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


PHP ReflectionParameter::getDeclaringFunction方法代码示例

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


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

示例1: getTypeOfParameter

 private function getTypeOfParameter(\ReflectionParameter $param)
 {
     if ($class = $param->getClass()) {
         return $class->name;
     }
     $paramName = $param->name;
     if (preg_match('/^[\\s\\/*]*@param\\s+(\\S+)\\s+\\$' . preg_quote($paramName, '/') . '\\W/m', $param->getDeclaringFunction()->getDocComment(), $matches)) {
         return $this->getFullNameOfType($matches[1], $param->getDeclaringFunction()->getDeclaringClass());
     }
     return;
 }
开发者ID:ranyuen,项目名称:di,代码行数:11,代码来源:Type.php

示例2: __construct

 public function __construct(\ReflectionParameter $parameter, array $classConfig, \rg\injektor\Configuration $config, \rg\injektor\DependencyInjectionContainer $dic, $mode)
 {
     $this->parameter = $parameter;
     $this->classConfig = $classConfig;
     $this->config = $config;
     $this->dic = $dic;
     $this->name = $parameter->name;
     $this->nameForAnnotationParsing = $parameter->name;
     $this->docComment = $this->parameter->getDeclaringFunction()->getDocComment();
     $this->additionalArguments = $this->dic->getParamsFromTypeHint($this->parameter);
     $this->mode = $mode;
     $this->analyze();
 }
开发者ID:mdio,项目名称:injektor,代码行数:13,代码来源:InjectionParameter.php

示例3: __construct

 public function __construct(\ReflectionParameter $parameter, $message = null, $code = null, \Exception $previous = null)
 {
     if (null === $message) {
         $message = sprintf('Unable to resolve argument $%s (#%d) of %s.', $parameter->name, $parameter->getPosition(), static::getFunctionName($parameter->getDeclaringFunction()));
     }
     parent::__construct($message, $code, $previous);
 }
开发者ID:rybakit,项目名称:arguments-resolver,代码行数:7,代码来源:UnresolvableArgumentException.php

示例4: getArgumentMock

 /**
  * @param \ReflectionParameter $parameter
  * @return mixed
  */
 private function getArgumentMock(\ReflectionParameter $parameter)
 {
     if ($parameter->getClass() !== null) {
         return $this->testCase->getMockBuilder($parameter->getClass()->getName())->disableOriginalConstructor()->getMock();
     }
     throw new \Mocktainer\UnmockableMethodArgumentException($parameter->getDeclaringClass()->getName(), $parameter->getDeclaringFunction()->getName(), $parameter->getName());
 }
开发者ID:paranoiq,项目名称:mocktainer,代码行数:11,代码来源:Mocktainer.php

示例5: getParameterAnnotations

 public function getParameterAnnotations(\ReflectionParameter $parameter)
 {
     $class = $parameter->getDeclaringClass() ?: 'Closure';
     $method = $parameter->getDeclaringFunction();
     if (!$method->isUserDefined()) {
         return array();
     }
     $context = 'parameter ' . ($class === 'Closure' ? $class : $class->getName()) . '::' . $method->getName() . '($' . $parameter->getName() . ')';
     if ($class === 'Closure') {
         $this->parser->setImports($this->getClosureImports($method));
     } else {
         $this->parser->setImports($this->getImports($class));
         $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
     }
     $lines = file($method->getFileName());
     $lines = array_slice($lines, $start = $method->getStartLine() - 1, $method->getEndLine() - $start);
     $methodBody = Implode($lines);
     $methodBody = str_replace("\n", null, $methodBody);
     $signature = preg_split('/\\)\\s*\\{/', $methodBody);
     $signature = $signature[0];
     $signature = substr($signature, strpos($signature, "function"));
     if (preg_match_all('/\\/\\*\\*(.*?)\\*\\/' . '.*?\\$(\\w+)/', $signature, $matches)) {
         $docComments = $matches[1];
         $names = $matches[2];
         for ($i = 0, $len = count($names); $i < $len; ++$i) {
             if ($names[$i] === $parameter->name) {
                 return $this->parser->parse($docComments[$i], $context);
             }
         }
     }
     return array();
 }
