/** * @param ClassReflectionInterface|ParameterReflectionInterface|FunctionReflectionInterface $reflectionElement * @return ClassReflectionInterface|FunctionReflectionInterface */ private function correctContextForParameterOrClassMember($reflectionElement) { if ($reflectionElement instanceof ParameterReflectionInterface && $reflectionElement->getDeclaringClassName() === null) { // Parameter of function in namespace or global space return $this->getFunction($reflectionElement->getDeclaringFunctionName()); } elseif ($reflectionElement instanceof InClassInterface) { // Member of a class return $this->getClass($reflectionElement->getDeclaringClassName()); } return $reflectionElement; }