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); }
/** * 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; }