• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ReflectionFunctionAbstract类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


示例17: getFunctionBody

 /**
  *
  * @param \ReflectionFunctionAbstract $function        	
  */
 public static function getFunctionBody(\ReflectionFunctionAbstract $function)
 {
     $source = file($function->getFileName());
     $start = $function->getStartLine() - 1;
     $end = $function->getEndLine();
     $body = implode('', array_slice($source, $start, $end - $start));
     $open = strpos($body, '{');
     $close = strrpos($body, '}');
     return trim(substr($body, $open + 1, (strlen($body) - $close) * -1));
 }
开发者ID:jmcclell,项目名称:php-code-generator,代码行数:14,代码来源:ReflectionUtils.php


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


示例19: __construct

 /**
  * @param \ReflectionParameter        $parameter
  * @param \ReflectionFunctionAbstract $context
  */
 public function __construct(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $context)
 {
     $this->parameter = $parameter;
     $this->context = $context;
     $name = $context->getName();
     if ($context instanceof \ReflectionMethod) {
         $name = $context->class . '::' . $name;
     }
     parent::__construct("Unable to resolve '{$parameter->name}' argument in '{$name}'.");
 }
开发者ID:jwdeitch,项目名称:components,代码行数:14,代码来源:ArgumentException.php


示例20: getReturnType

 /**
  * @return string|NULL
  */
 public static function getReturnType(\ReflectionFunctionAbstract $func)
 {
     if (PHP_VERSION_ID >= 70000 && $func->hasReturnType()) {
         return (string) $func->getReturnType();
     }
     $type = preg_replace('#[|\\s].*#', '', (string) self::parseAnnotation($func, 'return'));
     if ($type) {
         return $func instanceof \ReflectionMethod ? self::expandClassName($type, $func->getDeclaringClass()) : ltrim($type, '\\');
     }
 }
开发者ID:Northys,项目名称:di,代码行数:13,代码来源:PhpReflection.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ReflectionMethod类代码示例发布时间:2022-05-23
下一篇:
PHP ReflectionFunction类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap