Pinq\Parsing\FunctionReflection::resolveMagicConstants PHP Method

resolveMagicConstants() private method

private resolveMagicConstants ( Pinq\Parsing\IFunctionDeclaration $declaration )
$declaration Pinq\Parsing\IFunctionDeclaration
    private function resolveMagicConstants(IFunctionDeclaration $declaration)
    {
        $reflection = $this->innerReflection;
        $__FILE__ = $this->location->getFilePath();
        $__DIR__ = dirname($__FILE__);
        $__NAMESPACE__ = $declaration->getNamespace() ?: '';
        $__TRAIT__ = '';
        $namespacePrefix = $__NAMESPACE__ === '' ? '' : $__NAMESPACE__ . '\\';
        if ($declaration->isWithinClass()) {
            $__CLASS__ = $namespacePrefix . $declaration->getClass();
            $declarationType = $__CLASS__;
        } elseif ($declaration->isWithinTrait()) {
            $__TRAIT__ = $namespacePrefix . $declaration->getTrait();
            $declarationType = $__TRAIT__;
            //If the function is method declared within a trait the __CLASS__ constant
            //is programmed to be the class in which the trait is used in: https://bugs.php.net/bug.php?id=55214&edit=1
            //ReflectionMethod::getDeclaringClass() will resolve this.
            if ($reflection instanceof \ReflectionMethod) {
                $__CLASS__ = $reflection->getDeclaringClass()->getName();
            } else {
                $__CLASS__ = $this->scope->getScopeType() ?: '';
            }
        } else {
            $__CLASS__ = '';
            $__TRAIT__ = '';
            $declarationType = null;
        }
        $__FUNCTION__ = $reflection->getName();
        $__FUNCTION__WithinClosure = $namespacePrefix . '{closure}';
        if ($declarationType === null) {
            $__METHOD__ = $__FUNCTION__;
            $__METHOD__WithinClosure = $__FUNCTION__WithinClosure;
        } else {
            $__METHOD__ = $declarationType . '::' . $__FUNCTION__;
            $__METHOD__WithinClosure = $declarationType . '::' . $__FUNCTION__WithinClosure;
        }
        return new MagicConstants($__DIR__, $__FILE__, $__NAMESPACE__, $__CLASS__, $__TRAIT__, $__FUNCTION__, $__FUNCTION__WithinClosure, $__METHOD__, $__METHOD__WithinClosure);
    }