Skip to content

Commit e4331af

Browse files
committed
Fix another infinite recursion problem
1 parent 49dcc50 commit e4331af

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Type/Generic/TemplateTypeTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
117117

118118
public function isSubTypeOf(Type $type): TrinaryLogic
119119
{
120-
$boundClass = get_class($this->getBound());
120+
$bound = $this->getBound();
121121
if (
122-
!$type instanceof $boundClass
122+
!$type instanceof $bound
123+
&& !$this instanceof $type
123124
&& !$type instanceof TemplateType
124125
&& ($type instanceof UnionType || $type instanceof IntersectionType)
125126
) {

tests/PHPStan/Type/TemplateTypeTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ public function dataIsSuperTypeOf(): array
248248
TrinaryLogic::createMaybe(),
249249
TrinaryLogic::createMaybe(),
250250
],
251+
[
252+
$templateType('T', new BenevolentUnionType([new IntegerType(), new StringType()])),
253+
new UnionType([new BooleanType(), new FloatType(), new IntegerType(), new StringType(), new NullType()]),
254+
TrinaryLogic::createMaybe(),
255+
TrinaryLogic::createYes(),
256+
],
251257
];
252258
}
253259

0 commit comments

Comments
 (0)