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


PHP Reflector::getName方法代码示例

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


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

示例1: getAll

	/**
	 * Returns annotations.
	 * @param  \ReflectionClass|\ReflectionMethod|\ReflectionProperty
	 * @return array
	 */
	public static function getAll(\Reflector $r)
	{
		if ($r instanceof \ReflectionClass) {
			$type = $r->getName();
			$member = '';

		} elseif ($r instanceof \ReflectionMethod) {
			$type = $r->getDeclaringClass()->getName();
			$member = $r->getName();

		} else {
			$type = $r->getDeclaringClass()->getName();
			$member = '$' . $r->getName();
		}

		if (!self::$useReflection) { // auto-expire cache
			$file = $r instanceof \ReflectionClass ? $r->getFileName() : $r->getDeclaringClass()->getFileName(); // will be used later
			if ($file && isset(self::$timestamps[$file]) && self::$timestamps[$file] !== filemtime($file)) {
				unset(self::$cache[$type]);
			}
			unset(self::$timestamps[$file]);
		}

		if (isset(self::$cache[$type][$member])) { // is value cached?
			return self::$cache[$type][$member];
		}

		if (self::$useReflection === NULL) { // detects whether is reflection available
			self::$useReflection = (bool) Nette\Reflection\ClassReflection::from(__CLASS__)->getDocComment();
		}

		if (self::$useReflection) {
			return self::$cache[$type][$member] = self::parseComment($r->getDocComment());

		} else {
			if (self::$cache === NULL) {
				self::$cache = (array) self::getCache()->offsetGet('list');
				self::$timestamps = isset(self::$cache['*']) ? self::$cache['*'] : array();
			}

			if (!isset(self::$cache[$type]) && $file) {
				self::$cache['*'][$file] = filemtime($file);
				self::parseScript($file);
				self::getCache()->save('list', self::$cache);
			}

			if (isset(self::$cache[$type][$member])) {
				return self::$cache[$type][$member];
			} else {
				return self::$cache[$type][$member] = array();
			}
		}
	}
开发者ID:JanTvrdik,项目名称:StaticWeb,代码行数:58,代码来源:AnnotationsParser.php

示例2: getAnnotationsFor

 /**
  * Get annotations for reflector
  *
  * @param \Reflector $reflector
  *
  * @return array
  */
 public function getAnnotationsFor(\Reflector $reflector)
 {
     if ($reflector instanceof \ReflectionClass) {
         return $this->getClassAnnotations($reflector->getName());
     } elseif ($reflector instanceof \ReflectionMethod) {
         return $this->getMethodAnnotations($reflector->getDeclaringClass()->getName(), $reflector->getName());
     } elseif ($reflector instanceof \ReflectionProperty) {
         return $this->getPropertyAnnotations($reflector->getDeclaringClass()->getName(), $reflector->getName());
     } else {
         return [];
     }
 }
开发者ID:thinframe,项目名称:annotations,代码行数:19,代码来源:Collector.php

示例3: getCodeDocs

 /**
  * @param \Reflector $reflection
  * @param string $type
  *   If we are not reflecting the class itself, specify "Method", "Property", etc.
  *
  * @return array
  */
 public static function getCodeDocs($reflection, $type = NULL)
 {
     $docs = self::parseDocBlock($reflection->getDocComment());
     // Recurse into parent functions
     if (isset($docs['inheritDoc'])) {
         unset($docs['inheritDoc']);
         $newReflection = NULL;
         try {
             if ($type) {
                 $name = $reflection->getName();
                 $reflectionClass = $reflection->getDeclaringClass()->getParentClass();
                 if ($reflectionClass) {
                     $getItem = "get{$type}";
                     $newReflection = $reflectionClass->{$getItem}($name);
                 }
             } else {
                 $newReflection = $reflection->getParentClass();
             }
         } catch (\ReflectionException $e) {
         }
         if ($newReflection) {
             // Mix in
             $additionalDocs = self::getCodeDocs($newReflection, $type);
             if (!empty($docs['comment']) && !empty($additionalDocs['comment'])) {
                 $docs['comment'] .= "\n\n" . $additionalDocs['comment'];
             }
             $docs += $additionalDocs;
         }
     }
     return $docs;
 }
开发者ID:civicrm,项目名称:api4,代码行数:38,代码来源:ReflectionUtils.php

示例4: isGetter

 /**
  * @return bool
  */
 protected function isGetter()
 {
     if (!$this->isMethod()) {
         return false;
     }
     $name = $this->reflector->getName();
     $parse = substr($name, 0, 3);
     return $parse == 'get';
 }
开发者ID:sphring,项目名称:sphring,代码行数:12,代码来源:AbstractAnnotation.php

