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


PHP XPClass::getName方法代码示例

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


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

示例1: qnameFor

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

示例2: __construct

 /**
  * Creates a new array type instance
  *
  * @param  lang.XPClass $base
  * @param  lang.Type[] $components
  */
 public function __construct(XPClass $base, array $components)
 {
     $this->base = $base;
     $this->components = $components;
     parent::__construct(sprintf('%s<%s>', $base->getName(), implode(',', array_map(function ($e) {
         return $e->getName();
     }, $components))), null);
 }
开发者ID:johannes85,项目名称:core,代码行数:14,代码来源:WildcardType.class.php

示例3: 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)
 {
     try {
         $Urimethod = $class->getClassLoader()->getClass()->getMethod('classURI');
         $Urimethod->setAccessible(TRUE);
         return $Urimethod->invoke($class->getClassLoader(), $class->getName());
     } catch (Exception $ignored) {
         return $class->getClassName();
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:16,代码来源:XmlTestListener.class.php

示例4: valueOf

 /**
  * Returns the enumeration member uniquely identified by its name
  *
  * @param   lang.XPClass class class object
  * @param   string name enumeration member
  * @return  lang.Enum
  * @throws  lang.IllegalArgumentException in case the enum member does not exist or when the given class is not an enum
  */
 public static function valueOf(XPClass $class, $name)
 {
     if (!$class->isEnum()) {
         throw new IllegalArgumentException('Argument class must be lang.XPClass<? extends lang.Enum>');
     }
     try {
         $prop = $class->reflect()->getStaticPropertyValue($name);
         if ($class->isInstance($prop)) {
             return $prop;
         }
     } catch (\ReflectionException $e) {
         throw new IllegalArgumentException($e->getMessage());
     }
     throw new IllegalArgumentException('No such member "' . $name . '" in ' . $class->getName());
 }
开发者ID:johannes85,项目名称:core,代码行数:23,代码来源:Enum.class.php

示例5: 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 = array();
     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:Gamepay,项目名称:xp-framework,代码行数:55,代码来源:Runner.class.php

示例6: 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:Gamepay,项目名称:xp-framework,代码行数:11,代码来源:Reflect.class.php

示例7: valuesOf

 /**
  * Returns the enumeration members for a given class
  *
  * @param  lang.XPClass class class object
  * @return self[]
  * @throws lang.IllegalArgumentException in case the given class is not an enum
  */
 public static function valuesOf(XPClass $class)
 {
     if (!$class->isEnum()) {
         throw new IllegalArgumentException('Argument class must be lang.XPClass<? extends lang.Enum>');
     }
     $r = [];
     if ($class->isSubclassOf(self::class)) {
         foreach ($class->reflect()->getStaticProperties() as $prop) {
             $class->isInstance($prop) && ($r[] = $prop);
         }
     } else {
         $t = ClassLoader::defineClass($class->getName() . 'Enum', self::class, []);
         foreach ($class->reflect()->getMethod('getValues')->invoke(null) as $name => $ordinal) {
             $r[] = $t->newInstance($ordinal, $name);
         }
     }
     return $r;
 }
开发者ID:xp-framework,项目名称:core,代码行数:25,代码来源:Enum.class.php

示例8: createGenericType

 /**
  * Creates a generic type
  *
  * @param   lang.XPClass self
  * @param   lang.Type[] arguments
  * @return  string created type's literal name
  */
 public static function createGenericType(XPClass $self, array $arguments)
 {
     // Verify
     $annotations = $self->getAnnotations();
     if (!isset($annotations['generic']['self'])) {
         throw new IllegalStateException('Class ' . $self->name . ' is not a generic definition');
     }
     $components = array();
     foreach (explode(',', $annotations['generic']['self']) as $cs => $name) {
         $components[] = ltrim($name);
     }
     $cs++;
     if ($cs !== sizeof($arguments)) {
         throw new IllegalArgumentException(sprintf('Class %s expects %d component(s) <%s>, %d argument(s) given', $self->name, $cs, implode(', ', $components), sizeof($arguments)));
     }
     // Compose names
     $cn = $qc = '';
     foreach ($arguments as $typearg) {
         $cn .= '¸' . strtr($typearg->literal(), '\\', '¦');
         $qc .= ',' . $typearg->getName();
     }
     $name = $self->literal() . '··' . substr($cn, 1);
     $qname = $self->name . '<' . substr($qc, 1) . '>';
     // Create class if it doesn't exist yet
     if (!class_exists($name, FALSE) && !interface_exists($name, FALSE)) {
         $meta = xp::$meta[$self->name];
         // Parse placeholders into a lookup map
         $placeholders = array();
         foreach ($components as $i => $component) {
             $placeholders[$component] = $arguments[$i]->getName();
         }
         // Work on sourcecode
         $cl = self::_classLoaderFor($self->name);
         if (!$cl || !($bytes = $cl->loadClassBytes($self->name))) {
             throw new IllegalStateException($self->name);
         }
         // Namespaced class
         if (FALSE !== ($ns = strrpos($name, '\\'))) {
             $decl = substr($name, $ns + 1);
             $namespace = substr($name, 0, $ns);
             $src = 'namespace ' . $namespace . ';';
         } else {
             $decl = $name;
             $namespace = NULL;
             $src = '';
         }
         // Replace source
         $annotation = NULL;
         $matches = array();
         $state = array(0);
         $counter = 0;
         $tokens = token_get_all($bytes);
         for ($i = 0, $s = sizeof($tokens); $i < $s; $i++) {
             if (T_COMMENT === $tokens[$i][0]) {
                 continue;
             } else {
                 if (0 === $state[0]) {
                     if (T_ABSTRACT === $tokens[$i][0] || T_FINAL === $tokens[$i][0]) {
                         $src .= $tokens[$i][1] . ' ';
                     } else {
                         if (T_CLASS === $tokens[$i][0] || T_INTERFACE === $tokens[$i][0]) {
                             $meta['class'][DETAIL_GENERIC] = array($self->name, $arguments);
                             $src .= $tokens[$i][1] . ' ' . $decl;
                             array_unshift($state, $tokens[$i][0]);
                         }
                     }
                     continue;
                 } else {
                     if (T_CLASS === $state[0]) {
                         if (T_EXTENDS === $tokens[$i][0]) {
                             $i += 2;
                             $parent = '';
                             while ((T_STRING === $tokens[$i][0] || T_NS_SEPARATOR === $tokens[$i][0]) && $i < $s) {
                                 $parent .= $tokens[$i][1];
                                 $i++;
                             }
                             $i--;
                             '\\' === $parent[0] || ($parent = $namespace . '\\' . $parent);
                             if (isset($annotations['generic']['parent'])) {
                                 $xargs = array();
                                 foreach (explode(',', $annotations['generic']['parent']) as $j => $placeholder) {
                                     $xargs[] = Type::forName(strtr(ltrim($placeholder), $placeholders));
                                 }
                                 $src .= ' extends \\' . self::createGenericType($self->getParentClass(), $xargs);
                             } else {
                                 $src .= ' extends ' . $parent;
                             }
                         } else {
                             if (T_IMPLEMENTS === $tokens[$i][0]) {
                                 $src .= ' implements';
                                 $counter = 0;
                                 $annotation = @$annotations['generic']['implements'];
                                 array_unshift($state, 5);
//.........这里部分代码省略.........
开发者ID:melogamepay,项目名称:xp-framework,代码行数:101,代码来源:XPClass.class.php

示例9: registerMapping

 /**
  * Registers a class map
  *
  * @param   xml.QName object
  * @param   lang.XPClass class
  */
 public function registerMapping(QName $qname, XPClass $class)
 {
     $this->map[$qname->localpart] = xp::reflect($class->getName());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:NativeSoapClient.class.php


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