src/Intruder.php
private function getProperty(string $name): \ReflectionProperty
    {
        $class = $this->getReflection();

        # See if the literal class has this property
        if ($class->hasProperty($name)) {
            return $class->getProperty($name);
        }

        # If not this class then check its parents
        $parent = $class;
        while (true) {
            $parent = $parent->getParentClass();
            if (!$parent) {
                break;
            }

            if ($parent->hasProperty($name)) {
                return $parent->getProperty($name);
            }
        }

        # We didn't find the property, but use this to give a sensible error
        return $class->getProperty($name);
    }
private function getProperty(string $name): \ReflectionProperty
    {
        $class = $this->getReflection();

        # See if the literal class has this property
        if ($class->hasProperty($name)) {
            return $class->getProperty($name);
        }

        # If not this class then check its parents
        $parent = $class;
        while (true) {
            $parent = $parent->getParentClass();
            if (!$parent) {
                break;
            }

            if ($parent->hasProperty($name)) {
                return $parent->getProperty($name);
            }
        }

        # We didn't find the property, but use this to give a sensible error
        return $class->getProperty($name);
    }
private function getProperty ( string $ name ) : \ ReflectionProperty { $ class = $ this -> getReflection ( ) ; # See if the literal class has this property if ( $ class -> hasProperty ( $ name ) ) { return $ class -> getProperty ( $ name ) ; } # If not this class then check its parents $ parent = $ class ; while ( true ) { $ parent = $ parent -> getParentClass ( ) ; if ( ! $ parent ) { break ; } if ( $ parent -> hasProperty ( $ name ) ) { return $ parent -> getProperty ( $ name ) ; } } # We didn't find the property, but use this to give a sensible error return $ class -> getProperty ( $ name ) ; }
Go hunting for a property up the class hierarchy.

@param string $name The name of the property we're looking for

@return \ReflectionProperty
Go hunting for a property up the class hierarchy .