Re: Adding new closing tag =?> for keeping trailing newline
| From: | Guilliam Xavier | Date: | Wed, 08 Jun 2022 15:28:52 +0000 |
| Subject: | Re: Adding new closing tag =?> for keeping trailing newline | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117876@lists.php.net to get a copy of this message | ||
> Declare statements shouldn't have any impact outside of the file in which
> they appear. Declaring strict types doesn't force other classes that
> interact with the defined class to also use strict types. A declare to
> change how newlines after closing tags are handled within a single file
> forces anything that uses the classes/functions defined in that file to
> know that it handles them in a possibly different ways.
Indeed (via includes)... Also consider this hypothetical example:
```
- 0
<?php foreach([1, 2, 3] as $item): ?>
- <?= $item =?>
<?php endforeach; ?>
- 4
```
Note the use of both ?> and =?> *within the same file*; a declare
would not allow that.
> I personally don't see a need for a new closing tag. I'm not usually swayed
> by the "it adds confusion to the language" and would be against removing
> such a tag if it existed and that was the reason for removing it. However,
> I do think it's something to consider when adding something new to the
> language. In this case, I don't think the positives outweigh the negatives,
> especially in light of the fact it's really easy to accomplish this without
> changes.
I personally am generally in favor of removing "magic" stuff (even if
this isn't exactly proposing that but to add a "straightforward"
alternative).
Other example, consider starting from this:
```
- first
- foo bar
- last
```
Now if you want to "variablize" the
foo part, just change it to e.g.
<?= $foo ?>; but for bar you have to remember and write e.g. `<?=
$bar, PHP_EOL ?>` (or add a blank line after it [or a trailing
space... no, please don't]), only because it happens to be at the end
of a line (and don't forget to re-change it if you later append a
qux)...
PS: An[other] argument against could be something like "please don't
add more things encouraging the use of PHP as a templating engine
(unsafe etc.)", but the main target is *non*-HTML (e.g. Markdown or
raw text) templates.
--
Guilliam Xavier