/**
  * @param ReflectionClass|ReflectionParameter|ReflectionFunction|ReflectionElement $reflectionElement
  * @return ReflectionClass|ReflectionFunction
  */
 private function correctContextForParameterOrClassMember($reflectionElement)
 {
     if ($reflectionElement instanceof ReflectionParameter && $reflectionElement->getDeclaringClassName() === NULL) {
         // Parameter of function in namespace or global space
         return $this->getFunction($reflectionElement->getDeclaringFunctionName());
     } elseif ($reflectionElement instanceof ReflectionMethod || $reflectionElement instanceof ReflectionParameter || $reflectionElement instanceof ReflectionConstant && $reflectionElement->getDeclaringClassName() !== NULL || $reflectionElement instanceof ReflectionProperty) {
         // Member of a class
         return $this->getClass($reflectionElement->getDeclaringClassName());
     }
     return $reflectionElement;
 }