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


PHP ReflectionFunctionAbstract::getParameters方法代码示例

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


在下文中一共展示了ReflectionFunctionAbstract::getParameters方法的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: collect

 /**
  * @inheritdoc
  */
 public function collect()
 {
     $requirements = array();
     foreach ($this->reflection->getParameters() as $parameter) {
         $requirement = $this->createRequirement($parameter);
         $resourceName = $requirement->getResourceName();
         $requirements[$resourceName] = $requirement;
     }
     return $requirements;
 }
开发者ID:piotrminkina,项目名称:resource-resolver-bundle,代码行数:13,代码来源:AbstractCallableRequirements.php

示例3: 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

示例4: __construct

 public function __construct(ReflectionFunctionAbstract $method)
 {
     $this->name = $method->getShortName();
     $this->filename = $method->getFilename();
     $this->startline = $method->getStartLine();
     $this->endline = $method->getEndLine();
     $this->docstring = $method->getDocComment();
     $this->operator = $this->static ? Kint_Object::OPERATOR_STATIC : Kint_Object::OPERATOR_OBJECT;
     $this->access = Kint_Object::ACCESS_PUBLIC;
     if ($method instanceof ReflectionMethod) {
         $this->static = $method->isStatic();
         $this->abstract = $method->isAbstract();
         $this->final = $method->isFinal();
         $this->owner_class = $method->getDeclaringClass()->name;
         if ($method->isProtected()) {
             $this->access = Kint_Object::ACCESS_PROTECTED;
         } elseif ($method->isPrivate()) {
             $this->access = Kint_Object::ACCESS_PRIVATE;
         }
     }
     foreach ($method->getParameters() as $param) {
         $this->parameters[] = new Kint_Object_Parameter($param);
     }
     if ($this->docstring) {
         if (preg_match('/@return\\s+(.*)\\r?\\n/m', $this->docstring, $matches)) {
             if (!empty($matches[1])) {
                 $this->returntype = $matches[1];
             }
         }
     }
     $docstring = new Kint_Object_Representation_Docstring($this->docstring, $this->filename, $this->startline);
     $docstring->implicit_label = true;
     $this->addRepresentation($docstring);
 }
开发者ID:jnvsor,项目名称:kint,代码行数:34,代码来源:Method.php

示例5: dumpMethodParameters

 private function dumpMethodParameters(FunctionCallDefinition $definition, \ReflectionFunctionAbstract $functionReflection)
 {
     $args = array();
     foreach ($functionReflection->getParameters() as $index => $parameter) {
         if ($definition && $definition->hasParameter($index)) {
             $value = $definition->getParameter($index);
             if ($value instanceof EntryReference) {
                 $args[] = sprintf('$%s = link(%s)', $parameter->getName(), $value->getName());
             } else {
                 $args[] = sprintf('$%s = %s', $parameter->getName(), var_export($value, true));
             }
             continue;
         }
         // If the parameter is optional and wasn't specified, we take its default value
         if ($parameter->isOptional()) {
             try {
                 $value = $parameter->getDefaultValue();
                 $args[] = sprintf('$%s = (default value) %s', $parameter->getName(), var_export($value, true));
                 continue;
             } catch (\ReflectionException $e) {
                 // The default value can't be read through Reflection because it is a PHP internal class
             }
         }
         $args[] = sprintf('$%s = #UNDEFINED#', $parameter->getName());
     }
     return implode(PHP_EOL . '    ', $args);
 }
开发者ID:jhonleandres,项目名称:batata,代码行数:27,代码来源:FunctionCallDefinitionDumper.php

示例6: 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

示例7: 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

示例8: 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

