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


PHP ReflectionFunctionAbstract::getDeclaringClass方法代码示例

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


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

示例1: isResourceType

 /**
  * Check if the target action is declared the given type or sub type (checking for
  * interfaces is also supported).
  * 
  * @param string $typeName
  * @return boolean
  */
 public function isResourceType($typeName)
 {
     if ($typeName instanceof \ReflectionClass) {
         $typeName = $typeName->name;
     }
     if (!$this->target instanceof \ReflectionMethod) {
         return false;
     }
     if (class_exists($typeName)) {
         $lookup = strtolower($typeName);
         $ref = $this->target->getDeclaringClass();
         if (strtolower($ref->name) == $lookup) {
             return true;
         }
         $next = $ref;
         while ($next = $next->getParentClass()) {
             if (strtolower($next->name) == $lookup) {
                 return true;
             }
         }
         return false;
     }
     if (interface_exists($typeName, false)) {
         return $this->target->getDeclaringClass()->implementsInterface($typeName);
     }
     return false;
 }
开发者ID:koolkode,项目名称:http-komponent,代码行数:34,代码来源:ActionFilterChain.php

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

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

示例4: getDeclaringClass

 /**
  * {@inheritDoc}
  */
 public function getDeclaringClass()
 {
     if ($this->declaringFunction instanceof \ReflectionMethod) {
         return $this->declaringFunction->getDeclaringClass();
     }
     return null;
 }
开发者ID:console-helpers,项目名称:parser-reflection,代码行数:10,代码来源:ReflectionParameter.php

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

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

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

示例9: getFunctionName

 private function getFunctionName(\ReflectionFunctionAbstract $reflectionFunction)
 {
     if ($reflectionFunction->isClosure()) {
         return sprintf('closure defined in %s at line %d', $reflectionFunction->getFileName(), $reflectionFunction->getStartLine());
     } elseif ($reflectionFunction instanceof \ReflectionMethod) {
         return sprintf('%s::%s', $reflectionFunction->getDeclaringClass()->getName(), $reflectionFunction->getName());
     }
     return $reflectionFunction->getName();
 }
开发者ID:jhonleandres,项目名称:batata,代码行数:9,代码来源:FunctionCallDefinitionDumper.php

