diff --git a/src/Filters/src/Model/Mapper/UuidCaster.php b/src/Filters/src/Model/Mapper/UuidCaster.php index 2e54101f4..d5ebf75e8 100644 --- a/src/Filters/src/Model/Mapper/UuidCaster.php +++ b/src/Filters/src/Model/Mapper/UuidCaster.php @@ -19,7 +19,9 @@ public function supports(\ReflectionNamedType $type): bool $this->interfaceExists = \interface_exists(UuidInterface::class); } - return $this->interfaceExists && $this->implements($type->getName(), UuidInterface::class); + return $this->interfaceExists && + !$type->isBuiltin() && + $this->implements($type->getName(), UuidInterface::class); } public function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void @@ -40,6 +42,10 @@ private function implements(string $haystack, string $interface): bool return true; } + if (!\class_exists($haystack)) { + return false; + } + foreach ((array)\class_implements($haystack) as $implements) { if ($implements === $interface) { return true; diff --git a/src/Filters/tests/Mapper/UuidCasterTest.php b/src/Filters/tests/Mapper/UuidCasterTest.php index a793ff02d..c3aa6ee6a 100644 --- a/src/Filters/tests/Mapper/UuidCasterTest.php +++ b/src/Filters/tests/Mapper/UuidCasterTest.php @@ -43,6 +43,7 @@ public static function supportsDataProvider(): \Traversable { $ref = new \ReflectionClass(UserFilter::class); + yield 'string' => [$ref->getProperty('name'), false]; yield 'enum' => [$ref->getProperty('status'), false]; yield 'uuid' => [$ref->getProperty('groupUuid'), true]; }