开发者ID:spotframework,项目名称:spot,代码行数:32,代码来源:ReaderImpl.php

示例6: fromReflection

 /**
  * Creates a PHP parameter from reflection
  * 
  * @param \ReflectionParameter $ref
  * @return PhpParameter
  */
 public static function fromReflection(\ReflectionParameter $ref)
 {
     $parameter = new static();
     $parameter->setName($ref->name)->setPassedByReference($ref->isPassedByReference());
     if ($ref->isDefaultValueAvailable()) {
         $parameter->setDefaultValue($ref->getDefaultValue());
     }
     // find type and description in docblock
     $docblock = new Docblock($ref->getDeclaringFunction());
     $params = $docblock->getTags('param');
     $tag = $params->find($ref->name, function (ParamTag $t, $name) {
         return $t->getVariable() == '$' . $name;
     });
     if ($tag !== null) {
         $parameter->setType($tag->getType(), $tag->getDescription());
     }
     // set type if not found in comment
     if ($parameter->getType() === null) {
         if ($ref->isArray()) {
             $parameter->setType('array');
         } elseif ($class = $ref->getClass()) {
             $parameter->setType($class->getName());
         } elseif (method_exists($ref, 'isCallable') && $ref->isCallable()) {
             $parameter->setType('callable');
         }
     }
     return $parameter;
 }
开发者ID:domagala,项目名称:php-code-generator,代码行数:34,代码来源:PhpParameter.php

示例7: getDeclaringFunction

 /**
  * Get this parameters declaring (@see Nerd\Source\Funktion) object
  *
  * @return Nerd\Source\Funktion
  */
 public function getDeclaringFunction()
 {
     $function = parent::getDeclaringFunction();
     if ($function instanceof \ReflectionMethod) {
         return new Method($this->getDeclaringClass()->getName(), $function->getName());
     }
     return new Funktion($function->getName());
 }
开发者ID:nerdsrescueme,项目名称:Core,代码行数:13,代码来源:parameter.php

示例8: getParameterAnnotations

 function getParameterAnnotations(\ReflectionParameter $parameter)
 {
     $key = "@[Annot]" . $parameter->getDeclaringClass() . "#" . $parameter->getDeclaringFunction() . "#" . $parameter->name;
     if (($annotations = $this->cache->fetch($key)) === false) {
         $annotations = $this->reader->getParameterAnnotations($parameter);
         $this->cache->save($key, $annotations);
     }
     return $annotations;
 }
开发者ID:spotframework,项目名称:spot,代码行数:9,代码来源:CachedReader.php

示例9: getParameterTypeFromDoc

 protected static function getParameterTypeFromDoc(\ReflectionParameter $parameter)
 {
     $constructor = $parameter->getDeclaringFunction();
     $docComment = $constructor->getDocComment();
     if (!preg_match('#@inject(?<target>.+)\\$' . $parameter->getName() . '#', $docComment, $match)) {
         return null;
     }
     return str_replace(' ', '', $match['target']);
 }
开发者ID:conpago,项目名称:conpago-di,代码行数:9,代码来源:Parameter.php

示例10: getDeclaringFunction

 public function getDeclaringFunction()
 {
     $phpReflection = parent::getDeclaringFunction();
     if ($phpReflection instanceof ReflectionMethod) {
         $zendReflection = new ZendL_Reflection_Method($this->getDeclaringClass()->getName(), $phpReflection->getName());
     } else {
         $zendReflection = new ZendL_Reflection_Function($phpReflection->getName());
     }
     unset($phpReflection);
     return $zendReflection;
 }
开发者ID:lortnus,项目名称:zf1,代码行数:11,代码来源:Parameter.php

示例11: getArgumentType

 private static function getArgumentType(ReflectionParameter $parameter)
 {
     $comment = $parameter->getDeclaringFunction()->getDocComment();
     if (!$comment) {
         return null;
     }
     $matches = null;
     if (!preg_match("/@param\\s+([^\\s]+)\\s+\\\${$parameter->name}/", $comment, $matches)) {
         return null;
     }
     return $matches[1];
 }
