本文整理汇总了PHP中lang\XPClass::literal方法的典型用法代码示例。如果您正苦于以下问题:PHP XPClass::literal方法的具体用法?PHP XPClass::literal怎么用?PHP XPClass::literal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lang\XPClass
的用法示例。
在下文中一共展示了XPClass::literal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: memberOf
/**
* Resolves a class member, which is either a field, a class constant
* or the `ClassName::class` syntax, which returns the class' literal.
*
* @param lang.XPClass $class
* @param var[] $token A token as returned by `token_get_all()`
* @param string $context
* @return var
*/
protected function memberOf($class, $token, $context)
{
if (T_VARIABLE === $token[0]) {
$field = $class->getField(substr($token[1], 1));
$m = $field->getModifiers();
if ($m & MODIFIER_PUBLIC) {
return $field->get(null);
} else {
if ($m & MODIFIER_PROTECTED && $class->isAssignableFrom($context)) {
return $field->setAccessible(true)->get(null);
} else {
if ($m & MODIFIER_PRIVATE && $class->getName() === $context) {
return $field->setAccessible(true)->get(null);
} else {
throw new IllegalAccessException(sprintf('Cannot access %s field %s::$%s', implode(' ', Modifiers::namesOf($m)), $class->getName(), $field->getName()));
}
}
}
} else {
if (T_CLASS === $token[0]) {
return $class->literal();
} else {
return $class->getConstant($token[1]);
}
}
}
示例2: registerMapping
/**
* Registers a class map
*
* @param xml.QName object
* @param lang.XPClass class
*/
public function registerMapping(QName $qname, \lang\XPClass $class)
{
$this->map[$qname->localpart] = $class->literal();
}
示例3: beforeTestClass
/**
* This method gets invoked before any test method of the given class is
* invoked, and before any methods annotated with beforeTest.
*
* @param lang.XPClass $c
* @return void
* @throws unittest.PrerequisitesNotMetError
*/
public function beforeTestClass(\lang\XPClass $c)
{
if (0 === strncmp($this->prerequisite, '$this', 5)) {
throw new PrerequisitesNotMetError('Cannot use instance methods on a class action', null, [$this->prerequisite]);
}
try {
$verified = $this->verify->bindTo(null, $c->literal())->__invoke();
} catch (\lang\Throwable $e) {
throw new PrerequisitesNotMetError('Verification raised ' . $e->compoundMessage(), null, [$this->prerequisite]);
}
if (!$verified) {
throw new PrerequisitesNotMetError('Verification of failed', null, [$this->prerequisite]);
}
}