We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a4583d commit 661babeCopy full SHA for 661babe
1 file changed
src/Type/Generic/TemplateTypeTrait.php
@@ -282,13 +282,14 @@ public function inferTemplateTypes(Type $receivedType): TemplateTypeMap
282
TemplateTypeVarianceMap::createEmpty(),
283
TemplateTypeVariance::createStatic(),
284
));
285
- if ($resolvedBound->isSuperTypeOf($receivedType)->yes()) {
+ $boundMatches = $resolvedBound->isSuperTypeOf($receivedType);
286
+ if ($boundMatches->yes()) {
287
return (new TemplateTypeMap([
288
$this->name => $receivedType,
289
]))->union($map);
290
}
291
- if ($receivedType instanceof UnionType) {
292
+ if ($boundMatches->maybe() && $receivedType instanceof UnionType) {
293
$matchingTypes = [];
294
foreach ($receivedType->getTypes() as $innerType) {
295
if (!$resolvedBound->isSuperTypeOf($innerType)->yes()) {
0 commit comments