From 8215c687f11b5518711b8745011364f85346e073 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 22 Nov 2026 19:57:49 +0700 Subject: [PATCH] [PHP8.6] Handle crash on partial function application on PHP 8.6 scope set attribute --- .../Fixture/partial_application.php.inc | 31 +++++++++++++++++++ .../Scope/PHPStanNodeScopeResolver.php | 2 +- .../CallLikeReflectionNodeVisitor.php | 2 +- .../NodeVisitor/NameAndArgNodeVisitor.php | 2 +- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 rules-tests/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/partial_application.php.inc diff --git a/rules-tests/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/partial_application.php.inc b/rules-tests/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/partial_application.php.inc new file mode 100644 index 00000000000..27fc3660fa1 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/partial_application.php.inc @@ -0,0 +1,31 @@ +data = array_map(trim(?), [' x ']); + } +} + +?> +----- +data = array_map(trim(?), [' x ']); + } +} + +?> \ No newline at end of file diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 33060c93aec..648912e32c4 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -394,7 +394,7 @@ private function processCallLike(CallLike $callLike, MutatingScope $mutatingScop $callLike->class->setAttribute(AttributeKey::SCOPE, $mutatingScope); } - if ($callLike->isFirstClassCallable()) { + if ($callLike->isPartialFunctionApplication()) { return; } diff --git a/src/PhpParser/NodeVisitor/CallLikeReflectionNodeVisitor.php b/src/PhpParser/NodeVisitor/CallLikeReflectionNodeVisitor.php index f1ad79f82c3..a332086e418 100644 --- a/src/PhpParser/NodeVisitor/CallLikeReflectionNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/CallLikeReflectionNodeVisitor.php @@ -45,7 +45,7 @@ public function enterNode(Node $node): ?Node return null; } - if ($node->isFirstClassCallable()) { + if ($node->isPartialFunctionApplication()) { return null; } diff --git a/src/PhpParser/NodeVisitor/NameAndArgNodeVisitor.php b/src/PhpParser/NodeVisitor/NameAndArgNodeVisitor.php index 7e646c0417f..a7b0191e451 100644 --- a/src/PhpParser/NodeVisitor/NameAndArgNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/NameAndArgNodeVisitor.php @@ -27,7 +27,7 @@ public function enterNode(Node $node): ?Node if ($node instanceof FuncCall && $node->name instanceof Name) { $node->name->setAttribute(AttributeKey::IS_FUNCCALL_NAME, true); - if (! $node->isFirstClassCallable()) { + if (! $node->isPartialFunctionApplication()) { $funcCallName = $node->name->toString(); foreach ($node->getArgs() as $arg) { $arg->value->setAttribute(AttributeKey::FROM_FUNC_CALL_NAME, $funcCallName);