src/Reflection/ReflectionClass.php
public function getReflectionConstants() : array
    {
        // Note: constants are not merged via their name as array index, since internal PHP constant
        //       sorting does not follow `\array_merge()` semantics
        /** @var ReflectionClassConstant[] $allReflectionConstants */
        $allReflectionConstants = array_merge(
            array_values($this->getImmediateReflectionConstants()),
            ...array_map(
                static function (ReflectionClass $ancestor) : array {
                    return array_filter(
                        array_values($ancestor->getReflectionConstants()),
                        static function (ReflectionClassConstant $classConstant) : bool {
                            return ! $classConstant->isPrivate();
                        }
                    );
                },
                array_filter([$this->getParentClass()])
            ),
            ...array_map(
                static function (ReflectionClass $interface) : array {
                    return array_values($interface->getReflectionConstants());
                },
                array_values($this->getInterfaces())
            )
        );

        $reflectionConstants = [];

        foreach ($allReflectionConstants as $constant) {
            $constantName = $constant->getName();

            if (isset($reflectionConstants[$constantName])) {
                continue;
            }

            $reflectionConstants[$constantName] = $constant;
        }

        return $reflectionConstants;
    }
public function getReflectionConstants() : array
    {
        // Note: constants are not merged via their name as array index, since internal PHP constant
        //       sorting does not follow `\array_merge()` semantics
        /** @var ReflectionClassConstant[] $allReflectionConstants */
        $allReflectionConstants = array_merge(
            array_values($this->getImmediateReflectionConstants()),
            ...array_map(
                static function (ReflectionClass $ancestor) : array {
                    return array_filter(
                        array_values($ancestor->getReflectionConstants()),
                        static function (ReflectionClassConstant $classConstant) : bool {
                            return ! $classConstant->isPrivate();
                        }
                    );
                },
                array_filter([$this->getParentClass()])
            ),
            ...array_map(
                static function (ReflectionClass $interface) : array {
                    return array_values($interface->getReflectionConstants());
                },
                array_values($this->getInterfaces())
            )
        );

        $reflectionConstants = [];

        foreach ($allReflectionConstants as $constant) {
            $constantName = $constant->getName();

            if (isset($reflectionConstants[$constantName])) {
                continue;
            }

            $reflectionConstants[$constantName] = $constant;
        }

        return $reflectionConstants;
    }
Get an associative array of the defined constants in this class,
with keys as constant names and values as {@see ReflectionClassConstant} objects.

@return ReflectionClassConstant[] indexed by name