Browse Source

Merge branch 'master' into 3.0

Dariusz Ruminski 7 years ago
parent
commit
1d78ba93f5

+ 2 - 1
src/Fixer/Comment/SingleLineCommentStyleFixer.php

@@ -116,7 +116,8 @@ $c = 3;
             }
 
             $content = $token->getContent();
-            $commentContent = substr($content, 2, -2);
+            $commentContent = substr($content, 2, -2) ?: '';
+
             if ($this->hashEnabled && '#' === $content[0]) {
                 $tokens[$index] = new Token([$token->getId(), '//'.substr($content, 1)]);
 

+ 8 - 1
tests/Fixer/Comment/SingleLineCommentStyleFixerTest.php

@@ -149,7 +149,14 @@ $a = 1; /* after code */
 s    *
      */',
             ],
-
+            'empty comment' => [
+                '<?php
+//
+',
+                '<?php
+/**/
+',
+            ],
             // Untouched cases
             [
                 '<?php