本文整理汇总了PHP中lithium\analysis\Inspector::classes方法的典型用法代码示例。如果您正苦于以下问题:PHP Inspector::classes方法的具体用法?PHP Inspector::classes怎么用?PHP Inspector::classes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\analysis\Inspector
的用法示例。
在下文中一共展示了Inspector::classes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _closureDef
/**
* Helper method for caching closure function references to help the process of building the
* stack trace.
*
* @param array $frame Backtrace information.
* @param callable|string $function The method related to $frame information.
* @return string Returns either the cached or the fetched closure function reference while
* writing its reference to the cache array `$_closureCache`.
*/
protected static function _closureDef($frame, $function)
{
$reference = '::';
$frame += array('file' => '??', 'line' => '??');
$cacheKey = "{$frame['file']}@{$frame['line']}";
if (isset(static::$_closureCache[$cacheKey])) {
return static::$_closureCache[$cacheKey];
}
if ($class = Inspector::classes(array('file' => $frame['file']))) {
foreach (Inspector::methods(key($class), 'extents') as $method => $extents) {
$line = $frame['line'];
if (!($extents[0] <= $line && $line <= $extents[1])) {
continue;
}
$class = key($class);
$reference = "{$class}::{$method}";
$function = "{$reference}()::{closure}";
break;
}
} else {
$reference = $frame['file'];
$function = "{$reference}::{closure}";
}
$line = static::_definition($reference, $frame['line']) ?: '?';
$function .= " @ {$line}";
return static::$_closureCache[$cacheKey] = $function;
}
示例2: testClassFileIntrospection
public function testClassFileIntrospection()
{
$result = Inspector::classes(array('file' => __FILE__));
$this->assertEqual(array(__CLASS__ => __FILE__), $result);
$result = Inspector::classes(array('file' => __FILE__, 'group' => 'files'));
$this->assertCount(1, $result);
$this->assertEqual(__FILE__, key($result));
$result = Inspector::classes(array('file' => __FILE__, 'group' => 'foo'));
$this->assertEqual(array(), $result);
}