Skip to content

Commit bd76e52

Browse files
ondrejmirtesclaude
andcommitted
Do not inline callee bodies whose method calls use named arguments
The phar build's PHP 7.4 downgrade resolves a method call's named arguments only on a $this->prop receiver, from the property's native type. Inlining MutatingScope::enterNamespace() - one return of $this->scopeFactory->create(..., templateArgumentFrame: ...) - turned the receiver into $scope->scopeFactory at the call sites, the arguments stayed named, and the 2.3.x phar failed to parse on PHP 7.4 (NamespaceHandler, PhpClassReflectionExtension). Skip such callees; named arguments on new/static calls resolve by class name and still downgrade, so they stay inlinable. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PNSsTrrmeGmkCDA4VR72tt
1 parent 9f7d822 commit bd76e52

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎build/PHPStan/Build/InlineCallCollector.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ public function processNode(Node $node, Scope $scope): ?array
159159
if ($n instanceof Expr\NullsafePropertyFetch || $n instanceof Expr\NullsafeMethodCall) {
160160
return true;
161161
}
162+
if ($n instanceof Expr\MethodCall) {
163+
// the phar build's PHP 7.4 downgrade resolves a method call's named
164+
// arguments only on a $this->prop receiver (it reads the property's
165+
// native type); after substitution the receiver is the call site's
166+
// expression, and the arguments would survive as a parse error
167+
foreach ($n->getArgs() as $arg) {
168+
if ($arg->name !== null) {
169+
return true;
170+
}
171+
}
172+
}
162173
return false;
163174
});
164175
if ($forbidden !== null) {

0 commit comments

Comments
 (0)