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


PHP ReflectionFunctionAbstract类代码示例

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


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

示例1: __construct

 public function __construct(\ReflectionFunctionAbstract $Reflection, callable $SourceLoader)
 {
     $this->Reflection = $Reflection;
     $this->Parameters = $this->Reflection->getParameters();
     $this->UsedVariablesMap = $this->Reflection->getStaticVariables();
     $this->SourceLoader = $SourceLoader;
 }
开发者ID:timetoogo,项目名称:penumbra,代码行数:7,代码来源:DataBase.php

示例2: getCallArgs

 /**
  * Python-style args/kwargs argument arrays. Creates an indexed
  * argument list to use with reflection::
  * 
  *     class Pants {
  *         function doPants($arg1, $arg2, $arg3=null, $foo=>null) {
  *         }
  *     }
  *     
  * 	   $args = ['arg1', 'arg2', 'foo'=>'bar'];
  *     $rm = (new ReflectionClass('Pants'))->getMethod('doPants');
  *     $return = $rm->invokeArgs(func_get_call_args($rm), $args);
  */
 public static function getCallArgs(\ReflectionFunctionAbstract $rm, $args, $ignoreUnknown = false)
 {
     if (!$args) {
         $args = [];
     }
     $callArgs = [];
     $inArgs = true;
     foreach ($rm->getParameters() as $idx => $param) {
         $paramFound = false;
         if ($inArgs && ($inArgs = isset($args[$idx]))) {
             $callArgs[] = $args[$idx];
             $paramFound = true;
             unset($args[$idx]);
         } else {
             if (array_key_exists($param->name, $args)) {
                 $paramFound = true;
                 $callArgs[] = $args[$param->name];
                 unset($args[$param->name]);
             }
         }
         if (!$paramFound) {
             if ($param->isDefaultValueAvailable()) {
                 $callArgs[] = $param->getDefaultValue();
             } else {
                 throw new \UnexpectedValueException("No value for argument {$param->name} for function {$rm->getName()}");
             }
         }
     }
     if ($args && !$ignoreUnknown) {
         throw new \UnexpectedValueException("Unknown keyword arguments: " . implode(", ", array_keys($args)));
     }
     return $callArgs;
 }
开发者ID:shabbyrobe,项目名称:defile,代码行数:46,代码来源:CallHelper.php

示例3: determineRequestObjectClass

 /**
  * @param \ReflectionFunctionAbstract $reflectionFunction
  *
  * @return string
  */
 private function determineRequestObjectClass(\ReflectionFunctionAbstract $reflectionFunction)
 {
     $reflectionParameters = $reflectionFunction->getParameters();
     /** @var \ReflectionParameter $reflectionParameter */
     $reflectionParameter = reset($reflectionParameters);
     return $reflectionParameter->getClass()->name;
 }
开发者ID:tonicforhealth,项目名称:json-rpc,代码行数:12,代码来源:MetadataExtractor.php

示例4: getParameters

 protected function getParameters(\ReflectionFunctionAbstract $ref = null, array $userParams = [])
 {
     $parameters = [];
     $expectedParameters = $ref->getParameters();
     foreach ($expectedParameters as $parameter) {
         $name = $parameter->getName();
         $class = $parameter->getClass();
         if ($parameter->isVariadic()) {
             return array_merge($parameters, array_values($userParams));
         }
         if (isset($userParams[$name])) {
             $parameters[] = $userParams[$name];
             unset($userParams[$name]);
         } elseif ($parameter->isDefaultValueAvailable()) {
             $parameters[] = $parameter->getDefaultValue();
         } elseif ($this->has($name)) {
             $parameters[] = $this->get($name);
         } elseif ($class) {
             $parameters[] = $this->get($class->name);
         } else {
             throw new InjectorException("Unable to resolve parameter '{$name}'");
         }
     }
     return $parameters;
 }
开发者ID:ttyz,项目名称:injector,代码行数:25,代码来源:Injector.php

示例5: getInjections

 /**
  * Get the list of injectable arguments for a function or method.
  *
  * The returned array can be used with `call_user_func_array()` or
  * `invokeArgs()`.
  *
  * @param \ReflectionFunctionAbstract $method
  * @return array List of arguments
  * @throws \RuntimeException When an argument cannot be found
  */
 public function getInjections(\ReflectionFunctionAbstract $method)
 {
     $injections = [];
     $parameters = $method->getParameters();
     foreach ($parameters as $param) {
         $found = false;
         $injection = null;
         try {
             $injection = $this->findKey($param->getName());
             $found = true;
         } catch (\RuntimeException $e) {
         }
         if ($paramType = $param->getType()) {
             try {
                 $injection = $this->findKey($paramType);
                 $found = true;
             } catch (\RuntimeException $e) {
             }
         }
         if (!$found && $param->isDefaultValueAvailable()) {
             $injection = $param->getDefaultValue();
             $found = true;
         }
         if (!$found) {
             $paramName = $param->getName() . ' (' . $param->getType() . ')';
             throw new \RuntimeException("Could not find a definition for {$paramName}.");
         }
         $injections[] = $injection;
     }
     return $injections;
 }
开发者ID:ifcanduela,项目名称:pew,代码行数:41,代码来源:Injector.php

示例6: getClassName

 /**
  * Helper class for getFunctionName().
  *
  * @param \ReflectionFunctionAbstract $function
  * @return string
  */
 private static function getClassName(\ReflectionFunctionAbstract $function)
 {
     if ($function instanceof \ReflectionMethod) {
         return $function->getDeclaringClass()->getName() . '::';
     }
     return '';
 }
