Browse Source

When followed directly by a use declaration, the PhpDoc is most likely a file-level documentation block. Do not strip the newline after the documentation block in that case.

Robbert Schreuder Hes 5 years ago
parent
commit
10c9ec63bc

+ 1 - 0
src/Fixer/Phpdoc/NoBlankLinesAfterPhpdocFixer.php

@@ -79,6 +79,7 @@ class Bar {}
             T_CONTINUE,
             T_BREAK,
             T_DECLARE,
+            T_USE,
         ];
 
         foreach ($tokens as $index => $token) {

+ 14 - 0
tests/Fixer/Phpdoc/NoBlankLinesAfterPhpdocFixerTest.php

@@ -144,6 +144,20 @@ EOF;
         $this->doTest($expected);
     }
 
+    public function testLineBeforeUseStatementIsNotRemoved()
+    {
+        $expected = <<<'EOF'
+<?php
+/**
+ * This is some license header.
+ */
+
+use Foo\Bar;
+EOF;
+
+        $this->doTest($expected);
+    }
+
     public function testLineWithSpacesIsRemovedWhenNextTokenIsIndented()
     {
         $this->doTest(