Skip to content

Commit

Permalink
Allow comments between body and condition in do while loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
ht-bs committed Aug 3, 2017
1 parent 30cabe0 commit a666b15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function process(File $phpcsFile, $stackPtr)

if ($tokens[$stackPtr]['code'] === T_WHILE) {
// This could be from a DO WHILE, which doesn't have an opening brace.
$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
$lastContent = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
$brace = $tokens[$lastContent];
if (isset($brace['scope_condition']) === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,9 @@ if (true)
}
catch(Exception $e) {
}

do {
$i++;
}
// Comment
while ($i < 10);
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,9 @@ if (true) {
catch(Exception $e) {
}
}

do {
$i++;
}
// Comment
while ($i < 10);

0 comments on commit a666b15

Please sign in to comment.