Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Capability/Registry/ReferenceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Comment on lines +176 to +178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do something like this?

Ie, if it is an int, we would never call enum_exists().

Suggested change
$shouldAutoload = !in_array($typeName, ['int', 'float', 'string', 'bool', 'array', 'object', 'callable', 'iterable', 'mixed', 'void', 'null', 'false', 'true', 'never']);
if (enum_exists($typeName, $shouldAutoload)) {
if ($type->isBuiltin() === false && enum_exists($typeName)) {

https://www.php.net/manual/en/language.types.type-system.php

if (\is_object($argument) && $argument instanceof $typeName) {
return $argument;
}
Expand Down
Loading