Skip to content

Commit d5a6d29

Browse files
phpstan-botclaude
andcommitted
Return IsSuperTypeOfResult from ExpressionTypeHolder::isSuperTypeOf() for consistency
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5241dfc commit d5a6d29

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Analyser/ExpressionTypeHolder.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PhpParser\Node\Expr;
66
use PHPStan\TrinaryLogic;
7+
use PHPStan\Type\IsSuperTypeOfResult;
78
use PHPStan\Type\Type;
89
use PHPStan\Type\TypeCombinator;
910

@@ -50,17 +51,21 @@ public function equals(self $other): bool
5051
return $this->type === $other->type || $this->type->equals($other->type);
5152
}
5253

53-
public function isSuperTypeOf(self $other): bool
54+
public function isSuperTypeOf(self $other): IsSuperTypeOfResult
5455
{
5556
if ($this === $other) {
56-
return true;
57+
return IsSuperTypeOfResult::createYes();
5758
}
5859

5960
if (!$this->certainty->equals($other->certainty)) {
60-
return false;
61+
return IsSuperTypeOfResult::createNo();
62+
}
63+
64+
if ($this->type === $other->type) {
65+
return IsSuperTypeOfResult::createYes();
6166
}
6267

63-
return $this->type === $other->type || $this->type->isSuperTypeOf($other->type)->yes();
68+
return $this->type->isSuperTypeOf($other->type);
6469
}
6570

6671
public function and(self $other): self

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3230,7 +3230,7 @@ public function filterBySpecifiedTypes(SpecifiedTypes $specifiedTypes): self
32303230
}
32313231
if (!$specifiedExpressions[$holderExprString]->equals($conditionalTypeHolder)) {
32323232
$allExact = false;
3233-
if (!$conditionalTypeHolder->isSuperTypeOf($specifiedExpressions[$holderExprString])) {
3233+
if (!$conditionalTypeHolder->isSuperTypeOf($specifiedExpressions[$holderExprString])->yes()) {
32343234
$allSuperType = false;
32353235
break;
32363236
}

0 commit comments

Comments
 (0)