From 7b1a175370908ba0abec30f79a9fa305d9f3f6df Mon Sep 17 00:00:00 2001 From: Anastasiia Sherekina Date: Tue, 17 Jun 2025 11:50:25 +0300 Subject: [PATCH] fix multiline call sniff --- .../Formatting/WhiteSpaceAroundMultilineCallSniff.php | 7 +------ .../white-space-around-multiline-call/success.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/PhpCs/FiveLab/Sniffs/Formatting/WhiteSpaceAroundMultilineCallSniff.php b/src/PhpCs/FiveLab/Sniffs/Formatting/WhiteSpaceAroundMultilineCallSniff.php index c6dc55b..08eff48 100644 --- a/src/PhpCs/FiveLab/Sniffs/Formatting/WhiteSpaceAroundMultilineCallSniff.php +++ b/src/PhpCs/FiveLab/Sniffs/Formatting/WhiteSpaceAroundMultilineCallSniff.php @@ -48,12 +48,6 @@ protected function processFunctionCall(File $phpcsFile, int $stackPtr, array $pa } } - /** - * Check before multiline call - * - * @param File $phpcsFile - * @param int $stackPtr - */ private function checkBeforeCall(File $phpcsFile, int $stackPtr): void { $tokens = $phpcsFile->getTokens(); @@ -89,6 +83,7 @@ private function checkBeforeCall(File $phpcsFile, int $stackPtr): void T_OPEN_SHORT_ARRAY, T_COLON, T_ATTRIBUTE_END, + T_RETURN ]; if ($diffLines < 2 && !\in_array($prevToken['code'], $possiblePrevTokens, true)) { diff --git a/tests/PhpCs/FiveLab/Sniffs/Formatting/Resources/white-space-around-multiline-call/success.php b/tests/PhpCs/FiveLab/Sniffs/Formatting/Resources/white-space-around-multiline-call/success.php index 0f89463..3043357 100644 --- a/tests/PhpCs/FiveLab/Sniffs/Formatting/Resources/white-space-around-multiline-call/success.php +++ b/tests/PhpCs/FiveLab/Sniffs/Formatting/Resources/white-space-around-multiline-call/success.php @@ -1,5 +1,7 @@ child() ->method(\sprintf( @@ -64,4 +66,12 @@ function some(\DOMDocument $dom): string ])] function withAttributes() { + $object = new \StdClass(); + + return $object + ->some([ + 'bla' => 'bla', + 'foo' => 'foo', + ]) + ->some2(); }