Core Function ClassList
From Sputnik Wiki
(Difference between revisions)
m (1 revision) |
|||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
− | ClassList( <expression> ) | + | ClassList( <expression>, <inherits> ) |
</pre> | </pre> | ||
Line 10: | Line 10: | ||
Optional; Text to find contained in the class names or a regex to match against the class names. | Optional; Text to find contained in the class names or a regex to match against the class names. | ||
+ | |||
+ | ==== inherits ==== | ||
+ | |||
+ | Optional; Checks the inheritance of the classes as well for matches given here (must be a complete class name) | ||
=== Return Value === | === Return Value === |
Latest revision as of 09:25, 19 June 2015
ClassList( <expression>, <inherits> )
Contents |
Description
Return an array of all user defined classes (Or just ones fitting a given pattern).
expression
Optional; Text to find contained in the class names or a regex to match against the class names.
inherits
Optional; Checks the inheritance of the classes as well for matches given here (must be a complete class name)
Return Value
Success: Returns an array of the found classes.
Failure: Returns an empty array.
Remarks
None.
Example
// Define a few user classes Class moo { }; Class cat { }; Class dog { }; Class fox9 { }; // All classes foreach(ClassList() as $c) { println("F: " . $c); } println("Loop complete\n"); // All classes that contain "at" foreach(ClassList("at") as $c) { println("F: " . $c); } println("Loop complete\n"); // All classes that match the regex pattern \w+\d foreach(ClassList(m/\w+\d/) as $c) { println("F: " . $c); } println("Loop complete\n");