示例5: elseif

 /**
  * Parses and caches annotations.
  * @param  \ReflectionClass|\ReflectionMethod|\ReflectionProperty
  * @return array
  */
 public static function &init(Reflector $r)
 {
     $cache =& self::$cache[$r->getName()];
     if ($r instanceof ReflectionClass) {
         $cache =& $cache[''];
     } elseif ($r instanceof ReflectionMethod) {
         $cache =& $cache[$r->getDeclaringClass()->getName()];
     } else {
         $cache =& $cache['$' . $r->getDeclaringClass()->getName()];
     }
     if ($cache !== NULL) {
         return $cache;
     }
     preg_match_all('#@([a-zA-Z0-9_]+)(?:\\(((?>[^\'")]+|\'[^\']*\'|"[^"]*")*)\\))?#', $r->getDocComment(), $matches, PREG_SET_ORDER);
     $cache = array();
     foreach ($matches as $match) {
         if (isset($match[2])) {
             preg_match_all('#[,\\s](?>([a-zA-Z0-9_]+)\\s*=\\s*)?([^\'",\\s][^,]*|\'[^\']*\'|"[^"]*")#', ',' . $match[2], $matches, PREG_SET_ORDER);
             $items = array();
             $key = '';
             $val = TRUE;
             foreach ($matches as $m) {
                 list(, $key, $val) = $m;
                 if ($val[0] === "'" || $val[0] === '"') {
                     $val = substr($val, 1, -1);
                 } elseif (strcasecmp($val, 'true') === 0) {
                     $val = TRUE;
                 } elseif (strcasecmp($val, 'false') === 0) {
                     $val = FALSE;
                 } elseif (strcasecmp($val, 'null') === 0) {
                     $val = NULL;
                 } elseif (is_numeric($val)) {
                     $val = 1 * $val;
                 }
                 if ($key === '') {
                     $items[] = $val;
                 } else {
                     $items[$key] = $val;
                 }
             }
             $items = count($items) < 2 && $key === '' ? $val : new ArrayObject($items, ArrayObject::ARRAY_AS_PROPS);
         } else {
             $items = TRUE;
         }
         $cache[$match[1]][] = $items;
     }
     return $cache;
 }
开发者ID:vlki,项目名称:nette,代码行数:53,代码来源:Annotations.php

示例6: _getConfigGetter

 /**
  * @param \Reflector $thing
  * @throws \Exception
  * @return callable
  */
 protected function _getConfigGetter(\Reflector $thing = null)
 {
     $reader = $this->_getAnnotationReader();
     $annNS = $this->annNS;
     if ($thing === null) {
         return function ($ann) use($reader, $annNS) {
             return $reader->getSingleClassAnnotation($annNS . $ann);
         };
     }
     if ($thing instanceof \ReflectionMethod) {
         return function ($ann) use($reader, $thing, $annNS) {
             return $reader->getSingleMethodAnnotation($thing->getName(), $annNS . $ann);
         };
     }
     if ($thing instanceof \ReflectionProperty) {
         return function ($ann) use($reader, $thing, $annNS) {
             return $reader->getSinglePropertyAnnotation($thing->getName(), $annNS . $ann);
         };
     }
     throw new \Exception("Unable to work out how to configure a " . get_class($thing));
 }
开发者ID:siad007,项目名称:php-weasel,代码行数:26,代码来源:ClassAnnotationDriver.php

