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


PHP ReflectionFunctionAbstract::getNumberOfParameters方法代码示例

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


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

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

示例2: resolve

 /**
  * Resolves function arguments.
  *
  * @param array $parameters
  *
  * @return array
  *
  * @throws UnresolvableArgumentException
  */
 public function resolve(array $parameters)
 {
     if (!($number = $this->reflection->getNumberOfParameters())) {
         return [];
     }
     $arguments = array_fill(0, $number, null);
     foreach ($this->getParameters() as $pos => $parameter) {
         $result = $this->match($parameter, $parameters);
         if ($result) {
             $arguments[$pos] = $result[1];
             unset($parameters[$result[0]]);
             continue;
         }
         if ($parameter->isDefaultValueAvailable()) {
             $arguments[$pos] = $parameter->getDefaultValue();
             continue;
         }
         throw new UnresolvableArgumentException($parameter);
     }
     return $arguments;
 }
开发者ID:rybakit,项目名称:arguments-resolver,代码行数:30,代码来源:ArgumentsResolver.php

示例3: normalizeParams

 /**
  *  normalize the params of the $rmethod to allow a valid call
  *
  *  @example
  *    // method signature: foo($bar = '',$baz = '',SomeClass $che);
  *    $rmethod = new ReflectionMethod($instance,'foo');
  *    $this->normalizeParams($rmethod,array('che','cha')) // retuns array('che','cha',automatically created SomeClass Instance)
  *    $this->normalizeParams($rmethod,array('che')) // retuns array('che','',automatically created SomeClass Instance)
  *    $this->normalizeParams($rmethod,array('che' => new SomeClass(),'bar' => '')) // retuns array('','',passed in SomeClass Instance)       
  *        
  *  @param  ReflectionFunctionAbstract  $rfunc  the reflection of the method/function
  *  @param  array $params any params you want to pass to override any magically
  *                        discovered params
  *  @return array the params ready to be passed to the method using something like call_user_func_array
  */
 public function normalizeParams(\ReflectionFunctionAbstract $rfunc, array $params = array())
 {
     // canary...
     if ($rfunc->getNumberOfParameters() <= 0) {
         return $params;
     }
     //if
     $ret_params = array();
     $rparams = $rfunc->getParameters();
     foreach ($rparams as $rparam) {
         $ret_params[] = $this->normalizeParam($rparam, $params);
     }
     //foreach
     return $ret_params;
 }
开发者ID:Jaymon,项目名称:Montage,代码行数:30,代码来源:Container.php

示例4: makeFunctionSignature

 /**
  * Create a string representation of the method signature.
  *
  * @param ReflectionFunctionAbstract $func The function you want a signature for.
  * @return void
  **/
 public static function makeFunctionSignature(ReflectionFunctionAbstract $func)
 {
     $signature = $func->getName() . '( ';
     foreach ($func->getParameters() as $param) {
         $signature .= '$' . $param->getName();
         if ($param->isDefaultValueAvailable()) {
             $signature .= ' = ' . var_export($param->getDefaultValue(), true);
         }
         $signature .= ', ';
     }
     if ($func->getNumberOfParameters() > 0) {
         $signature = substr($signature, 0, -2);
     }
     $signature .= ' )';
     return $signature;
 }
开发者ID:rchavik,项目名称:infinitas,代码行数:22,代码来源:docblock_tools.php

示例5: hashParameters

 private static function hashParameters(\ReflectionFunctionAbstract $method)
 {
     $res = [];
     if (PHP_VERSION_ID < 70000 && $method->getNumberOfParameters() && $method->getFileName()) {
         $res[] = file($method->getFileName())[$method->getStartLine() - 1];
     }
     foreach ($method->getParameters() as $param) {
         $res[] = [$param->getName(), PHP_VERSION_ID >= 70000 ? PhpReflection::getParameterType($param) : NULL, $param->isVariadic(), $param->isDefaultValueAvailable() ? $param->isDefaultValueConstant() ? $param->getDefaultValueConstantName() : [$param->getDefaultValue()] : NULL];
     }
     return $res;
 }
开发者ID:nette,项目名称:di,代码行数:11,代码来源:DependencyChecker.php

示例6: matchesNumberOfArguments

 /**
  * @param \ReflectionFunctionAbstract $func
  * @param integer                     $num
  * @return boolean
  */
 public static function matchesNumberOfArguments(\ReflectionFunctionAbstract $func, $num)
 {
     return $func->getNumberOfRequiredParameters() <= $num && $func->getNumberOfParameters() >= $num;
 }
开发者ID:xxoxx,项目名称:php-waf,代码行数:9,代码来源:ReflectionUtils.php


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