Skip to content

Commit

Permalink
Do not resolve intersection types when doing type inflection for even…
Browse files Browse the repository at this point in the history
…t handler mapping.
  • Loading branch information
frankdejonge committed Nov 25, 2023
1 parent c80b8ab commit ce8dfed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/EventConsumption/InflectHandlerMethodsFromType.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ protected function firstParameterType(ReflectionMethod $method): ?ReflectionType
*/
protected function acceptedTypes(ReflectionType $type): array
{
$acceptedTypes = [];

if ($type instanceof ReflectionNamedType) {
return [$type];
$acceptedTypes[] = $type;
} elseif ($type instanceof ReflectionUnionType) {
return $type->getTypes();
foreach ($type->getTypes() as $type) {
if ($type instanceof ReflectionNamedType) {
$acceptedTypes[] = $type;
}
}
}

return [];
return $acceptedTypes;
}
}

0 comments on commit ce8dfed

Please sign in to comment.