Skip to content

Commit

Permalink
Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not…
Browse files Browse the repository at this point in the history
… ignoring indentation inside multi-line string arguments
  • Loading branch information
gsherwood committed Oct 3, 2019
1 parent 0aa44e9 commit 50a20de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file
- Fixed bug #2621 : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument
-- Thanks to Martins Sipenko for the patch
- Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments
- Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing
</notes>
<contents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ public function process(File $phpcsFile, $stackPtr)
break;
}

// Leave indentation inside multi-line strings.
if (isset(Tokens::$textStringTokens[$tokens[$i]['code']]) === true
|| isset(Tokens::$heredocTokens[$tokens[$i]['code']]) === true
) {
continue;
}

if ($tokens[$i]['code'] !== T_WHITESPACE) {
$foundIndent = 0;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ $i < 10;
$i++;
) {
}

if (
foo(
'this
is a
string',
<<<EOD
foobar!
EOD
)
) {
return;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,16 @@ for (
$i++;
) {
}

if (
foo(
'this
is a
string',
<<<EOD
foobar!
EOD
)
) {
return;
}

0 comments on commit 50a20de

Please sign in to comment.