Core Function ClassList
From Sputnik Wiki
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");