本文整理汇总了PHP中XPClass::detailsForClass方法的典型用法代码示例。如果您正苦于以下问题:PHP XPClass::detailsForClass方法的具体用法?PHP XPClass::detailsForClass怎么用?PHP XPClass::detailsForClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPClass
的用法示例。
在下文中一共展示了XPClass::detailsForClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadClass0
/**
* Load the class by the specified name
*
* @param string class fully qualified class name io.File
* @return string class name
* @throws lang.ClassNotFoundException in case the class can not be found
* @throws lang.ClassFormatException in case the class format is invalud
*/
public function loadClass0($class)
{
$name = strtr($class, '.', '\\');
if (isset(\xp::$cl[$class])) {
return $name;
}
// Load class
\xp::$cl[$class] = nameof($this) . '://' . $this->path;
\xp::$cll++;
try {
$r = (include $this->classUri($class));
} catch (ClassLoadingException $e) {
unset(\xp::$cl[$class]);
\xp::$cll--;
// If class was declared, but loading threw an exception it means
// a "soft" dependency, one that is only required at runtime, was
// not loaded, the class itself has been declared.
if (class_exists($name, false) || interface_exists($name, false) || trait_exists($name, false)) {
throw new ClassDependencyException($class, [$this], $e);
}
// If otherwise, a "hard" dependency could not be loaded, eg. the
// base class or a required interface and thus the class could not
// be declared.
throw new ClassLinkageException($class, [$this], $e);
}
\xp::$cll--;
if (false === $r) {
unset(\xp::$cl[$class]);
$e = new ClassNotFoundException($class, [$this]);
\xp::gc(__FILE__);
throw $e;
} else {
if (!class_exists($name, false) && !interface_exists($name, false) && !trait_exists($name, false)) {
$details = XPClass::detailsForClass($class);
$uri = $this->classUri($class);
unset(\xp::$cl[$class]);
if (isset($details['class'])) {
$reflect = new \ReflectionClass($details['class'][DETAIL_ARGUMENTS]);
\xp::$errors[$uri][$reflect->getStartLine()] = ['' => 1];
$e = new ClassFormatException('File does not declare type `' . $class . '`, but `' . strtr($reflect->getName(), '\\', '.') . '`');
\xp::gc($uri);
throw $e;
} else {
throw new ClassFormatException('Loading `' . $class . '`: No types declared in ' . $this->classUri($class));
}
}
}
method_exists($name, '__static') && (\xp::$cli[] = [$name, '__static']);
if (0 === \xp::$cll) {
$invocations = \xp::$cli;
\xp::$cli = [];
foreach ($invocations as $inv) {
$inv($name);
}
}
return $name;
}
示例2: canBeCachedViaXpRegistry
public function canBeCachedViaXpRegistry()
{
with(xp::$registry['details.' . ($fixture = 'DummyDetails')] = $details = $this->dummyDetails());
$actual = XPClass::detailsForClass($fixture);
unset(xp::$registry['details.' . $fixture]);
$this->assertEquals($details, $actual);
}