Fork me on GitHub
a Sensio Labs Product

7th Gear (v3.59.3) edition

Rule heredoc_closing_marker

Unify heredoc or nowdoc closing marker.

Configuration

closing_marker

Preferred closing marker.

Allowed types: string

Default value: 'EOD'

explicit_heredoc_style

Whether the closing marker should be wrapped in double quotes.

Allowed types: bool

Default value: false

reserved_closing_markers

Reserved closing markers to be kept unchanged.

Allowed types: list<string>

Default value: ['CSS', 'DIFF', 'HTML', 'JS', 'JSON', 'MD', 'PHP', 'PYTHON', 'RST', 'TS', 'SQL', 'XML', 'YAML']

Examples

Example #1

Default configuration.

--- Original
+++ New
-<?php $a = <<<"TEST"
+<?php $a = <<<EOD
 Foo
-TEST;
+EOD;

Example #2

With configuration: ['closing_marker' => 'EOF'].

--- Original
+++ New
-<?php $a = <<<'TEST'
+<?php $a = <<<'EOF'
 Foo
-TEST;
+EOF;

Example #3

With configuration: ['explicit_heredoc_style' => true].

--- Original
+++ New
-<?php $a = <<<EOD
+<?php $a = <<<"EOD"
 Foo
 EOD;

References

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