Behat\RestTestingExtension\RestTestingHelper::findProperty PHP Method

findProperty() public static method

Finds a property for the given class.
public static findProperty ( object | string $class, string $name, boolean $access = true ) : ReflectionProperty
$class object | string The class instance or name.
$name string The name of a property.
$access boolean Make the property accessible?
return ReflectionProperty The property.
    public static function findProperty($class, $name, $access = true)
    {
        $reflection = new \ReflectionClass($class);
        while (!$reflection->hasProperty($name)) {
            if (!($reflection = $reflection->getParentClass())) {
                throw new Exception(sprintf('Class "%s" does not have property "%s" defined.', $class, $name));
            }
        }
        $property = $reflection->getProperty($name);
        $property->setAccessible($access);
        return $property;
    }