示例7: getAll

 /**
  * Returns annotations.
  * @param  \ReflectionClass|\ReflectionMethod|\ReflectionProperty
  * @return array
  */
 public static function getAll(\Reflector $r)
 {
     if ($r instanceof \ReflectionClass) {
         $type = $r->getName();
         $member = 'class';
     } elseif ($r instanceof \ReflectionMethod) {
         $type = $r->getDeclaringClass()->getName();
         $member = $r->getName();
     } else {
         $type = $r->getDeclaringClass()->getName();
         $member = '$' . $r->getName();
     }
     if (!self::$useReflection) {
         // auto-expire cache
         $file = $r instanceof \ReflectionClass ? $r->getFileName() : $r->getDeclaringClass()->getFileName();
         // will be used later
         if ($file && isset(self::$timestamps[$file]) && self::$timestamps[$file] !== filemtime($file)) {
             unset(self::$cache[$type]);
         }
         unset(self::$timestamps[$file]);
     }
     if (isset(self::$cache[$type][$member])) {
         // is value cached?
         return self::$cache[$type][$member];
     }
     if (self::$useReflection === NULL) {
         // detects whether is reflection available
         self::$useReflection = (bool) ClassType::from(__CLASS__)->getDocComment();
     }
     if (self::$useReflection) {
         $annotations = self::parseComment($r->getDocComment());
     } else {
         if (!self::$cacheStorage) {
             // trigger_error('Set a cache storage for annotations parser via Nette\Reflection\AnnotationParser::setCacheStorage().', E_USER_WARNING);
             self::$cacheStorage = new Nette\Caching\Storages\DevNullStorage();
         }
         $outerCache = new Nette\Caching\Cache(self::$cacheStorage, 'Nette.Reflection.Annotations');
         if (self::$cache === NULL) {
             self::$cache = (array) $outerCache->load('list');
             self::$timestamps = isset(self::$cache['*']) ? self::$cache['*'] : array();
         }
         if (!isset(self::$cache[$type]) && $file) {
             self::$cache['*'][$file] = filemtime($file);
             foreach (self::parsePhp(file_get_contents($file)) as $class => $info) {
                 foreach ($info as $prop => $comment) {
                     if ($prop !== 'use') {
                         self::$cache[$class][$prop] = self::parseComment($comment);
                     }
                 }
             }
             $outerCache->save('list', self::$cache);
         }
         if (isset(self::$cache[$type][$member])) {
             $annotations = self::$cache[$type][$member];
         } else {
             $annotations = array();
         }
     }
     if ($r instanceof \ReflectionMethod && !$r->isPrivate() && (!$r->isConstructor() || !empty($annotations['inheritdoc'][0]))) {
         try {
             $inherited = self::getAll(new \ReflectionMethod(get_parent_class($type), $member));
         } catch (\ReflectionException $e) {
             try {
                 $inherited = self::getAll($r->getPrototype());
             } catch (\ReflectionException $e) {
                 $inherited = array();
             }
         }
         $annotations += array_intersect_key($inherited, array_flip(self::$inherited));
     }
     return self::$cache[$type][$member] = $annotations;
 }
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:77,代码来源:AnnotationsParser.php

示例8: _annotationTarget

/**
 * returns annotation target for given reflector
 *
 * @internal
 * @param   \Reflector $reflector
 * @return  string
 * @throws  \ReflectionException
 * @since   5.3.0
 */
function _annotationTarget(\Reflector $reflector) : string
{
    if ($reflector instanceof \ReflectionClass) {
        return $reflector->getName();
    }
    if ($reflector instanceof \ReflectionMethod) {
        return $reflector->class . '::' . $reflector->getName() . '()';
    }
    if ($reflector instanceof \ReflectionFunction) {
        return $reflector->getName() . '()';
    }
    if ($reflector instanceof \ReflectionParameter) {
        return _annotationTarget($reflector->getDeclaringFunction()) . '#' . $reflector->getName();
    }
    if ($reflector instanceof \ReflectionProperty) {
        return $reflector->class . ($reflector->isStatic() ? '::$' : '->') . $reflector->getName();
    }
    throw new \ReflectionException('Can not retrieve target for ' . get_class($reflector));
}
开发者ID:stubbles,项目名称:stubbles-reflect,代码行数:28,代码来源:functions.php

