Re: Parse error: Invalid body indentation level
| From: | Rasmus Schultz | Date: | Mon, 28 May 2018 16:56:18 +0000 |
| Subject: | Re: Parse error: Invalid body indentation level | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102150@lists.php.net to get a copy of this message | ||
> > Yes, this is an expected result under the flexible heredoc RFC. To avoid
> > issues, please use a heredoc label that does not occur within the string.
>
> Hmkay, so code that worked fine with PHP 7.1 and PHP 7.2 breaks with PHP
> 7.3. This breaking change should at least be prominently documented. As of
> right now, I do not see such documentation in UPGRADING.
Wow, I can't believe I didn't think of this when I reviewed that RFC.
This is potentially a pretty serious BC break, really - at least in two cases:
1. Markdown, where indentation can be irregular as well as meaningful.
2. Failing tests!
The latter could prove rather difficult - getting your tests to pass
under 7.2 and 7.3+ might be far from simple, and at the very least
would require test-helpers that conditionally treat whitespace
differently for 7.3+ and earlier versions.
Even inline HTML could potentially suffer, if you have <pre> blocks.
And on top of these unexpected results and test-failures, of course
there may be parse errors for inline content with meaningful
whitespace that was (or wasn't) indented correctly.
Honestly, are there any cases where existing code *benefits* from
changing the existing syntax/feature?
Some people indent inline blocks so that the output ends up with the
desired indentation, rather than the source-code looking pretty - in
those cases, whitespace will now be silently removed and the output no
longer as desired?
Are we positive it wouldn't be safer to just introduce a slight syntax
variation for blocks that treat indentation differently?
(am I blowing this out of proportion?)