Fork me on GitHub
a Sensio Labs Product

Space Sets (v3.64.0) edition

Rule heredoc_indentation

Heredoc/nowdoc content must be properly indented.

Configuration

indentation

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

Allowed values: 'same_as_start' and 'start_plus_one'

Default value: 'start_plus_one'

Examples

Example #1

Default configuration.

--- Original
+++ New
 <?php
     $heredoc = <<<EOD
-abc
-    def
-EOD;
+        abc
+            def
+        EOD;

     $nowdoc = <<<'EOD'
-abc
-    def
-EOD;
+        abc
+            def
+        EOD;

Example #2

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

--- Original
+++ New
 <?php
     $nowdoc = <<<'EOD'
-abc
-    def
-EOD;
+    abc
+        def
+    EOD;

Rule sets

The rule is part of the following rule sets:

References

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.