本文整理匯總了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]);
}
}