示例9: formatName

 /**
  * Print the signature name.
  *
  * @param \Reflector $reflector
  *
  * @return string Formatted name.
  */
 public static function formatName(\Reflector $reflector)
 {
     return $reflector->getName();
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:11,代码来源:SignatureFormatter.php

示例10: convertReflectorToTest

 private function convertReflectorToTest(\Reflector $reflector)
 {
     $name = $reflector->getName();
     return method_exists($reflector, 'isClosure') ? new FunctionTest($name) : new ClassTest(new $name());
 }
开发者ID:phpassert,项目名称:core,代码行数:5,代码来源:FSDiscoverer.php

示例11: getAll

 static function getAll(\Reflector $r)
 {
     if ($r instanceof \ReflectionClass) {
         $type = $r->getName();
         $member = '';
     } elseif ($r instanceof \ReflectionMethod) {
         $type = $r->getDeclaringClass()->getName();
         $member = $r->getName();
     } else {
         $type = $r->getDeclaringClass()->getName();
         $member = '$' . $r->getName();
     }
     if (!self::$useReflection) {
         $file = $r instanceof \ReflectionClass ? $r->getFileName() : $r->getDeclaringClass()->getFileName();
         if ($file && isset(self::$timestamps[$file]) && self::$timestamps[$file] !== filemtime($file)) {
             unset(self::$cache[$type]);
         }
         unset(self::$timestamps[$file]);
     }
     if (isset(self::$cache[$type][$member])) {
         return self::$cache[$type][$member];
     }
     if (self::$useReflection === NULL) {
         self::$useReflection = (bool) ClassType::from(__CLASS__)->getDocComment();
     }
     if (self::$useReflection) {
         $annotations = self::parseComment($r->getDocComment());
     } else {
         if (!self::$cacheStorage) {
             self::$cacheStorage = new Nette\Caching\Storages\DevNullStorage();
         }
         $outerCache = new Nette\Caching\Cache(self::$cacheStorage, 'Nette.Reflection.Annotations');
         if (self::$cache === NULL) {
             self::$cache = (array) $outerCache->offsetGet('list');
             self::$timestamps = isset(self::$cache['*']) ? self::$cache['*'] : array();
         }
         if (!isset(self::$cache[$type]) && $file) {
             self::$cache['*'][$file] = filemtime($file);
             self::parseScript($file);
             $outerCache->save('list', self::$cache);
         }
         if (isset(self::$cache[$type][$member])) {
             $annotations = self::$cache[$type][$member];
         } else {
             $annotations = array();
         }
     }
     if ($r instanceof \ReflectionMethod && !$r->isPrivate() && (!$r->isConstructor() || !empty($annotations['inheritdoc'][0]))) {
         try {
             $inherited = self::getAll(new \ReflectionMethod(get_parent_class($type), $member));
         } catch (\ReflectionException $e) {
             try {
                 $inherited = self::getAll($r->getPrototype());
             } catch (\ReflectionException $e) {
                 $inherited = array();
             }
         }
         $annotations += array_intersect_key($inherited, array_flip(self::$inherited));
     }
     return self::$cache[$type][$member] = $annotations;
 }
开发者ID:rotten77,项目名称:xcv,代码行数:61,代码来源:nette.min.php

示例12: getAll

 static function getAll(Reflector $r)
 {
     if ($r instanceof ReflectionClass) {
         $type = $r->getName();
         $member = '';
     } elseif ($r instanceof ReflectionMethod) {
         $type = $r->getDeclaringClass()->getName();
         $member = $r->getName();
     } else {
         $type = $r->getDeclaringClass()->getName();
         $member = '$' . $r->getName();
     }
     if (!self::$useReflection) {
         $file = $r instanceof ReflectionClass ? $r->getFileName() : $r->getDeclaringClass()->getFileName();
         if ($file && isset(self::$timestamps[$file]) && self::$timestamps[$file] !== filemtime($file)) {
             unset(self::$cache[$type]);
         }
         unset(self::$timestamps[$file]);
     }
     if (isset(self::$cache[$type][$member])) {
         return self::$cache[$type][$member];
     }
     if (self::$useReflection === NULL) {
         self::$useReflection = (bool) NClassReflection::from(__CLASS__)->getDocComment();
     }
     if (self::$useReflection) {
         return self::$cache[$type][$member] = self::parseComment($r->getDocComment());
     } else {
         if (self::$cache === NULL) {
             self::$cache = (array) self::getCache()->offsetGet('list');
             self::$timestamps = isset(self::$cache['*']) ? self::$cache['*'] : array();
         }
         if (!isset(self::$cache[$type]) && $file) {
             self::$cache['*'][$file] = filemtime($file);
             self::parseScript($file);
             self::getCache()->save('list', self::$cache);
         }
         if (isset(self::$cache[$type][$member])) {
             return self::$cache[$type][$member];
         } else {
             return self::$cache[$type][$member] = array();
         }
     }
 }
开发者ID:kacer,项目名称:FakturoidPairing,代码行数:44,代码来源:nette.php

示例13: addParameterMapping

 /**
  * This mapping is used in the _wakeup-method to set the parameters after _sleep.
  *
  * @param \Reflector $field
  * @param array $mapping
  */
 public function addParameterMapping(\Reflector $field, $mapping = array())
 {
     $fieldName = $field->getName();
     $this->parameters[$fieldName] = $mapping;
 }
开发者ID:revinate,项目名称:search-bundle,代码行数:11,代码来源:ClassMetadata.php

示例14: getName

 /** For use with array_map to create an array of strings from an array of Reflection objects via their ->getName() methods **/
 private static function getName(Reflector $o)
 {
     return $o->getName();
 }
开发者ID:ahri,项目名称:ahriphplibs,代码行数:5,代码来源:CodeListing.classes.php

示例15: __construct

 public function __construct(\Reflector $ref, array $exceptions)
 {
     parent::__construct(sprintf('No Manual page found for %s (%s) in %s', $ref->getName(), get_class($ref), implode(', ', array_keys($exceptions))), 0, end($exceptions));
     $ref = $ref;
     $this->orig = $exceptions;
 }
开发者ID:johannes,项目名称:php-explorer,代码行数:6,代码来源:Manual.php


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