From 81c4bfafaf86421d51e4e6e14d8fbc7f4d009d2f Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Thu, 22 Jan 2026 16:35:51 +0800 Subject: [PATCH] Add autoload check for enum types in ReferenceHandler Some old framework is using autoload to include with the typeName directly, e.g. `include(ini.php)` when the typeName is `ini`. If the typeName is the arbitrary type, set autoload in `enum_exists` to `false` --- src/Capability/Registry/ReferenceHandler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; }