当前位置: 首页>>代码示例>>PHP>>正文


PHP XPClass::literal方法代码示例

本文整理汇总了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]);
         }
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:35,代码来源:ClassParser.class.php

示例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();
 }
开发者ID:treuter,项目名称:webservices,代码行数:10,代码来源:NativeSoapClient.class.php

示例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]);
     }
 }
开发者ID:xp-framework,项目名称:unittest,代码行数:22,代码来源:VerifyThat.class.php


注:本文中的lang\XPClass::literal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。