src/Reflection/ReflectionClass.php
public function getImmediateReflectionConstants() : array
    {
        if ($this->cachedReflectionConstants !== null) {
            return $this->cachedReflectionConstants;
        }

        $constants = array_merge(
            [],
            ...array_map(
                function (ConstNode $constNode) : array {
                    $constants = [];

                    foreach ($constNode->consts as $constantPositionInNode => $constantNode) {
                        $constants[] = ReflectionClassConstant::createFromNode($this->reflector, $constNode, $constantPositionInNode, $this);
                    }

                    return $constants;
                },
                array_filter(
                    $this->node->stmts,
                    static function (Node\Stmt $stmt) : bool {
                        return $stmt instanceof ConstNode;
                    }
                )
            )
        );

        return $this->cachedReflectionConstants = array_combine(
            array_map(
                static function (ReflectionClassConstant $constant) : string {
                    return $constant->getName();
                },
                $constants
            ),
            $constants
        );
    }
public function getImmediateReflectionConstants() : array
    {
        if ($this->cachedReflectionConstants !== null) {
            return $this->cachedReflectionConstants;
        }

        $constants = array_merge(
            [],
            ...array_map(
                function (ConstNode $constNode) : array {
                    $constants = [];

                    foreach ($constNode->consts as $constantPositionInNode => $constantNode) {
                        $constants[] = ReflectionClassConstant::createFromNode($this->reflector, $constNode, $constantPositionInNode, $this);
                    }

                    return $constants;
                },
                array_filter(
                    $this->node->stmts,
                    static function (Node\Stmt $stmt) : bool {
                        return $stmt instanceof ConstNode;
                    }
                )
            )
        );

        return $this->cachedReflectionConstants = array_combine(
            array_map(
                static function (ReflectionClassConstant $constant) : string {
                    return $constant->getName();
                },
                $constants
            ),
            $constants
        );
    }
Get an associative array of only the constants for this specific class (i.e. do not search
up parent classes etc.), with keys as constant names and values as {@see ReflectionClassConstant} objects.

@return ReflectionClassConstant[] indexed by name