src/Analyse/Callback/Iterate/ThroughMethods.php
protected function retrieveDeclaringReflection(
        \ReflectionMethod $reflectionMethod,
        \ReflectionClass $declaringClass
    ) {
        // Get a first impression.
        if ($reflectionMethod->getFileName() === $declaringClass->getFileName()) {
            return $declaringClass;
        }

        // Go through the first layer of traits.
        // No need to recheck the availability for traits. This is done above.
        foreach ($declaringClass->getTraits() as $trait) {
            $result = $this->retrieveDeclaringReflection($reflectionMethod, $trait);
            if ($result !== false) {
                return $result;
            }
        }

        return false;
    }
protected function retrieveDeclaringReflection(
        \ReflectionMethod $reflectionMethod,
        \ReflectionClass $declaringClass
    ) {
        // Get a first impression.
        if ($reflectionMethod->getFileName() === $declaringClass->getFileName()) {
            return $declaringClass;
        }

        // Go through the first layer of traits.
        // No need to recheck the availability for traits. This is done above.
        foreach ($declaringClass->getTraits() as $trait) {
            $result = $this->retrieveDeclaringReflection($reflectionMethod, $trait);
            if ($result !== false) {
                return $result;
            }
        }

        return false;
    }
protected function retrieveDeclaringReflection ( \ ReflectionMethod $ reflectionMethod , \ ReflectionClass $ declaringClass ) { // Get a first impression. if ( $ reflectionMethod -> getFileName ( ) === $ declaringClass -> getFileName ( ) ) { return $ declaringClass ; } // Go through the first layer of traits. // No need to recheck the availability for traits. This is done above. foreach ( $ declaringClass -> getTraits ( ) as $ trait ) { $ result = $ this -> retrieveDeclaringReflection ( $ reflectionMethod , $ trait ) ; if ( $ result !== false ) { return $ result ; } } return false ; }
Retrieve the declaration class reflection from traits.

@param \ReflectionMethod $reflectionMethod
The reflection of the method we are analysing.
@param \ReflectionClass $declaringClass
The original declaring class, the one with the traits.

@return bool|\ReflectionClass
false = unable to retrieve someting.
Otherwise return a reflection class.
Retrieve the declaration class reflection from traits .