lithium\analysis\Inspector::parents PHP Method

parents() public static method

Gets the full inheritance list for the given class.
public static parents ( string $class, array $options = [] ) : array
$class string Class whose inheritance chain will be returned
$options array Option consists of: - `'autoLoad'` _boolean_: Whether or not to call `__autoload` by default. Defaults to `true`.
return array An array of the name of the parent classes of the passed `$class` parameter, or `false` on error.
    public static function parents($class, array $options = array())
    {
        $defaults = array('autoLoad' => false);
        $options += $defaults;
        $class = is_object($class) ? get_class($class) : $class;
        if (!class_exists($class, $options['autoLoad'])) {
            return false;
        }
        return class_parents($class);
    }

Usage Example

Example #1
0
 /**
  * Tests getting a list of parent classes from an object or string class name.
  */
 public function testClassParents()
 {
     $result = Inspector::parents($this);
     $this->assertEqual('lithium\\test\\Unit', current($result));
     $result2 = Inspector::parents(__CLASS__);
     $this->assertEqual($result2, $result);
     $this->assertFalse(Inspector::parents('lithium\\core\\Foo', array('autoLoad' => false)));
 }
All Usage Examples Of lithium\analysis\Inspector::parents