src/Reflection/ReflectionClass.php
private function getMethodsIndexedByName() : array
    {
        if ($this->cachedMethods !== null) {
            return $this->cachedMethods;
        }

        $this->cachedMethods = [];

        $traitAliases = $this->getTraitAliases();

        foreach ($this->getAllMethods() as $method) {
            $methodName              = $method->getName();
            $methodNameWithClassName = sprintf('%s::%s', $method->getDeclaringClass()->getName(), $methodName);

            foreach ($traitAliases as $methodAlias => $traitMethodNameWithTraitName) {
                if ($methodNameWithClassName !== $traitMethodNameWithTraitName) {
                    continue;
                }

                if (isset($this->cachedMethods[$methodAlias])) {
                    continue;
                }

                $this->cachedMethods[$methodAlias] = $method;
            }

            if (isset($this->cachedMethods[$methodName])) {
                continue;
            }

            $this->cachedMethods[$methodName] = $method;
        }

        return $this->cachedMethods;
    }
private function getMethodsIndexedByName() : array
    {
        if ($this->cachedMethods !== null) {
            return $this->cachedMethods;
        }

        $this->cachedMethods = [];

        $traitAliases = $this->getTraitAliases();

        foreach ($this->getAllMethods() as $method) {
            $methodName              = $method->getName();
            $methodNameWithClassName = sprintf('%s::%s', $method->getDeclaringClass()->getName(), $methodName);

            foreach ($traitAliases as $methodAlias => $traitMethodNameWithTraitName) {
                if ($methodNameWithClassName !== $traitMethodNameWithTraitName) {
                    continue;
                }

                if (isset($this->cachedMethods[$methodAlias])) {
                    continue;
                }

                $this->cachedMethods[$methodAlias] = $method;
            }

            if (isset($this->cachedMethods[$methodName])) {
                continue;
            }

            $this->cachedMethods[$methodName] = $method;
        }

        return $this->cachedMethods;
    }
Construct a flat list of methods that are available. This will search up
all parent classes/traits/interfaces/current scope for methods.

Methods are not merged via their name as array index, since internal PHP method
sorting does not follow `\array_merge()` semantics.

@return ReflectionMethod[] indexed by method name