Core Function ClassList

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> ClassList( <expression> ) </pre> === Description === Return an array of all user defined classes (Or just ones fitting a given pattern). ==== expression ==== Optional; ...")
 
 
(3 intermediate revisions by one user not shown)
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 ===
Line 24: Line 28:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
// Define a few user functions
+
// Define a few user classes
Function moo() { }
+
Class moo { };
Function cat() { }
+
Class cat { };
Function dog() { }
+
Class dog { };
Function fox9() { }
+
Class fox9 { };
 
+
// All functions
+
// All classes
foreach(FunctionList() as $c)
+
foreach(ClassList() as $c)
 
{
 
{
 
println("F: " . $c);
 
println("F: " . $c);
 
}
 
}
 
println("Loop complete\n");
 
println("Loop complete\n");
 
+
// All functions that contain "at"
+
// All classes that contain "at"
foreach(FunctionList("at") as $c)
+
foreach(ClassList("at") as $c)
 
{
 
{
 
println("F: " . $c);
 
println("F: " . $c);
 
}
 
}
 
println("Loop complete\n");
 
println("Loop complete\n");
 
+
// All functions that match the regex pattern \w+\d
+
// All classes that match the regex pattern \w+\d
foreach(FunctionList(m/\w+\d/) as $c)
+
foreach(ClassList(m/\w+\d/) as $c)
 
{
 
{
 
println("F: " . $c);
 
println("F: " . $c);

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");
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox