Просмотр исходного кода

bug: Fixed line between general script documentation and require (#7177)

Rauno Moisto 1 год назад
Родитель
Сommit
a27c4fc486

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

@@ -71,7 +71,11 @@ class Bar {}
             T_DECLARE,
             T_DECLARE,
             T_DOC_COMMENT,
             T_DOC_COMMENT,
             T_GOTO,
             T_GOTO,
+            T_INCLUDE,
+            T_INCLUDE_ONCE,
             T_NAMESPACE,
             T_NAMESPACE,
+            T_REQUIRE,
+            T_REQUIRE_ONCE,
             T_RETURN,
             T_RETURN,
             T_THROW,
             T_THROW,
             T_USE,
             T_USE,

+ 52 - 1
tests/Fixer/Phpdoc/NoBlankLinesAfterPhpdocFixerTest.php

@@ -132,7 +132,7 @@ EOF;
         $this->doTest($input);
         $this->doTest($input);
     }
     }
 
 
-    public function testLineBeforeDeclareIsNotBeRemoved(): void
+    public function testLineBeforeDeclareIsNotRemoved(): void
     {
     {
         $expected = <<<'EOF'
         $expected = <<<'EOF'
 <?php
 <?php
@@ -160,6 +160,57 @@ EOF;
         $this->doTest($expected);
         $this->doTest($expected);
     }
     }
 
 
+    /**
+     * @dataProvider provideLineBeforeIncludeOrRequireIsNotRemovedCases
+     */
+    public function testLineBeforeIncludeOrRequireIsNotRemoved(string $expected, ?string $input = null): void
+    {
+        $this->doTest($expected, $input);
+    }
+
+    public static function provideLineBeforeIncludeOrRequireIsNotRemovedCases(): iterable
+    {
+        yield [<<<'EOF'
+<?php
+/**
+ * This describes what my script does.
+ */
+
+include 'vendor/autoload.php';
+EOF
+        ];
+
+        yield [<<<'EOF'
+<?php
+/**
+ * This describes what my script does.
+ */
+
+include_once 'vendor/autoload.php';
+EOF
+        ];
+
+        yield [<<<'EOF'
+<?php
+/**
+ * This describes what my script does.
+ */
+
+require 'vendor/autoload.php';
+EOF
+        ];
+
+        yield [<<<'EOF'
+<?php
+/**
+ * This describes what my script does.
+ */
+
+require_once 'vendor/autoload.php';
+EOF
+        ];
+    }
+
     public function testLineWithSpacesIsRemovedWhenNextTokenIsIndented(): void
     public function testLineWithSpacesIsRemovedWhenNextTokenIsIndented(): void
     {
     {
         $this->doTest(
         $this->doTest(