Skip to content

Commit

Permalink
ReferencedNameHelper: Fixed searching of class references in heredoc
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Mar 1, 2022
1 parent c1d5942 commit bef66a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions SlevomatCodingStandard/Helpers/ReferencedNameHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private static function createAllReferencedNames(File $phpcsFile, int $openTagPo
$beginSearchAtPointer = $openTagPointer + 1;
$nameTokenCodes = TokenHelper::getNameTokenCodes();
$nameTokenCodes[] = T_DOUBLE_QUOTED_STRING;
$nameTokenCodes[] = T_HEREDOC;

$tokens = $phpcsFile->getTokens();
while (true) {
Expand Down
1 change: 1 addition & 0 deletions tests/Helpers/ReferencedNameHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function testGetAllReferencedNames(): void
['STR_PAD_RIGHT', false, true],
['EnumType', false, false],
['UrlGeneratorInterface', false, false],
['ClassInHeredoc', false, false],
['ClassInDoubleQuote', false, false],
];

Expand Down
4 changes: 4 additions & 0 deletions tests/Helpers/data/lotsOfReferencedNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ public function generateRoute($router): string
}
}

<<<XML
<string>Hello world and {$this->wrap(ClassInHeredoc::EXAMPLE)}</string>
XML;

"foo {$db->quote(ClassInDoubleQuote::SOME_CONSTANT)}";
"foo $db->quote(FakeClassInDoubleQuote::SOME_CONSTANT)";

Expand Down

0 comments on commit bef66a4

Please sign in to comment.