From 29665e0768c3e95a6d1c54a3ad2cc6a890396391 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Mon, 23 Mar 2026 01:13:35 +0100 Subject: [PATCH] fix: correct parts.unshift() to parts.shift() in isSimpleCallArgument --- src/util.mjs | 2 +- tests/call/__snapshots__/jsfmt.spec.mjs.snap | 4 ++++ tests/call/call.php | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util.mjs b/src/util.mjs index b4bf9e473..1451dc717 100644 --- a/src/util.mjs +++ b/src/util.mjs @@ -678,7 +678,7 @@ function isSimpleCallArgument(node, depth = 2) { if (isCallLikeExpression(node)) { const parts = getChainParts(node); - parts.unshift(); + parts.shift(); return ( parts.length <= depth && diff --git a/tests/call/__snapshots__/jsfmt.spec.mjs.snap b/tests/call/__snapshots__/jsfmt.spec.mjs.snap index be49c6300..604148b70 100644 --- a/tests/call/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/call/__snapshots__/jsfmt.spec.mjs.snap @@ -356,6 +356,8 @@ $callable = $item->doSomething(...); $callable = $item::doSomething(...); $callable = Foo::doSomething(...); +$this->method1()->method2()->method3(foo()->bar()); + =====================================output===================================== doSomething(...); $callable = $item::doSomething(...); $callable = Foo::doSomething(...); +$this->method1()->method2()->method3(foo()->bar()); + ================================================================================ `; diff --git a/tests/call/call.php b/tests/call/call.php index 6e2f5a11d..5efc9b88d 100644 --- a/tests/call/call.php +++ b/tests/call/call.php @@ -347,3 +347,5 @@ public function setFoo($foo) $callable = $item->doSomething(...); $callable = $item::doSomething(...); $callable = Foo::doSomething(...); + +$this->method1()->method2()->method3(foo()->bar());