开发者ID:brick,项目名称:di,代码行数:13,代码来源:UnresolvedValueException.php

示例7: getReflectionFunctionName

 /**
  * Helper method to retrieve the name of a ReflectionFunctionAbstract
  * @param \ReflectionFunctionAbstract $reflection
  * @return string
  */
 protected function getReflectionFunctionName(\ReflectionFunctionAbstract $reflection)
 {
     // Class method
     if ($reflection instanceof \ReflectionMethod) {
         return $reflection->getDeclaringClass()->getName() . '::' . $reflection->getName();
     }
     return $reflection->getName();
 }
开发者ID:frogsystem,项目名称:spawn,代码行数:13,代码来源:ParameterResolutionException.php

示例8: getParameter

 private function getParameter(\ReflectionFunctionAbstract $reflectionFunction, $name)
 {
     foreach ($reflectionFunction->getParameters() as $parameter) {
         if ($parameter->getName() === $name) {
             return $parameter;
         }
     }
 }
开发者ID:yavin,项目名称:behat-context-injection-extension,代码行数:8,代码来源:ContextArgumentTransformer.php

示例9: fetchFunctionIdentifier

 private function fetchFunctionIdentifier(\ReflectionFunctionAbstract $function)
 {
     $functionIdentifier = $function->getName();
     if ($function instanceof \ReflectionMethod) {
         $functionIdentifier = sprintf('%s::%s', $function->getDeclaringClass()->getName(), $function->getName());
     }
     return $functionIdentifier;
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:8,代码来源:InvalidCollaboratorTypeException.php

示例10: getFunctionName

 /**
  * @param \ReflectionFunctionAbstract $reflection
  *
  * @return string
  */
 protected static function getFunctionName(\ReflectionFunctionAbstract $reflection)
 {
     $name = $reflection->name . '()';
     if ($reflection instanceof \ReflectionMethod) {
         $name = $reflection->getDeclaringClass()->name . '::' . $name;
     }
     return $name;
 }
开发者ID:rybakit,项目名称:arguments-resolver,代码行数:13,代码来源:UnresolvableArgumentException.php

示例11: __construct

 /**
  * @param string                      $type
  * @param mixed                       $value
  * @param integer                     $position
  * @param \ReflectionFunctionAbstract $func
  */
 public function __construct($type, $value, $position, \ReflectionFunctionAbstract $func)
 {
     $this->type = $type;
     $this->value = $value;
     $this->position = $position;
     $this->func = $func;
     $params = $func->getParameters();
     $this->reflection = isset($params[$position]) ? $params[$position] : null;
 }
开发者ID:villfa,项目名称:checktypes,代码行数:15,代码来源:Parameter.php

示例12: fetchCode

 /**
  * @param \ReflectionFunctionAbstract $reflection
  *
  * @return string
  */
 protected function fetchCode(\ReflectionFunctionAbstract $reflection)
 {
     $file = $reflection->getFileName();
     if (!file_exists($file)) {
         return '';
     }
     $startLine = $reflection->getStartLine();
     return implode('', array_slice(file($file), $startLine, $reflection->getEndLine() - $startLine - 1));
 }
开发者ID:oncesk,项目名称:runkit,代码行数:14,代码来源:Code.php

示例13: generateForParameter

 /**
  * Generate key for parameter
  *
  * @param \ReflectionParameter        $parameter
  * @param \ReflectionFunctionAbstract $method
  *
  * @return string
  */
 public static function generateForParameter(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $method)
 {
     if ($method instanceof \ReflectionMethod) {
         $key = $method->getDeclaringClass()->getName() . '::' . $method->getName() . ':' . $parameter->getName();
     } else {
         $key = 'function::' . $method->getName() . ':' . $parameter->getName();
     }
     return $key;
 }
开发者ID:Gtvar,项目名称:FivePercent-Converter,代码行数:17,代码来源:KeyGenerator.php

示例14: setOrderArguments

 /**
  * Set correct order of arguments
  *
  * @param MethodDefinition $methodDefinition
  * @param \ReflectionFunctionAbstract $reflectionMethod
  * @throws \InvalidArgumentException
  */
 public function setOrderArguments(MethodDefinition $methodDefinition, \ReflectionFunctionAbstract $reflectionMethod)
 {
     $parameters = [];
     // Get parameter names
     foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
         $parameters[] = $reflectionParameter->getName();
     }
     $methodDefinition->setParametersCollectionOrder($parameters);
 }
开发者ID:samsonframework,项目名称:container,代码行数:16,代码来源:ReflectionParameterAnalyzer.php

示例15: getAttributeName

 /**
  * Get the attribute name for ParamFetcher injection
  *
  * @param \ReflectionFunctionAbstract $controllerReflector
  *
  * @return null|string
  */
 private function getAttributeName(\ReflectionFunctionAbstract $controllerReflector)
 {
     foreach ($controllerReflector->getParameters() as $parameter) {
         $hintedClass = $parameter->getClass();
         if ($hintedClass !== null && $hintedClass->implementsInterface(ParamFetcherInterface::class)) {
             return $parameter->getName();
         }
     }
     return null;
 }
开发者ID:alekitto,项目名称:param-fetcher-bundle,代码行数:17,代码来源:ControllerListener.php


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