Skip to content

Commit

Permalink
PSR2/UseDeclaration: allow the fixer to function correctly with vario…
Browse files Browse the repository at this point in the history
…us combinations of comments
  • Loading branch information
jrfnl committed Feb 17, 2018
1 parent bd96102 commit 1530543
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ public function process(File $phpcsFile, $stackPtr)

--$end;

if (($tokens[$end]['code'] === T_COMMENT
|| isset(Tokens::$phpcsCommentTokens[$tokens[$end]['code']]) === true)
&& substr($tokens[$end]['content'], 0, 2) === '/*'
&& substr($tokens[$end]['content'], -2) !== '*/'
) {
// Multi-line block comments are not allowed as trailing comment after a use statement.
--$end;
}

$next = $phpcsFile->findNext(T_WHITESPACE, ($end + 1), null, true);

if ($next === false || $tokens[$next]['code'] === T_CLOSE_TAG) {
Expand Down

0 comments on commit 1530543

Please sign in to comment.