Skip to content

Commit c11b324

Browse files
committed
Fixed bug #2506 : PSR2 standard can't auto fix multi-line function call inside a string concat statement
1 parent f797a35 commit c11b324

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3939
-- Boolean operators can now appear in the middle of the line
4040
- PSR12.Files.FileHeader no longer ignores comments preceding a use, namespace, or declare statement
4141
- PSR12.Files.FileHeader now allows a hashbang line at the top of the file
42+
- Fixed bug #2506 : PSR2 standard can't auto fix multi-line function call inside a string concat statement
4243
- Fixed bug #2530 : PEAR.Commenting.FunctionComment does not support intersection types in comments
4344
- Fixed bug #2615 : Constant visibility false positive on non-class constants
4445
- Fixed bug #2616 : PSR12.Files.FileHeader false positive when file only contains docblock

src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
350350

351351
$foundFunctionIndent = 0;
352352
if ($first !== false) {
353-
if ($tokens[$first]['code'] === T_INLINE_HTML) {
353+
if ($tokens[$first]['code'] === T_INLINE_HTML
354+
|| $tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
355+
) {
354356
$trimmed = ltrim($tokens[$first]['content']);
355357
if ($trimmed === '') {
356358
$foundFunctionIndent = strlen($tokens[$first]['content']);

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,14 @@ $this->foo(
431431
true
432432

433433
);
434+
435+
function m()
436+
{
437+
$t = '
438+
' . (empty(true) ? '
439+
' . f(
440+
'1',
441+
'2',
442+
) . '
443+
' : '');
444+
}

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,14 @@ $this->foo(
441441
['a','b'],
442442
true
443443
);
444+
445+
function m()
446+
{
447+
$t = '
448+
' . (empty(true) ? '
449+
' . f(
450+
'1',
451+
'2',
452+
) . '
453+
' : '');
454+
}

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc')
116116
424 => 1,
117117
429 => 1,
118118
432 => 1,
119+
440 => 1,
120+
441 => 1,
121+
442 => 1,
119122
];
120123

121124
}//end getErrorList()

0 commit comments

Comments
 (0)