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());