SPL-StandardPHPLibrary
Public Member Functions | Public Attributes | List of all members
SubClasses Class Reference
Inheritance diagram for SubClasses:
Inheritance graph
Collaboration diagram for SubClasses:
Collaboration graph

Public Member Functions

 __construct ($base, $check_interfaces=false)
 
 append ($value)
 
 asort ()
 
 count ()
 
 current ()
 
 getArrayCopy ()
 
 getChildren ()
 
 getFlags ()
 
 hasChildren ()
 
 key ()
 
 ksort ()
 
 natcasesort ()
 
 natsort ()
 
 next ()
 
 offsetExists ($index)
 
 offsetGet ($index)
 
 offsetSet ($index, $newval)
 
 offsetUnset ($index)
 
 rewind ()
 
 seek ($position)
 
 setFlags ($flags)
 
 uasort (mixed cmp_function)
 
 uksort (mixed cmp_function)
 
 valid ()
 

Public Attributes

const ARRAY_AS_PROPS = 0x00000002
 
const STD_PROP_LIST = 0x00000001
 

Detailed Description

Collects sub classes for given class or interface.

Definition at line 32 of file class_tree.php.

Constructor & Destructor Documentation

SubClasses::__construct (   $base,
  $check_interfaces = false 
)
Parameters
basebase class to collect sub classes for
check_interfaceswhether we deal with interfaces

Definition at line 37 of file class_tree.php.

References ArrayIterator\offsetSet(), and ArrayIterator\uksort().

38  {
39  foreach(get_declared_classes() as $cname)
40  {
41  $parent = get_parent_class($cname);
42  if (strcasecmp($parent, $base) == 0)
43  {
44  $this->offsetSet($cname, new SubClasses($cname));
45  }
46  if ($check_interfaces)
47  {
48  if ($parent)
49  {
50  $parent_imp = class_implements($parent);
51  }
52  foreach(class_implements($cname) as $iname)
53  {
54  if (strcasecmp($iname, $base) == 0)
55  {
56  if (!$parent || !in_array($iname, $parent_imp))
57  {
58  $this->offsetSet($cname, new SubClasses($cname));
59  }
60  }
61  }
62  }
63  }
64  if ($check_interfaces)
65  {
66  foreach(get_declared_interfaces() as $cname)
67  {
68  foreach(class_implements($cname) as $iname)
69  {
70  if (strcasecmp($iname, $base) == 0)
71  {
72  $this->offsetSet($cname, new SubClasses($cname, true));
73  }
74  }
75  }
76  }
77  $this->uksort('strnatcasecmp');
78  }
uksort(mixed cmp_function)
Sort the entries by key using user defined function.
Definition: spl.php:785
offsetSet($index, $newval)
Definition: spl.php:808
Collects sub classes for given class or interface.
Definition: class_tree.php:32

Here is the call graph for this function:

Member Function Documentation

ArrayIterator::append (   $value)
inherited
Parameters
$valueis appended as last element
Warning
this method cannot be called when the ArrayIterator refers to an object.

Definition at line 818 of file spl.php.

818 {}
ArrayIterator::asort ( )
inherited

Sort the entries by values.

Definition at line 773 of file spl.php.

773 {}
ArrayIterator::count ( )
inherited
Returns
the number of elements in the array or the number of public properties in the object.

Implements Countable.

Definition at line 834 of file spl.php.

834 {}
SubClasses::current ( )
Returns
key() since that is the name we need

Implements Iterator.

Definition at line 82 of file class_tree.php.

References ArrayIterator\natcasesort().

83  {
84  $result = parent::key();
85  $parent = get_parent_class($result);
86  if ($parent)
87  {
88  $interfaces = array_diff(class_implements($result), class_implements($parent));
89  if ($interfaces)
90  {
91  $implements = array();
92  foreach($interfaces as $interface)
93  {
94  $implements = array_merge($implements, class_implements($interface));
95  }
96  $interfaces = array_diff($interfaces, $implements);
97  natcasesort($interfaces);
98  $result .= ' (' . join(', ', $interfaces) . ')';
99  }
100  }
101  return $result;
102  }
natcasesort()
Sort the entries by values using case insensitive "natural order" algorithm.
Definition: spl.php:793

Here is the call graph for this function:

ArrayIterator::getArrayCopy ( )
inherited
Returns
a copy of the array
Note
when the ArrayIterator refers to an object then this method returns an array of the public properties.