示例10: autowireArguments

 /**
  * Generates list of arguments using autowiring.
  * @return array
  */
 public static function autowireArguments(\ReflectionFunctionAbstract $method, array $arguments, $container)
 {
     $optCount = 0;
     $num = -1;
     $res = array();
     $methodName = ($method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' : '') . $method->getName() . '()';
     foreach ($method->getParameters() as $num => $parameter) {
         if (array_key_exists($num, $arguments)) {
             $res[$num] = $arguments[$num];
             unset($arguments[$num]);
             $optCount = 0;
         } elseif (array_key_exists($parameter->getName(), $arguments)) {
             $res[$num] = $arguments[$parameter->getName()];
             unset($arguments[$parameter->getName()]);
             $optCount = 0;
         } elseif (($class = PhpReflection::getParameterType($parameter)) && !PhpReflection::isBuiltinType($class)) {
             $res[$num] = $container->getByType($class, FALSE);
             if ($res[$num] === NULL) {
                 if ($parameter->allowsNull()) {
                     $optCount++;
                 } elseif (class_exists($class) || interface_exists($class)) {
                     $rc = new \ReflectionClass($class);
                     if ($class !== ($hint = $rc->getName())) {
                         throw new ServiceCreationException("Service of type {$class} needed by {$methodName} not found, did you mean {$hint}?");
                     }
                     throw new ServiceCreationException("Service of type {$class} needed by {$methodName} not found. Did you register it in configuration file?");
                 } else {
                     throw new ServiceCreationException("Class {$class} needed by {$methodName} not found. Check type hint and 'use' statements.");
                 }
             } else {
                 if ($container instanceof ContainerBuilder) {
                     $res[$num] = '@' . $res[$num];
                 }
                 $optCount = 0;
             }
         } elseif ($parameter->isOptional() || $parameter->isDefaultValueAvailable()) {
             // !optional + defaultAvailable = func($a = NULL, $b) since 5.3.17 & 5.4.7
             // optional + !defaultAvailable = i.e. Exception::__construct, mysqli::mysqli, ...
             $res[$num] = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : NULL;
             $optCount++;
         } else {
             throw new ServiceCreationException("Parameter \${$parameter->getName()} in {$methodName} has no class type hint or default value, so its value must be specified.");
         }
     }
     // extra parameters
     while (array_key_exists(++$num, $arguments)) {
         $res[$num] = $arguments[$num];
         unset($arguments[$num]);
         $optCount = 0;
     }
     if ($arguments) {
         throw new ServiceCreationException("Unable to pass specified arguments to {$methodName}.");
     }
     return $optCount ? array_slice($res, 0, -$optCount) : $res;
 }
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:59,代码来源:Helpers.php

示例11: fromReflection

 /**
  * Creates a function location instance from the supplied reflection.
  *
  * @param \ReflectionFunctionAbstract $reflection
  *
  * @return self
  */
 public static function fromReflection(\ReflectionFunctionAbstract $reflection)
 {
     if ($reflection instanceof \ReflectionFunction) {
         $namespace = $reflection->getNamespaceName();
     } elseif ($reflection instanceof \ReflectionMethod) {
         $namespace = $reflection->getDeclaringClass()->getNamespaceName();
     } else {
         $namespace = null;
     }
     return new self($reflection->getFileName(), $namespace, $reflection->getStartLine(), $reflection->getEndLine());
 }
开发者ID:timetoogo,项目名称:pinq,代码行数:18,代码来源:FunctionLocation.php

示例12: getReturnType

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

示例13: getFunctionName

 /**
  * @param \ReflectionFunctionAbstract $reflection
  *
  * @return string
  */
 protected static function getFunctionName(\ReflectionFunctionAbstract $reflection)
 {
     if (!$reflection instanceof \ReflectionMethod) {
         return $reflection->name;
     }
     $class = $reflection->getDeclaringClass()->name;
     // see https://github.com/facebook/hhvm/issues/3874
     if (0 === strpos($class, 'Closure')) {
         $class = 'Closure';
     }
     return $class . '::' . $reflection->name;
 }
开发者ID:rybakit,项目名称:arguments-resolver,代码行数:17,代码来源:ReflectionFactoryTest.php

示例14: fromReflection

 /**
  * Creates a function scope instance from the supplied reflection and callable.
  *
  * @param \ReflectionFunctionAbstract $reflection
  * @param callable                    $callable
  *
  * @return self
  */
 public static function fromReflection(\ReflectionFunctionAbstract $reflection, callable $callable)
 {
     if (is_array($callable)) {
         /** @var $reflection \ReflectionMethod */
         $thisObject = is_object($callable[0]) ? $callable[0] : null;
         $scopeType = $reflection->getDeclaringClass()->getName();
     } elseif (is_object($callable) && !$callable instanceof \Closure) {
         /** @var $reflection \ReflectionMethod */
         $thisObject = $callable;
         $scopeType = $reflection->getDeclaringClass()->getName();
     } elseif ($reflection->isClosure()) {
         $thisObject = $reflection->getClosureThis();
         $scopeClass = $reflection->getClosureScopeClass();
         $scopeType = $scopeClass === null ? null : $scopeClass->getName();
     } else {
         $thisObject = null;
         $scopeType = null;
     }
     $variableTable = $reflection->getStaticVariables();
     return new self($thisObject, $scopeType, $variableTable);
 }
开发者ID:timetoogo,项目名称:pinq,代码行数:29,代码来源:FunctionScope.php

示例15: processFunctionOrMethod

 /**
  * @param \ReflectionFunctionAbstract $functionOrMethod
  */
 private function processFunctionOrMethod(\ReflectionFunctionAbstract $functionOrMethod)
 {
     if ($functionOrMethod->isInternal()) {
         return;
     }
     $name = $functionOrMethod->getName();
     if ($functionOrMethod instanceof \ReflectionMethod) {
         $name = $functionOrMethod->getDeclaringClass()->getName() . '::' . $name;
     }
     if (!isset($this->lookupTable[$functionOrMethod->getFileName()])) {
         $this->lookupTable[$functionOrMethod->getFileName()] = [];
     }
     foreach (range($functionOrMethod->getStartLine(), $functionOrMethod->getEndLine()) as $line) {
         $this->lookupTable[$functionOrMethod->getFileName()][$line] = $name;
     }
 }
开发者ID:ezrra,项目名称:PHP,代码行数:19,代码来源:Wizard.php


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