Skip to content

Latest commit

 

History

History
92 lines (68 loc) · 1.67 KB

heredoc_indentation.rst

File metadata and controls

92 lines (68 loc) · 1.67 KB

Rule heredoc_indentation

Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.

Configuration

indentation

Whether the indentation should be the same as in the start token line or one level more.

Allowed values: 'same_as_start', 'start_plus_one'

Default value: 'start_plus_one'

Examples

Example #1

Default configuration.

--- Original
+++ New
@@ -1,5 +1,5 @@
 <?php
     $a = <<<EOD
-abc
-    def
-EOD;
+        abc
+            def
+        EOD;

Example #2

Default configuration.

--- Original
+++ New
@@ -1,5 +1,5 @@
 <?php
     $a = <<<'EOD'
-abc
-    def
-EOD;
+        abc
+            def
+        EOD;

Example #3

With configuration: ['indentation' => 'same_as_start'].

--- Original
+++ New
@@ -1,5 +1,5 @@
 <?php
     $a = <<<'EOD'
-abc
-    def
-EOD;
+    abc
+        def
+    EOD;

Rule sets

The rule is part of the following rule sets:

@PHP73Migration
Using the @PHP73Migration rule set will enable the heredoc_indentation rule with the default config.
@PHP74Migration
Using the @PHP74Migration rule set will enable the heredoc_indentation rule with the default config.
@PHP80Migration
Using the @PHP80Migration rule set will enable the heredoc_indentation rule with the default config.