PHPUnit\Runner\CleverAndSmart\Exception\PropertyReflectionException::propertyNotExistsInHierarchy PHP Method

propertyNotExistsInHierarchy() public static method

public static propertyNotExistsInHierarchy ( $propertyName, ReflectionException $exception, array $classHierarchy )
$exception ReflectionException
$classHierarchy array
    public static function propertyNotExistsInHierarchy($propertyName, BaseReflectionException $exception, array $classHierarchy)
    {
        return new static(sprintf('Property "%s" does not exist in hierarchy %s', $propertyName, implode(' < ', $classHierarchy)), null, $exception);
    }

Usage Example

 /**
  * Get proper PropertyReflection object
  *
  * @param object $object
  * @param string $propertyName
  * @throws ReflectionException
  * @return ReflectionProperty
  */
 private static function getPropertyReflection($object, $propertyName)
 {
     $reflected = new ReflectionObject($object);
     $classHierarchy = array();
     do {
         try {
             $property = $reflected->getProperty($propertyName);
             $property->setAccessible(true);
             return $property;
         } catch (ReflectionException $e) {
             $classHierarchy[] = $reflected->getName();
             $e = PropertyReflectionException::propertyNotExistsInHierarchy($propertyName, $e, $classHierarchy);
         }
     } while ($reflected = $reflected->getParentClass());
     throw $e;
 }
PropertyReflectionException