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


PHP XPClass::getName方法代码示例

本文整理汇总了PHP中lang\XPClass::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP XPClass::getName方法的具体用法?PHP XPClass::getName怎么用?PHP XPClass::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lang\XPClass的用法示例。


在下文中一共展示了XPClass::getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: qnameFor

 /**
  * Fetch a qname for a class.
  *
  * @param   lang.XPClass class
  * @return  var xml.QName or NULL if no mapping exists
  */
 public function qnameFor(\lang\XPClass $class)
 {
     if (!isset($this->_c2q[$class->getName()])) {
         return null;
     }
     return $this->_qnames[$this->_c2q[$class->getName()]];
 }
开发者ID:treuter,项目名称:webservices,代码行数:13,代码来源:XPSoapMapping.class.php

示例3: interfaceNamed

 /**
  * Locate interface by a given name
  *
  * @param  lang.XPClass $class
  * @param  string $name
  * @return lang.XPClass
  * @throws lang.ElementNotFoundException
  */
 private function interfaceNamed($class, $name)
 {
     foreach ($class->getInterfaces() as $iface) {
         if (strstr($iface->getName(), $name)) {
             return $iface;
         }
     }
     throw new ElementNotFoundException('Class ' . $class->getName() . ' does not implement ' . $name);
 }
开发者ID:xp-framework,项目名称:core,代码行数:17,代码来源:ImplementationTest.class.php

示例4: newInstance

 /**
  * Creates a new instance of a given class. If the constructor uses
  * injection, the arguments are compiled from the relevant annotations.
  * Otherwise, optional constructor arguments may be passed.
  *
  * @param   lang.XPClass $class
  * @param   [:var] $named Named arguments
  * @return  var
  * @throws  inject.ProvisionException
  */
 public function newInstance(XPClass $class, $named = [])
 {
     if ($class->hasConstructor()) {
         $constructor = $class->getConstructor();
         try {
             return $constructor->newInstance($this->args($constructor, $named));
         } catch (TargetInvocationException $e) {
             throw new ProvisionException('Error creating an instance of ' . $class->getName(), $e->getCause());
         } catch (Throwable $e) {
             throw new ProvisionException('Error creating an instance of ' . $class->getName(), $e);
         }
     } else {
         return $class->newInstance();
     }
 }
开发者ID:xp-forge,项目名称:inject,代码行数:25,代码来源:Injector.class.php

示例5: displayNameOf

 /**
  * Gets class name (and generic components if this class is a 
  * generic definition)
  *
  * @param   lang.XPClass class
  * @return  string
  */
 protected static function displayNameOf(XPClass $class)
 {
     return $class->getName() . ($class->isGenericDefinition() ? '<' . implode(', ', $class->genericComponents()) . '>' : '');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:11,代码来源:Reflect.class.php

示例6: showUsage

 /**
  * Show usage
  *
  * @param   lang.XPClass class
  */
 public static function showUsage(XPClass $class)
 {
     // Description
     if (null !== ($comment = $class->getComment())) {
         self::$err->writeLine(self::textOf($comment));
         self::$err->writeLine(str_repeat('=', 72));
     }
     $extra = $details = $positional = [];
     foreach ($class->getMethods() as $method) {
         if (!$method->hasAnnotation('arg')) {
             continue;
         }
         $arg = $method->getAnnotation('arg');
         $name = strtolower(preg_replace('/^set/', '', $method->getName()));
         $comment = self::textOf($method->getComment());
         if (0 == $method->numParameters()) {
             $optional = true;
         } else {
             list($first, ) = $method->getParameters();
             $optional = $first->isOptional();
         }
         if (isset($arg['position'])) {
             $details['#' . ($arg['position'] + 1)] = $comment;
             $positional[$arg['position']] = $name;
         } else {
             if (isset($arg['name'])) {
                 $details['--' . $arg['name'] . ' | -' . (isset($arg['short']) ? $arg['short'] : $arg['name'][0])] = $comment;
                 $extra[$arg['name']] = $optional;
             } else {
                 $details['--' . $name . ' | -' . (isset($arg['short']) ? $arg['short'] : $name[0])] = $comment;
                 $extra[$name] = $optional;
             }
         }
     }
     // Usage
     asort($positional);
     self::$err->write('Usage: $ xpcli ', $class->getName(), ' ');
     foreach ($positional as $name) {
         self::$err->write('<', $name, '> ');
     }
     foreach ($extra as $name => $optional) {
         self::$err->write($optional ? '[' : '', '--', $name, $optional ? '] ' : ' ');
     }
     self::$err->writeLine();
     // Argument details
     self::$err->writeLine('Arguments:');
     foreach ($details as $which => $comment) {
         self::$err->writeLine('* ', $which, "\n  ", str_replace("\n", "\n  ", $comment), "\n");
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:55,代码来源:Runner.class.php

示例7: uriFor

 /**
  * Tries to get class uri via reflection
  *
  * @param  lang.XPClass class The class to return the URI for
  * @return string
  */
 private function uriFor(XPClass $class)
 {
     return $class->getClassLoader()->classUri($class->getName());
 }
开发者ID:xp-framework,项目名称:unittest,代码行数:10,代码来源:XmlTestListener.class.php


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