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`. |
Результат | array | An array of the name of the parent classes of the passed `$class` parameter, or `false` on error. |
/** * 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))); }
/** * Convert an exception object to an exception result array for test reporting. * * @param array $exception The exception data to report on. Statistics are gathered and * added to the reporting stack contained in `Unit::$_results`. * @param string $lineFlag * @return void * @todo Refactor so that reporters handle trace formatting. */ protected function _reportException($exception, $lineFlag = null) { $message = $exception['message']; $isExpected = ($exp = end($this->_expected)) && ($exp === true || $exp === $message || Validator::isRegex($exp) && preg_match($exp, $message)); if ($isExpected) { return array_pop($this->_expected); } $initFrame = current($exception['trace']) + array('class' => '-', 'function' => '-'); foreach ($exception['trace'] as $frame) { if (isset($scopedFrame)) { break; } if (!class_exists('lithium\\analysis\\Inspector')) { continue; } if (isset($frame['class']) && in_array($frame['class'], Inspector::parents($this))) { $scopedFrame = $frame; } } if (class_exists('lithium\\analysis\\Debugger')) { $exception['trace'] = Debugger::trace(array('trace' => $exception['trace'], 'format' => '{:functionRef}, line {:line}', 'includeScope' => false, 'scope' => array_filter(array('functionRef' => __NAMESPACE__ . '\\{closure}', 'line' => $lineFlag)))); } $this->_result('exception', $exception + array('class' => $initFrame['class'], 'method' => $initFrame['function'])); }
/** * Convert an exception object to an exception result array for test reporting. * * @param object $exception The exception object to report on. Statistics are gathered and * added to the reporting stack contained in `Unit::$_results`. * @param string $lineFlag * @return void * @todo Refactor so that reporters handle trace formatting. */ protected function _reportException($exception, $lineFlag = null) { $initFrame = current($exception['trace']) + array('class' => '-', 'function' => '-'); foreach ($exception['trace'] as $frame) { if (isset($scopedFrame)) { break; } if (!class_exists('lithium\\analysis\\Inspector')) { continue; } if (isset($frame['class']) && in_array($frame['class'], Inspector::parents($this))) { $scopedFrame = $frame; } } $trace = $exception['trace']; unset($exception['trace']); $this->_result('exception', $exception + array('class' => $initFrame['class'], 'method' => $initFrame['function'], 'trace' => Debugger::trace(array('trace' => $trace, 'format' => '{:functionRef}, line {:line}', 'includeScope' => false, 'scope' => array_filter(array('functionRef' => __NAMESPACE__ . '\\{closure}', 'line' => $lineFlag)))))); }