Skip to content

Commit

Permalink
GenericClassStringType::isSuperTypeOf() - do not convert maybe into no
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 12, 2022
1 parent 0e25706 commit 6fba542
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/Type/Generic/GenericClassStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
$isSuperType = $genericType->isSuperTypeOf($objectType);
}

// Explicitly handle the uncertainty for Maybe.
if ($isSuperType->maybe()) {
return TrinaryLogic::createNo();
}
return $isSuperType;
} elseif ($type instanceof self) {
return $this->type->isSuperTypeOf($type->type);
Expand Down
6 changes: 3 additions & 3 deletions tests/PHPStan/Type/Generic/GenericClassStringTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function dataIsSuperTypeOf(): array
8 => [
new GenericClassStringType(new ObjectType(InvalidArgumentException::class)),
new ConstantStringType(Exception::class),
TrinaryLogic::createNo(),
TrinaryLogic::createMaybe(),
],
9 => [
new GenericClassStringType(new ObjectType(stdClass::class)),
Expand Down Expand Up @@ -128,7 +128,7 @@ public function dataIsSuperTypeOf(): array
TemplateTypeVariance::createInvariant(),
)),
new ConstantStringType(Throwable::class),
TrinaryLogic::createNo(),
TrinaryLogic::createMaybe(),
],
15 => [
new GenericClassStringType(new StaticType($reflectionProvider->getClass(Exception::class))),
Expand All @@ -138,7 +138,7 @@ public function dataIsSuperTypeOf(): array
16 => [
new GenericClassStringType(new StaticType($reflectionProvider->getClass(InvalidArgumentException::class))),
new ConstantStringType(Exception::class),
TrinaryLogic::createNo(),
TrinaryLogic::createMaybe(),
],
17 => [
new GenericClassStringType(new StaticType($reflectionProvider->getClass(Throwable::class))),
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Type/TypeCombinatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3020,8 +3020,8 @@ public function dataIntersect(): iterable
new GenericClassStringType(new ObjectType(InvalidArgumentException::class)),
new ConstantStringType(Exception::class),
],
NeverType::class,
'*NEVER*',
IntersectionType::class,
"'Exception'&class-string<InvalidArgumentException>",
],
[
[
Expand Down

0 comments on commit 6fba542

Please sign in to comment.