开发者ID:reginaldoandrade,项目名称:ezerphp,代码行数:12,代码来源:EzerAjaxFrontController.php

示例12: getDeclaringFunction

 /**
  * Returns the function or method declaring this parameter
  * @return ezcReflectionFunction|ezcReflectionMethod
  * @since PHP 5.2.3
  */
 public function getDeclaringFunction()
 {
     if ($this->parameter instanceof parent) {
         $func = $this->parameter->getDeclaringFunction();
     } else {
         $func = parent::getDeclaringFunction();
     }
     if ($func instanceof ReflectionMethod) {
         return new ezcReflectionMethod($func->getDeclaringClass(), $func->getName());
     } else {
         return new ezcReflectionFunction($func->getName());
     }
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:18,代码来源:parameter.php

示例13: getParameterKey

 /**
  * {@inheritdoc}
  */
 public function getParameterKey(\ReflectionParameter $parameter)
 {
     $function = $parameter->getDeclaringFunction();
     if ($function instanceof \ReflectionMethod) {
         foreach ($this->reader->getMethodAnnotations($function) as $annotation) {
             if ($annotation instanceof Inject) {
                 $value = $annotation->getValue($parameter->getName());
                 if ($value !== null) {
                     return $value;
                 }
             }
         }
     }
     return null;
 }
开发者ID:brick,项目名称:di,代码行数:18,代码来源:AnnotationPolicy.php

示例14: analyze

 /**
  * {@inheritdoc}
  * @throws ParameterDefinitionAlreadyExistsException
  * @throws ReferenceNotImplementsException
  * @throws MethodDefinitionNotFoundException
  * @throws ParameterDefinitionNotFoundException
  * @throws \InvalidArgumentException
  */
 public function analyze(DefinitionAnalyzer $analyzer, ClassDefinition $classDefinition, \ReflectionParameter $reflectionParameter)
 {
     $methodName = $reflectionParameter->getDeclaringFunction()->getName();
     $parameterName = $reflectionParameter->getName();
     // Define parameter only if method definition is available
     if ($classDefinition->hasMethod($methodName)) {
         $methodDefinition = $classDefinition->getMethod($methodName);
         // Define parameter definition if not exists
         $parameterDefinition = $methodDefinition->setupParameter($parameterName);
         $this->setReflectionMetadata($parameterDefinition, $reflectionParameter);
         $dependency = $parameterDefinition->getDependency();
         // If dependency was not set
         // UndefinedReference is the default value of dependency which was not use before
         if (!$dependency || $dependency instanceof UndefinedReference) {
             $this->setDependencyByReflection($parameterDefinition, $reflectionParameter);
         }
         $this->setOrderArguments($methodDefinition, $reflectionParameter->getDeclaringFunction());
     }
 }
开发者ID:samsonframework,项目名称:container,代码行数:27,代码来源:ReflectionParameterAnalyzer.php

示例15: denormalizeParameter

 /**
  * Denormalize a method parameter value.
  *
  * @param \ReflectionParameter $reflectionParameter
  * @param mixed $value Parameter value to denormalize
  * @return mixed
  */
 protected function denormalizeParameter(\ReflectionParameter $reflectionParameter, $value)
 {
     if ($reflectionParameter->getClass() === null && !$reflectionParameter->isArray()) {
         return $value;
     }
     if (!$this->serializer instanceof DenormalizerInterface) {
         throw new LogicException('Cannot denormalize because injected serializer is not a denormalizer');
     }
     if ($reflectionParameter->getClass() !== null) {
         return $this->serializer->denormalize($value, $reflectionParameter->getClass()->name);
     }
     if ($reflectionParameter->isArray()) {
         $className = $reflectionParameter->getDeclaringClass()->getName();
         $methodName = $reflectionParameter->getDeclaringFunction()->getName();
         $parameterName = $reflectionParameter->getName();
         return $this->serializer->denormalize($value, $className . '::' . $methodName . '(' . $parameterName . ')');
     }
     return $value;
 }
开发者ID:a-mayer,项目名称:boekkooi-broadway,代码行数:26,代码来源:AdvancedInstantiationTrait.php


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