phprs\util\DocParser::Constant PHP Метод

Constant() приватный Метод

Constant ::= integer | string | float | boolean
private Constant ( ) : mixed
Результат mixed
    private function Constant()
    {
        $identifier = $this->Identifier();
        if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
            list($className, $const) = explode('::', $identifier);
            $alias = false === ($pos = strpos($className, '\\')) ? $className : substr($className, 0, $pos);
            $found = false;
            switch (true) {
                case !empty($this->namespaces):
                    foreach ($this->namespaces as $ns) {
                        if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) {
                            $className = $ns . '\\' . $className;
                            $found = true;
                            break;
                        }
                    }
                    break;
                case isset($this->imports[$loweredAlias = strtolower($alias)]):
                    $found = true;
                    $className = false !== $pos ? $this->imports[$loweredAlias] . substr($className, $pos) : $this->imports[$loweredAlias];
                    break;
                default:
                    if (isset($this->imports['__NAMESPACE__'])) {
                        $ns = $this->imports['__NAMESPACE__'];
                        if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) {
                            $className = $ns . '\\' . $className;
                            $found = true;
                        }
                    }
                    break;
            }
            if ($found) {
                $identifier = $className . '::' . $const;
            }
        }
        // checks if identifier ends with ::class, \strlen('::class') === 7
        $classPos = stripos($identifier, '::class');
        if ($classPos === strlen($identifier) - 7) {
            return substr($identifier, 0, $classPos);
        }
        if (!defined($identifier)) {
            throw AnnotationException::semanticalErrorConstants($identifier, $this->context);
        }
        return constant($identifier);
    }