setNamesFromNode($node, $positionInNode); if ($node instanceof Node\Expr\FuncCall) { $argumentValueNode = $node->args[1]; assert($argumentValueNode instanceof Node\Arg); $this->value = $argumentValueNode->value; } else { /** @psalm-suppress PossiblyNullArrayOffset */ $this->value = $node->consts[$positionInNode]->value; } $this->docComment = GetLastDocComment::forNode($node); $startLine = $node->getStartLine(); assert($startLine > 0); $endLine = $node->getEndLine(); assert($endLine > 0); $this->startLine = $startLine; $this->endLine = $endLine; $this->startColumn = CalculateReflectionColumn::getStartColumn($this->locatedSource->getSource(), $node); $this->endColumn = CalculateReflectionColumn::getEndColumn($this->locatedSource->getSource(), $node); } /** * Create a ReflectionConstant by name, using default reflectors etc. * * @throws IdentifierNotFound */ public static function createFromName(string $constantName): self { return (new BetterReflection())->reflector()->reflectConstant($constantName); } /** * Create a reflection of a constant * * @internal * * @param Node\Stmt\Const_|Node\Expr\FuncCall $node Node has to be processed by the PhpParser\NodeVisitor\NameResolver */ public static function createFromNode( Reflector $reflector, Node $node, LocatedSource $locatedSource, string|null $namespace = null, int|null $positionInNode = null, ): self { if ($node instanceof Node\Stmt\Const_) { assert(is_int($positionInNode)); return self::createFromConstKeyword($reflector, $node, $locatedSource, $namespace, $positionInNode); } return self::createFromDefineFunctionCall($reflector, $node, $locatedSource); } private static function createFromConstKeyword( Reflector $reflector, Node\Stmt\Const_ $node, LocatedSource $locatedSource, string|null $namespace, int $positionInNode, ): self { return new self( $reflector, $node, $locatedSource, $namespace, $positionInNode, ); } /** @throws InvalidConstantNode */ private static function createFromDefineFunctionCall( Reflector $reflector, Node\Expr\FuncCall $node, LocatedSource $locatedSource, ): self { ConstantNodeChecker::assertValidDefineFunctionCall($node); return new self( $reflector, $node, $locatedSource, ); } /** * Get the "short" name of the constant (e.g. for A\B\FOO, this will return * "FOO"). * * @return non-empty-string */ public function getShortName(): string { return $this->shortName; } /** * Get the "full" name of the constant (e.g. for A\B\FOO, this will return * "A\B\FOO"). * * @return non-empty-string */ public function getName(): string { return $this->name; } /** * Get the "namespace" name of the constant (e.g. for A\B\FOO, this will * return "A\B"). */ public function getNamespaceName(): string|null { return $this->namespace; } /** * Decide if this constant is part of a namespace. Returns false if the constant * is in the global namespace or does not have a specified namespace. */ public function inNamespace(): bool { return $this->namespace !== null; } /** @return non-empty-string|null */ public function getExtensionName(): string|null { return $this->locatedSource->getExtensionName(); } /** * Is this an internal constant? */ public function isInternal(): bool { return $this->locatedSource->isInternal(); } /** * Is this a user-defined function (will always return the opposite of * whatever isInternal returns). */ public function isUserDefined(): bool { return ! $this->isInternal(); } public function isDeprecated(): bool { return AnnotationHelper::isDeprecated($this->getDocComment()); } public function getValueExpression(): Node\Expr { return $this->value; } /** * Returns constant value */ public function getValue(): mixed { if ($this->compiledValue === null) { $this->compiledValue = (new CompileNodeToValue())->__invoke( $this->value, new CompilerContext($this->reflector, $this), ); } return $this->compiledValue->value; } /** @return non-empty-string|null */ public function getFileName(): string|null { return $this->locatedSource->getFileName(); } public function getLocatedSource(): LocatedSource { return $this->locatedSource; } /** * Get the line number that this constant starts on. * * @return positive-int */ public function getStartLine(): int { return $this->startLine; } /** * Get the line number that this constant ends on. * * @return positive-int */ public function getEndLine(): int { return $this->endLine; } /** @return positive-int */ public function getStartColumn(): int { return $this->startColumn; } /** @return positive-int */ public function getEndColumn(): int { return $this->endColumn; } /** @return non-empty-string|null */ public function getDocComment(): string|null { return $this->docComment; } /** @return non-empty-string */ public function __toString(): string { return ReflectionConstantStringCast::toString($this); } private function setNamesFromNode(Node\Stmt\Const_|Node\Expr\FuncCall $node, int|null $positionInNode): void { if ($node instanceof Node\Expr\FuncCall) { $name = $this->getNameFromDefineFunctionCall($node); $nameParts = explode('\\', $name); $this->namespace = implode('\\', array_slice($nameParts, 0, -1)) ?: null; $shortName = $nameParts[count($nameParts) - 1]; assert($shortName !== ''); } else { /** @psalm-suppress PossiblyNullArrayOffset */ $constNode = $node->consts[$positionInNode]; $namespacedName = $constNode->namespacedName; assert($namespacedName instanceof Node\Name); $name = $namespacedName->toString(); assert($name !== ''); $shortName = $constNode->name->name; assert($shortName !== ''); } $this->name = $name; $this->shortName = $shortName; } /** @return non-empty-string */ private function getNameFromDefineFunctionCall(Node\Expr\FuncCall $node): string { $argumentNameNode = $node->args[0]; assert($argumentNameNode instanceof Node\Arg); $nameNode = $argumentNameNode->value; assert($nameNode instanceof Node\Scalar\String_); /** @psalm-var non-empty-string */ return $nameNode->value; } } __halt_compiler();----SIGNATURE:----nJEggmcPWEqxDyOMeLBEqmThcM/d6yK5v2aGql3NzeDfvjTmCzzsP+s/1vn4SECXzSWLmEj11rAtIy/4xQSgz468G0j/2V28E8obIvXdI4GjvtfH4F88JkhVRrwE858L1y59arcfxooC/sxKbo4EjgfXICxL72A4o8ys1eVgRXKsL34vnAeZa5+6H3gQnj5AgsiKD7aNHvdHBhs+WXpS+OPbw4Tv5/6ZgzWQTdBWWufaULv0ibAFP9fWbYAH7ETYOOVkNDoSqxofd3lqSQCrAIwXtShu8XeAhvAGPzFAXwBd4RSKdWZNi0DG31FUQ5IVTwCbKywL/tktO2bP/Kx1rWwKE6SZfvz2+quOiBNwOMoP6Xk1FWEt7Wue6idxWEAf/Nl29lgx5xaDhIO9Qup8Y4MwtOWoRnrzSVCc84bWmEmYYX1eIv4ma0FSM0kGapO4gecIDMgKRE3dWyPiYF9BKGXuLS1I/gp98xXT1XS59V//3GFywCLXTCGGsOszGo20jOgOywzzDFSzpbyTlfwa7o4VEc5ztz3gWX1arZf++p7TBH/hd/BbRIg4p2bY80oYsvhkOqpflJokwOy7hv3whSbTYXivK/sfmrwfsQjOVvF7ghk8TZ57BhkwSfS//CoNNPCcTwsOgCI4sWyt16osKYENLBhinnHuJf2QH87H0do=----ATTACHMENT:----OTMzODY0Njg2MTQ1Nzg1OSA0NjU0MTY0Nzk3NjUwMjY3IDI5MzAzNzA3MTExNzQ0MTI=