diff --git a/src/Capability/Registry/ReferenceHandler.php b/src/Capability/Registry/ReferenceHandler.php index f01b1870..66a29b05 100644 --- a/src/Capability/Registry/ReferenceHandler.php +++ b/src/Capability/Registry/ReferenceHandler.php @@ -173,7 +173,9 @@ private function castArgumentType(mixed $argument, \ReflectionParameter $paramet $typeName = $type->getName(); - if (enum_exists($typeName)) { + $shouldAutoload = !in_array($typeName, ['int', 'float', 'string', 'bool', 'array', 'object', 'callable', 'iterable', 'mixed', 'void', 'null', 'false', 'true', 'never']); + + if (enum_exists($typeName, $shouldAutoload)) { if (\is_object($argument) && $argument instanceof $typeName) { return $argument; }