Definition at line 824 of file spl.php.

824 {}
RecursiveArrayIterator::getChildren ( )
inherited
Returns
an iterator for the current elements children
Note
the returned iterator will be of the same class as $this

Implements RecursiveIterator.

Definition at line 43 of file recursivearrayiterator.inc.

References ArrayIterator\current().

44  {
45  if ($this->current() instanceof self)
46  {
47  return $this->current();
48  }
49  if (empty($this->ref))
50  {
51  $this->ref = new ReflectionClass($this);
52  }
53  return $this->ref->newInstance($this->current());
54  }
current()
Return the current element.
Definition: spl.php:843

Here is the call graph for this function:

ArrayIterator::getFlags ( )
inherited
Returns
current flags

Definition at line 769 of file spl.php.

769 {}
RecursiveArrayIterator::hasChildren ( )
inherited
Returns
whether the current element has children

Implements RecursiveIterator.

Definition at line 34 of file recursivearrayiterator.inc.

References ArrayIterator\current().

35  {
36  return is_array($this->current());
37  }
current()
Return the current element.
Definition: spl.php:843

Here is the call graph for this function:

ArrayIterator::key ( )
inherited

Return the key of the current element.

Implements Iterator.

Definition at line 846 of file spl.php.

846 {}
ArrayIterator::ksort ( )
inherited

Sort the entries by key.

Definition at line 777 of file spl.php.

777 {}
ArrayIterator::natcasesort ( )
inherited

Sort the entries by values using case insensitive "natural order" algorithm.

Definition at line 793 of file spl.php.

Referenced by current().

793 {}
ArrayIterator::natsort ( )
inherited

Sort the entries by values using "natural order" algorithm.

Definition at line 789 of file spl.php.

789 {}
ArrayIterator::next ( )
inherited

Move forward to next element.

Implements Iterator.

Definition at line 849 of file spl.php.

849 {}
ArrayIterator::offsetExists (   $index)
inherited
Parameters
$indexoffset to inspect
Returns
whetehr offset $index esists

Implements ArrayAccess.

Definition at line 798 of file spl.php.

798 {}
ArrayIterator::offsetGet (   $index)
inherited
Parameters
$indexoffset to return value for
Returns
value at offset $index

Implements ArrayAccess.

Definition at line 803 of file spl.php.

803 {}
ArrayIterator::offsetSet (   $index,
  $newval 
)
inherited
Parameters
$indexindex to set
$newvalnew value to store at offset $index

Implements ArrayAccess.

Definition at line 808 of file spl.php.

Referenced by __construct().

808 {}
ArrayIterator::offsetUnset (   $index)
inherited
Parameters
$indexoffset to unset

Implements ArrayAccess.

Definition at line 812 of file spl.php.

812 {}
ArrayIterator::rewind ( )
inherited

Rewind the Iterator to the first element.

Implements Iterator.

Definition at line 837 of file spl.php.

837 {}
ArrayIterator::seek (   $position)
inherited
Parameters
$positionoffset to seek to
Exceptions
OutOfBoundsExceptionif $position is invalid

Implements SeekableIterator.

Definition at line 829 of file spl.php.

829 {}
ArrayIterator::setFlags (   $flags)
inherited

Set behavior flags.

Parameters
$flagsbitmask as follows: 0 set: properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.) 1 set: array indices can be accessed as properties in read/write

Definition at line 764 of file spl.php.

764 {}
ArrayIterator::uasort ( mixed  cmp_function)
inherited

Sort the entries by values using user defined function.

Definition at line 781 of file spl.php.

781 {}
ArrayIterator::uksort ( mixed  cmp_function)
inherited

Sort the entries by key using user defined function.

Definition at line 785 of file spl.php.

Referenced by __construct().

785 {}
ArrayIterator::valid ( )
inherited

Check if there is a current element after calls to rewind() or next().

Implements Iterator.

Definition at line 840 of file spl.php.

840 {}

Member Data Documentation

const ArrayIterator::ARRAY_AS_PROPS = 0x00000002
inherited

Array indices can be accessed as properties in read/write.

Definition at line 747 of file spl.php.

const ArrayIterator::STD_PROP_LIST = 0x00000001
inherited

Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.)

Definition at line 745 of file spl.php.


The documentation for this class was generated from the following file: