Skip to content

Commit 40d5991

Browse files
committed
NoCommentedOutCodeFixer - fix handling empty comment
1 parent c5414f4 commit 40d5991

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Fixer/NoCommentedOutCodeFixer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ private function getIndicesToRemove(Tokens $tokens, array $commentIndices): arra
7676
$content .= PHP_EOL . $this->getMessage($tokens[$index]->getContent());
7777
$testedIndices[] = $index;
7878

79+
if (\strlen(\rtrim($content)) === 5) {
80+
continue;
81+
}
82+
7983
try {
8084
@Tokens::fromCode($content);
8185
} catch (\ParseError $error) {

tests/Fixer/NoCommentedOutCodeFixerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ public function provideFixCases(): \Generator
4747
];
4848

4949
yield [
50-
'<?php ',
51-
'<?php //',
50+
'<?php
51+
// To foo
52+
//
53+
// or not to foo?
54+
',
5255
];
5356

5457
yield ['<?php // var_dump("no semicolon after")'];

0 commit comments

Comments
 (0)