示例9: resolveParameters

 /**
  * @param MethodInjection             $definition
  * @param \ReflectionFunctionAbstract $functionReflection
  * @param array                       $parameters
  *
  * @throws DefinitionException A parameter has no value defined or guessable.
  * @return array Parameters to use to call the function.
  */
 public function resolveParameters(MethodInjection $definition = null, \ReflectionFunctionAbstract $functionReflection = null, array $parameters = [])
 {
     $args = [];
     if (!$functionReflection) {
         return $args;
     }
     $definitionParameters = $definition ? $definition->getParameters() : array();
     foreach ($functionReflection->getParameters() as $index => $parameter) {
         if (array_key_exists($parameter->getName(), $parameters)) {
             // Look in the $parameters array
             $value =& $parameters[$parameter->getName()];
         } elseif (array_key_exists($index, $definitionParameters)) {
             // Look in the definition
             $value =& $definitionParameters[$index];
         } else {
             // If the parameter is optional and wasn't specified, we take its default value
             if ($parameter->isOptional()) {
                 $args[] = $this->getParameterDefaultValue($parameter, $functionReflection);
                 continue;
             }
             throw new DefinitionException(sprintf("The parameter '%s' of %s has no value defined or guessable", $parameter->getName(), $this->getFunctionName($functionReflection)));
         }
         if ($value instanceof DefinitionHelper) {
             $nestedDefinition = $value->getDefinition('');
             // If the container cannot produce the entry, we can use the default parameter value
             if ($parameter->isOptional() && !$this->definitionResolver->isResolvable($nestedDefinition)) {
                 $value = $this->getParameterDefaultValue($parameter, $functionReflection);
             } else {
                 $value = $this->definitionResolver->resolve($nestedDefinition);
             }
         }
         $args[] =& $value;
     }
     return $args;
 }
开发者ID:jdreesen,项目名称:PHP-DI,代码行数:43,代码来源:ParameterResolver.php

示例10: resolveParameters

 /**
  * @param AbstractFunctionCallDefinition $definition
  * @param \ReflectionFunctionAbstract    $functionReflection
  * @param array                          $parameters
  *
  * @throws DefinitionException A parameter has no value defined or guessable.
  * @return array Parameters to use to call the function.
  */
 public function resolveParameters(AbstractFunctionCallDefinition $definition = null, \ReflectionFunctionAbstract $functionReflection = null, array $parameters = array())
 {
     $args = array();
     if (!$functionReflection) {
         return $args;
     }
     foreach ($functionReflection->getParameters() as $index => $parameter) {
         if (array_key_exists($parameter->getName(), $parameters)) {
             // Look in the $parameters array
             $value = $parameters[$parameter->getName()];
         } elseif ($definition && $definition->hasParameter($index)) {
             // Look in the definition
             $value = $definition->getParameter($index);
         } else {
             // If the parameter is optional and wasn't specified, we take its default value
             if ($parameter->isOptional()) {
                 $args[] = $this->getParameterDefaultValue($parameter, $functionReflection);
                 continue;
             }
             throw new DefinitionException(sprintf("The parameter '%s' of %s has no value defined or guessable", $parameter->getName(), $this->getFunctionName($functionReflection)));
         }
         if ($value instanceof EntryReference) {
             // If the container cannot produce the entry, we can use the default parameter value
             if (!$this->container->has($value->getName()) && $parameter->isOptional()) {
                 $value = $this->getParameterDefaultValue($parameter, $functionReflection);
             } else {
                 $value = $this->container->get($value->getName());
             }
         }
         $args[] = $value;
     }
     return $args;
 }
开发者ID:Clon450,项目名称:batata,代码行数:41,代码来源:ParameterResolver.php

示例11: 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

示例12: 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

示例13: __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

示例14: loadArguments

 /**
  * Populates arguments assembled from the event and the given target function.
  * 
  * @param \ReflectionFunctionAbstract $ref
  * @param EventParamResolverInterface $resolver
  * @return array
  */
 protected function loadArguments(\ReflectionFunctionAbstract $ref, EventParamResolverInterface $resolver)
 {
     $args = [];
     if ($ref->getNumberOfParameters() > 1) {
         foreach (array_slice($ref->getParameters(), 1) as $param) {
             $args[] = $resolver->resolve($param->getClass(), $param->isDefaultValueAvailable() ? $param->getDefaultValue() : false);
         }
     }
     return $args;
 }
开发者ID:koolkode,项目名称:event,代码行数:17,代码来源:AbstractListener.php

示例15: injectPaginatedRequest

 /**
  * @param \ReflectionFunctionAbstract $r
  * @param Request                     $request
  *
  * @return void
  */
 private function injectPaginatedRequest(\ReflectionFunctionAbstract $r, Request $request)
 {
     $paginatedRequest = new PaginatedRequest($request, $this->pagePath, $this->pageDefaultValue, $this->maxResultsPath, $this->maxResultsDefaultValue);
     foreach ($r->getParameters() as $param) {
         if (!$param->getClass() || !$param->getClass()->isInstance($paginatedRequest)) {
             continue;
         }
         $request->attributes->set($param->getName(), $paginatedRequest);
     }
 }
开发者ID:kieranbamforth,项目名称:paginator-bundle,代码行数:16,代码来源:PaginatedRequestListener.php


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