Req #76609 [Wfx]: Flexible heredocs should not have special indentation rules

From: Date: Wed, 11 Jul 2018 18:25:15 +0000
Subject: Req #76609 [Wfx]: Flexible heredocs should not have special indentation rules
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216279@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76609&edit=1 ID: 76609 User updated by: mattacosta at gmail dot com Reported by: mattacosta at gmail dot com Summary: Flexible heredocs should not have special indentation rules Status: Wont fix Type: Feature/Change Request Package: *General Issues PHP Version: 7.3.0alpha3 Block user comment: N Private report: N New Comment: > Personally I'd be open to relax this restriction, but you'll need to bring this up on > the internals list. Sigh, fair enough. This just feels like an overlooked scenario that's definitely in line with the goal of avoiding "the current situation of having indentation levels ruined by these syntaxes". > As long as the indentation is always the same (and we thus don't run into the question of > "what width is a tab character?") we at least have no technical reason to disallow this. Yeah, a tab in the text would be same width as a tab before the end label so that shouldn't be a problem. Previous Comments: ------------------------------------------------------------------------ [2018-07-11 09:54:23] nikic@php.net Personally I'd be open to relax this restriction, but you'll need to bring this up on the internals list. As long as the indentation is always the same (and we thus don't run into the question of "what width is a tab character?") we at least have no technical reason to disallow this. ------------------------------------------------------------------------ [2018-07-11 03:31:41] requinix@php.net Flexible heredocs was thoroughly discussed. https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes > These [unmixed whitespace] constraints have been included because mixing tabs and spaces for > indentation is > harmful to legibility. ------------------------------------------------------------------------ [2018-07-11 03:24:04] mattacosta at gmail dot com Description: ------------ Flexible heredocs require that indentation only consist of spaces or tabs, but not both. This could be a problem for code embedded in other files. Instead of requiring that the indentation exactly match the indentation prior to the end label *and* not have mixed whitespace, it should just exactly match the indentation. Generally speaking, the language shouldn't decide what indentation is good or bad either. The user should. Test script: --------------- <!-- This would be aligned if the tab size were 4 instead of 8. --> <html> <body text="<?= <<<LABEL 3 tabs and 2 spaces LABEL?>" attr="hello-world"> </body> </html> Expected result: ---------------- <!-- Mixed or not this would be the same. --> <html> <body text="3 tabs and 2 spaces" attr="hello-world"> </body> </html> Actual result: -------------- Parse error: Invalid indentation - tabs and spaces cannot be mixed ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76609&edit=1

« previous php.bugs (#216279) next »