Skip to content

Commit 64f3fe3

Browse files
phpstan-botclaude
authored andcommitted
Remove redundant isSuperTypeOf check after TypeCombinator::intersect()
The result of TypeCombinator::intersect($writableType, $nonFinalObjectType) is by definition a subtype of $nonFinalObjectType, so the isSuperTypeOf check is always true when the result is not NeverType. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cba17ba commit 64f3fe3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Analyser/ExprHandler/NewHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ private function exactInstantiation(MutatingScope $scope, New_ $node, Name $clas
422422
if ($foundProperty !== null) {
423423
$nonFinalObjectType = $isStatic ? new StaticType($nonFinalClassReflection) : new ObjectType($resolvedClassName, classReflection: $nonFinalClassReflection);
424424
$propertyType = TypeCombinator::intersect($foundProperty->getWritableType(), $nonFinalObjectType);
425-
if (!($propertyType instanceof NeverType) && $nonFinalObjectType->isSuperTypeOf($propertyType)->yes()) {
425+
if (!($propertyType instanceof NeverType)) {
426426
return $propertyType;
427427
}
428428
}

0 commit comments

Comments
 (0)