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

DX: update `HeredocIndentationFixer` code samples (#7197)

Kuba Werłos 1 год назад
Родитель
Сommit
b90b7cd56f

+ 1 - 1
doc/list.rst

@@ -990,7 +990,7 @@ List of Available Rules
    `Source PhpCsFixer\\Fixer\\Comment\\HeaderCommentFixer <./../src/Fixer/Comment/HeaderCommentFixer.php>`_
 -  `heredoc_indentation <./rules/whitespace/heredoc_indentation.rst>`_
 
-   Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.
+   Heredoc/nowdoc content must be properly indented.
 
    Configuration options:
 

+ 1 - 1
doc/rules/index.rst

@@ -866,7 +866,7 @@ Whitespace
   Remove extra spaces in a nullable typehint.
 - `heredoc_indentation <./whitespace/heredoc_indentation.rst>`_
 
-  Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.
+  Heredoc/nowdoc content must be properly indented.
 - `indentation_type <./whitespace/indentation_type.rst>`_
 
   Code MUST use configured indentation type.

+ 5 - 15
doc/rules/whitespace/heredoc_indentation.rst

@@ -2,7 +2,7 @@
 Rule ``heredoc_indentation``
 ============================
 
-Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.
+Heredoc/nowdoc content must be properly indented.
 
 Configuration
 -------------
@@ -30,7 +30,7 @@ Example #1
    --- Original
    +++ New
     <?php
-        $a = <<<EOD
+        $heredoc = <<<EOD
    -abc
    -    def
    -EOD;
@@ -38,17 +38,7 @@ Example #1
    +            def
    +        EOD;
 
-Example #2
-~~~~~~~~~~
-
-*Default* configuration.
-
-.. code-block:: diff
-
-   --- Original
-   +++ New
-    <?php
-        $a = <<<'EOD'
+        $nowdoc = <<<'EOD'
    -abc
    -    def
    -EOD;
@@ -56,7 +46,7 @@ Example #2
    +            def
    +        EOD;
 
-Example #3
+Example #2
 ~~~~~~~~~~
 
 With configuration: ``['indentation' => 'same_as_start']``.
@@ -66,7 +56,7 @@ With configuration: ``['indentation' => 'same_as_start']``.
    --- Original
    +++ New
     <?php
-        $a = <<<'EOD'
+        $nowdoc = <<<'EOD'
    -abc
    -    def
    -EOD;

+ 7 - 18
src/Fixer/Whitespace/HeredocIndentationFixer.php

@@ -20,10 +20,9 @@ use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface;
 use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
 use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
 use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
+use PhpCsFixer\FixerDefinition\CodeSample;
 use PhpCsFixer\FixerDefinition\FixerDefinition;
 use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
-use PhpCsFixer\FixerDefinition\VersionSpecification;
-use PhpCsFixer\FixerDefinition\VersionSpecificCodeSample;
 use PhpCsFixer\Preg;
 use PhpCsFixer\Tokenizer\Analyzer\WhitespacesAnalyzer;
 use PhpCsFixer\Tokenizer\Token;
@@ -37,43 +36,33 @@ final class HeredocIndentationFixer extends AbstractFixer implements Configurabl
     public function getDefinition(): FixerDefinitionInterface
     {
         return new FixerDefinition(
-            'Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.',
+            'Heredoc/nowdoc content must be properly indented.',
             [
-                new VersionSpecificCodeSample(
+                new CodeSample(
                     <<<'SAMPLE'
                         <?php
-                            $a = <<<EOD
+                            $heredoc = <<<EOD
                         abc
                             def
                         EOD;
 
-                        SAMPLE
-                    ,
-                    new VersionSpecification(7_03_00)
-                ),
-                new VersionSpecificCodeSample(
-                    <<<'SAMPLE'
-                        <?php
-                            $a = <<<'EOD'
+                            $nowdoc = <<<'EOD'
                         abc
                             def
                         EOD;
 
                         SAMPLE
-                    ,
-                    new VersionSpecification(7_03_00)
                 ),
-                new VersionSpecificCodeSample(
+                new CodeSample(
                     <<<'SAMPLE'
                         <?php
-                            $a = <<<'EOD'
+                            $nowdoc = <<<'EOD'
                         abc
                             def
                         EOD;
 
                         SAMPLE
                     ,
-                    new VersionSpecification(7_03_00),
                     ['indentation' => 'same_as_start']
                 ),
             ]