Skip to content

Commit 520e931

Browse files
committed
bug #4996 NoEmptyCommentFixer - handle multiline comments (kubawerlos)
This PR was squashed before being merged into the 2.15 branch (closes #4996). Discussion ---------- NoEmptyCommentFixer - handle multiline comments Commits ------- f83dc08 NoEmptyCommentFixer - handle multiline comments
2 parents 83a4ac3 + f83dc08 commit 520e931

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Fixer/Comment/NoEmptyCommentFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function isEmptyComment($content)
157157
{
158158
static $mapper = [
159159
self::TYPE_HASH => '|^#\s*$|', // single line comment starting with '#'
160-
self::TYPE_SLASH_ASTERISK => '|^/\*\s*\*/$|', // comment starting with '/*' and ending with '*/' (but not a PHPDoc)
160+
self::TYPE_SLASH_ASTERISK => '|^/\*[\s\*]*\*+/$|', // comment starting with '/*' and ending with '*/' (but not a PHPDoc)
161161
self::TYPE_DOUBLE_SLASH => '|^//\s*$|', // single line comment starting with '//'
162162
];
163163

tests/Fixer/Comment/NoEmptyCommentFixerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,26 @@ public function provideFixCases()
212212
$bar = 2;
213213
',
214214
],
215+
[
216+
'<?php
217+
'.'
218+
',
219+
'<?php
220+
/*
221+
*
222+
*/
223+
',
224+
],
225+
[
226+
'<?php
227+
'.'
228+
',
229+
'<?php
230+
/********
231+
*
232+
********/
233+
',
234+
],
215235
];
216236
}
217237

0 commit comments

Comments
 (0)