Skip to content

Commit 3f301e7

Browse files
phpstan-botclaude
authored andcommitted
Remove dead isCallable() guard for closure/arrow function callback types
Scope::getType() on a Closure or ArrowFunction AST node always returns a ClosureType, which is always callable. The isCallable()->yes() check was therefore always true, making the else branch (FuncCall fallback) dead code for these node types. This also eliminates an unkillable mutation testing mutant (yes() vs !no()). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b37858 commit 3f301e7

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/Type/Php/ArrayMapFunctionReturnTypeExtension.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ private static function resolveCallbackReturnType(Scope $scope, Node\Expr $callb
175175
$clone->setAttribute(ArrayMapArgVisitor::ATTRIBUTE_NAME, [new Node\Arg(new TypeExpr($wrappedType))]);
176176
$clone->setAttribute('phpstanCachedTypes', []);
177177

178-
$closureType = $scope->getType($clone);
179-
if ($closureType->isCallable()->yes()) {
180-
return $closureType->getCallableParametersAcceptors($scope)[0]->getReturnType();
181-
}
178+
return $scope->getType($clone)->getCallableParametersAcceptors($scope)[0]->getReturnType();
182179
}
183180

184181
return $scope->getType(new FuncCall($callback, [

0 commit comments

Comments
 (0)