Skip to content

Commit

Permalink
Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue afte…
Browse files Browse the repository at this point in the history
…r NOWDOC

Stopping at the end of a here/nowdoc when finding the start of a statement isn't correct.
These token have openers/closers to help sniff developers, but they are still strings
and should be skipped over in the same way.
  • Loading branch information
gsherwood committed Aug 20, 2020
1 parent 913acfe commit ce1cd52
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,8 @@ public function findStartOfStatement($start, $ignore=null)
if (isset($this->tokens[$i]['scope_opener']) === true
&& $i === $this->tokens[$i]['scope_closer']
&& $this->tokens[$i]['code'] !== T_CLOSE_PARENTHESIS
&& $this->tokens[$i]['code'] !== T_END_NOWDOC
&& $this->tokens[$i]['code'] !== T_END_HEREDOC
) {
// Found the end of the previous scope block.
return $lastNotEmpty;
Expand Down
16 changes: 16 additions & 0 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,22 @@ return [
]),
];

return [
'lor' =>
<<<'INTRO'
lorem ipsum
INTRO,
'em' => [
[
'',
],
],
'abc' => [
'a' => 'wop wop',
'b' => 'ola ola.',
],
];

?>

<?php if (true) : ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,22 @@ return [
]),
];

return [
'lor' =>
<<<'INTRO'
lorem ipsum
INTRO,
'em' => [
[
'',
],
],
'abc' => [
'a' => 'wop wop',
'b' => 'ola ola.',
],
];

?>

<?php if (true) : ?>
Expand Down
16 changes: 16 additions & 0 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,22 @@ return [
]),
];

return [
'lor' =>
<<<'INTRO'
lorem ipsum
INTRO,
'em' => [
[
'',
],
],
'abc' => [
'a' => 'wop wop',
'b' => 'ola ola.',
],
];

?>

<?php if (true) : ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,22 @@ return [
]),
];

return [
'lor' =>
<<<'INTRO'
lorem ipsum
INTRO,
'em' => [
[
'',
],
],
'abc' => [
'a' => 'wop wop',
'b' => 'ola ola.',
],
];

?>

<?php if (true) : ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
1340 => 1,
1342 => 1,
1345 => 1,
1464 => 1,
1465 => 1,
1466 => 1,
1467 => 1,
1480 => 1,
1481 => 1,
1482 => 1,
1483 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit ce1cd52

Please sign in to comment.