diff --git a/src/ReflectionHydrator.php b/src/ReflectionHydrator.php index e64e96e..088ad91 100644 --- a/src/ReflectionHydrator.php +++ b/src/ReflectionHydrator.php @@ -62,17 +62,18 @@ public function hydrate(array $data, object $object, bool $includeParentProperti */ protected static function getReflProperties(object $input, bool $includeParentProperties): array { - $class = get_class($input); + $reflClass = new ReflectionClass($input); + $class = $reflClass->getName(); if (isset(static::$reflProperties[$class])) { return static::$reflProperties[$class]; } static::$reflProperties[$class] = []; - $reflClass = new ReflectionClass($class); do { foreach ($reflClass->getProperties() as $property) { + /** @psalm-suppress UnusedMethodCall - Bizarre, this is a void return!!! */ $property->setAccessible(true); static::$reflProperties[$class][$property->getName()] = $property; } diff --git a/test/ReflectionHydratorTest.php b/test/ReflectionHydratorTest.php index 83f0f59..03805c0 100644 --- a/test/ReflectionHydratorTest.php +++ b/test/ReflectionHydratorTest.php @@ -12,6 +12,8 @@ use stdClass; use TypeError; +use function get_parent_class; + #[CoversClass(ReflectionHydrator::class)] class ReflectionHydratorTest extends TestCase {