Skip to content

Commit 5d50e4c

Browse files
author
Thibaud Fabre
committed
Improve new line replace algo
1 parent 481963f commit 5d50e4c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Aztech/Sniffs/Formatting/NoConsecutiveBlankLinesSniff.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
3232
$buffer .= str_replace(' ', '', $token['content']);
3333

3434
if (strpos($buffer, PHP_EOL . PHP_EOL . PHP_EOL) !== false) {
35-
$error = 'There should be no consecutive blank lines';
35+
$error = 'There must be no consecutive blank lines';
3636
$phpcsFile->addError($error, $ptr, 'ConsecutiveBlankLines');
3737

38-
$buffer = str_replace(PHP_EOL . PHP_EOL . PHP_EOL, PHP_EOL, $buffer);
38+
while (strpos($buffer, PHP_EOL . PHP_EOL . PHP_EOL) !== false) {
39+
$buffer = str_replace(PHP_EOL . PHP_EOL . PHP_EOL, PHP_EOL . PHP_EOL, $buffer);
40+
}
3941
}
4042
}
4143
}

0 commit comments

Comments
 (0)