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


PHP ReflectionFunction::getParameters方法代码示例

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


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

示例1: execute

 /**
  * (non-PHPdoc)
  * @see \PHPFluent\EventManager\Listener::execute()
  */
 public function execute(Event $event, array $context = array())
 {
     $arguments = array($event, $context);
     $parameters = $this->reflection->getParameters();
     $firstParameter = array_shift($parameters);
     if ($firstParameter instanceof \ReflectionParameter && $firstParameter->isArray()) {
         $arguments = array_reverse($arguments);
     }
     return $this->reflection->invokeArgs($arguments);
 }
开发者ID:phpfluent,项目名称:eventmanager,代码行数:14,代码来源:Callback.php

示例2: getParameterList

 /**
  * @return IParameterReflection[]
  */
 public function getParameterList()
 {
     if ($this->parameterList === null) {
         $this->parameterList = [];
         foreach ($this->reflectionFunction->getParameters() as $reflectionParameter) {
             $this->parameterList[$reflectionParameter->getName()] = new ParameterReflection($reflectionParameter);
         }
     }
     return $this->parameterList;
 }
开发者ID:edde-framework,项目名称:edde,代码行数:13,代码来源:FunctionReflection.php

示例3: main

 function main()
 {
     $rc = new ReflectionClass("Foo\\Bar\\A");
     var_dump($rc->isInterface());
     var_dump($rc->getMethod('set')->getParameters()[0]->getDefaultValue());
     var_dump($rc->getMethod('set')->getParameters()[0]->getDefaultValueConstantName());
     $rc = new \ReflectionFunction("Foo\\Bar\\foo");
     var_dump($rc->getParameters()[0]->getDefaultValue());
     var_dump($rc->getParameters()[0]->getDefaultValueConstantName());
     Foo\Bar\foo();
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:default_value_with_self.php

示例4: collectDependencies

 /**
  * @return DependencyContainer
  */
 private function collectDependencies()
 {
     $dependencies = new DependencyContainer();
     if (!$this->invokableReflection) {
         return $dependencies;
     }
     foreach ($this->invokableReflection->getParameters() as $parameter) {
         $dependencies->addDependency($parameter);
     }
     return $dependencies;
 }
开发者ID:filecage,项目名称:creator,代码行数:14,代码来源:Invokable.php

示例5: getParameters

 /**
  * @return \PHPStan\Reflection\ParameterReflection[]
  */
 public function getParameters() : array
 {
     if ($this->parameters === null) {
         $this->parameters = array_map(function (\ReflectionParameter $reflection) {
             return new PhpParameterReflection($reflection);
         }, $this->reflection->getParameters());
         if ($this->reflection->getName() === 'array_unique' && count($this->parameters) === 1) {
             // PHP bug #70960
             $this->parameters[] = new DummyOptionalParameter('sort_flags', new IntegerType(false));
         }
     }
     return $this->parameters;
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:16,代码来源:FunctionReflection.php

示例6: send

 public function send(StreamInterface $stream)
 {
     if (!$stream->isWritable()) {
         throw new \InvalidArgumentException('Output stream must be writable');
     }
     if (is_array($this->callback)) {
         $ref = (new \ReflectionClass(is_object($this->callback[0]) ? get_class($this->callback[0]) : $this->callback[0]))->getMethod($this->callback[1]);
     } elseif (is_object($this->callback) && !$this->callback instanceof \Closure) {
         $ref = new \ReflectionMethod(get_class($this->callback), '__invoke');
     } else {
         $ref = new \ReflectionFunction($this->callback);
     }
     if ($ref->isGenerator()) {
         foreach (call_user_func($this->callback) as $chunk) {
             $stream->write($chunk);
         }
         return;
     }
     foreach ($ref->getParameters() as $param) {
         if (NULL !== ($type = $param->getClass())) {
             if ($type->name === StreamInterface::class || $type->implementsInterface(StreamInterface::class)) {
                 call_user_func($this->callback, $stream);
                 return;
             }
         }
         break;
     }
     $stream->write((string) call_user_func($this->callback));
 }
开发者ID:koolkode,项目名称:http,代码行数:29,代码来源:CallbackEntity.php

示例7: test

function test()
{
    $x = new ReflectionFunction('array_filter');
    $params = $x->getParameters();
    $p1 = $params[1];
    var_dump($p1->getDefaultValueText());
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:hhas_defaults.php

示例8: onKernelController

 /**
  * Modifies the ParamConverterManager instance.
  *
  * @param FilterControllerEvent $event A FilterControllerEvent instance
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     $request = $event->getRequest();
     $configurations = array();
     if ($configuration = $request->attributes->get('_converters')) {
         foreach (is_array($configuration) ? $configuration : array($configuration) as $configuration) {
             $configurations[$configuration->getName()] = $configuration;
         }
     }
     if (is_array($controller)) {
         $r = new \ReflectionMethod($controller[0], $controller[1]);
     } else {
         $r = new \ReflectionFunction($controller);
     }
     // automatically apply conversion for non-configured objects
     foreach ($r->getParameters() as $param) {
         if (!$param->getClass() || $param->getClass()->isInstance($request)) {
             continue;
         }
         $name = $param->getName();
         if (!isset($configurations[$name])) {
             $configuration = new ParamConverter(array());
             $configuration->setName($name);
             $configuration->setClass($param->getClass()->getName());
             $configurations[$name] = $configuration;
         } elseif (null === $configurations[$name]->getClass()) {
             $configurations[$name]->setClass($param->getClass()->getName());
         }
         $configurations[$name]->setIsOptional($param->isOptional());
     }
     $this->manager->apply($request, $configurations);
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:38,代码来源:ParamConverterListener.php

示例9: ReflectionFunction

 /**
  * get Closure info
  * @param Closure $c
  * @return array
  */
 function closure_dump(Closure $c)
 {
     $str = 'function (';
     $r = new ReflectionFunction($c);
     $params = array();
     foreach ($r->getParameters() as $p) {
         $s = '';
         if ($p->isArray()) {
             $s .= 'array ';
         } else {
             if ($p->getClass()) {
                 $s .= $p->getClass()->name . ' ';
             }
         }
         if ($p->isPassedByReference()) {
             $s .= '&';
         }
         $s .= '$' . $p->name;
         if ($p->isOptional()) {
             $s .= ' = ' . var_export($p->getDefaultValue(), TRUE);
         }
         $params[] = $s;
     }
     $str .= implode(', ', $params);
     $str .= '){' . PHP_EOL;
     $lines = file($r->getFileName());
     for ($l = $r->getStartLine(); $l < $r->getEndLine(); $l++) {
         $str .= $lines[$l];
     }
     $arr = ['file' => $r->getFileName(), 'line' => $r->getStartLine() . '-' . $r->getEndLine(), 'source' => $str];
     return $arr;
 }
开发者ID:Vr80s,项目名称:laravel-rbac,代码行数:37,代码来源:helpers.php

示例10: getParameters

 /**
  * @return Parameter[]
  */
 public function getParameters()
 {
     foreach ($res = parent::getParameters() as $key => $val) {
         $res[$key] = new Parameter($this->value, $val->getName());
     }
     return $res;
 }
开发者ID:nette,项目名称:reflection,代码行数:10,代码来源:GlobalFunction.php

示例11: castClosure

 static function castClosure($c)
 {
     $a = array();
     if (!class_exists('ReflectionFunction', false)) {
         return $a;
     }
     $c = new \ReflectionFunction($c);
     foreach ($c->getParameters() as $p) {
         $n = ($p->isPassedByReference() ? '&$' : '$') . $p->getName();
         if ($p->isDefaultValueAvailable()) {
             $a[$n] = $p->getDefaultValue();
         } else {
             $a[] = $n;
         }
     }
     $m = self::META_PREFIX;
     $a = array($m . 'returnsRef' => true, $m . 'args' => $a);
     if (!$c->returnsReference()) {
         unset($a[$m . 'returnsRef']);
     }
     $a[$m . 'use'] = array();
     if (false === ($a[$m . 'file'] = $c->getFileName())) {
         unset($a[$m . 'file']);
     } else {
         $a[$m . 'lines'] = $c->getStartLine() . '-' . $c->getEndLine();
     }
     if (!($c = $c->getStaticVariables())) {
         unset($a[$m . 'use']);
     } else {
         foreach ($c as $p => &$c) {
             $a[$m . 'use']['$' . $p] =& $c;
         }
     }
     return $a;
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:35,代码来源:Caster.php

示例12: runMiddlewares

 /**
  * Runs all the middlewares of given type.
  */
 public static function runMiddlewares($type = self::BEFORE_REQUEST)
 {
     $apricot = static::getInstance();
     $middlewares = $apricot->middlewares;
     /** @var \Exception */
     $error = null;
     foreach ($middlewares as $key => $middleware) {
         $hasNextMiddleware = array_key_exists($key + 1, $middlewares);
         if ($type !== $middleware['type']) {
             continue;
         }
         $r = new \ReflectionFunction($middleware['callback']);
         $parameters = $r->getParameters();
         $next = $hasNextMiddleware ? $middlewares[$key + 1] : function () {
         };
         try {
             $r->invokeArgs(array($error, $next));
         } catch (\Exception $e) {
             // If there is no more middleware to run, throw the exception.
             if (!$hasNextMiddleware) {
                 throw $e;
             }
             $error = $e;
         }
     }
 }
开发者ID:djom20,项目名称:Apricot,代码行数:29,代码来源:Middleware.php

示例13: getNamedArgs

 public static function getNamedArgs()
 {
     $bt = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
     $frame = $bt[1];
     if ($frame['function'] == '{closure}') {
         throw new \LogicException("This can't work inside a closure, sadly");
     }
     if (isset($frame['class'])) {
         $rc = new \ReflectionClass($frame['class']);
         $rf = $rc->getMethod($frame['function']);
     } else {
         $rf = new \ReflectionFunction($frame['function']);
     }
     $named = [];
     $args = $frame['args'];
     foreach ($rf->getParameters() as $idx => $param) {
         $name = $param->getName();
         if (!array_key_exists($idx, $args)) {
             if ($param->isDefaultValueAvailable()) {
                 $named[$name] = $param->getDefaultValue();
             } else {
                 break;
             }
         } else {
             $named[$name] = $args[$idx];
         }
     }
     return $named;
 }
开发者ID:shabbyrobe,项目名称:defile,代码行数:29,代码来源:CallHelper.php

示例14: shouldRun

 private function shouldRun($callback, $controllerResult)
 {
     if (is_array($callback)) {
         $callbackReflection = new \ReflectionMethod($callback[0], $callback[1]);
     } elseif (is_object($callback) && !$callback instanceof \Closure) {
         $callbackReflection = new \ReflectionObject($callback);
         $callbackReflection = $callbackReflection->getMethod('__invoke');
     } else {
         $callbackReflection = new \ReflectionFunction($callback);
     }
     if ($callbackReflection->getNumberOfParameters() > 0) {
         $parameters = $callbackReflection->getParameters();
         $expectedControllerResult = $parameters[0];
         if ($expectedControllerResult->getClass() && (!is_object($controllerResult) || !$expectedControllerResult->getClass()->isInstance($controllerResult))) {
             return false;
         }
         if ($expectedControllerResult->isArray() && !is_array($controllerResult)) {
             return false;
         }
         if (method_exists($expectedControllerResult, 'isCallable') && $expectedControllerResult->isCallable() && !is_callable($controllerResult)) {
             return false;
         }
     }
     return true;
 }
开发者ID:shomimn,项目名称:builder,代码行数:25,代码来源:ViewListenerWrapper.php

示例15: call_closure

 /**
  * Call closure.
  *
  * @param mixed $closure
  * @param array $parameters
  *
  * @return Closure
  */
 protected function call_closure($closure, array $parameters = [])
 {
     if ($closure instanceof Closure) {
         $rc = new ReflectionFunction($closure);
         $args = $rc->getParameters();
         $params = $parameters;
         $classes = [$this->get_class_prefix(get_class($this)), get_class($this), get_parent_class($this)];
         foreach ($args as $index => $arg) {
             if ($arg->getClass() === null) {
                 continue;
             }
             if (in_array($arg->getClass()->name, $classes)) {
                 $parameters[$index] = $this;
             } else {
                 if ($this->exists($arg->getClass()->name)) {
                     $parameters[$index] = $this->make($arg->getClass()->name);
                 }
             }
         }
         if (!empty($args) && empty($parameters)) {
             $parameters[0] = $this;
         }
         if (count($args) > count($parameters)) {
             $parameters = array_merge($parameters, $params);
         }
         return $this->call_closure(call_user_func_array($closure, $parameters), $parameters);
     }
     return $closure;
 }
开发者ID:ekandreas,项目名称:papi,代码行数:37,代码来源:class-papi-container.php


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