Skip to content

Commit 0d964bc

Browse files
Clarify closing identifier indentation behaviour of Heredoc (#5763)
1 parent 36d18e7 commit 0d964bc

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

language/types/string.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ echo 'Variables do not $expand $either', PHP_EOL;
216216
</simpara>
217217

218218
<simpara>
219-
The closing identifier may be indented by space or tab, in which case
220-
the indentation will be stripped from all lines in the doc string.
219+
The closing identifier may be indented with spaces or tabs. Whitespace
220+
equal to the closing identifier's indentation is then removed from the
221+
beginning of every line in the heredoc string.
221222
Prior to PHP 7.3.0, the closing identifier <emphasis>must</emphasis>
222223
begin in the first column of the line.
223224
</simpara>
@@ -233,20 +234,20 @@ echo 'Variables do not $expand $either', PHP_EOL;
233234
<programlisting role="php">
234235
<![CDATA[
235236
<?php
236-
// no indentation
237+
// closing identifier not indented
237238
echo <<<END
238239
a
239240
b
240241
c
241242
\n
242243
END;
243244
244-
// 4 spaces of indentation
245+
// closing identifier indented with 3 spaces; 3 spaces stripped from each line
245246
echo <<<END
246247
a
247248
b
248249
c
249-
END;
250+
END;
250251
]]>
251252
</programlisting>
252253
&example.outputs.73;
@@ -256,9 +257,9 @@ echo <<<END
256257
b
257258
c
258259
259-
a
260-
b
261-
c
260+
a
261+
b
262+
c
262263
]]>
263264
</screen>
264265
</example>

0 commit comments

Comments
 (0)