-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
semicolons in short echo tags #609
Comments
@joemaller Hm, interesting, php require |
It should be very easy, but let's wait what says other |
I don't recommend using an option for this, because we agreed that options are only for very rare cases where
While (1) seems to be the case here, (2) and (3) probably aren't. My feeling is also that the "community standard" is having no semicolons in short echo tags - if anyone has a different feeling we could collect some data of popular open source projects. |
...quieter than I'd hoped. I think reasonable next step would be collecting examples of short-echo tag usage, to establish that there is in fact a community standard, even though that usage pattern is not formally declared and hasn't yet been recognized in a PSR. |
Semicolons in PHP Short Echo TagsDespite the short-echo syntax having been supported by default since PHP 5.4 was released back in 2012 (EOL 2015), it's difficult to find clear guidance about best practices. Most often, information is confounded with older advice about avoiding short-open tags ( Examples are difficult to find since random snippets of non-alphanumeric syntax like PHP DocumentationThe Official PHP documentation omits semicolons from short-echo examples:
More from the PHP docs on implied semicolons:
Stack Overflow
CakePHPShort echo is recommended in CakePHP template contexts, no semicolons: // wrong = semicolon, no spaces
<td><?=$name;?></td>
// good = spaces, no semicolon
<td><?= $name ?></td> WordPressWordPress still supports PHP versions back to 5.2.4, so they discourage short-echo tags. However, their coding standards example omits semicolons: Miscellaneous examples
|
💯 I'd say that's enough evidence to justify omitting semicolons in our output. |
Agreed. Even though I always include them in my own code, I think it's clear that omitting them seems to be much more common. |
We avoid |
Has there been any discussion about semicolons in short echo tags?
Using dev builds, this:
Changes to this (added semicolon):
Nearly every PHP short echo tag example I found omits semicolons. Because short echo tags are usually found in template contexts, the less-verbose the better.
There don't appear to be any PSR recommendations about this, though the CakePHP project (the only big-project guidance I could find) recommends omitting short echo tag semicolons:
If short echo tag semicolons are the way Prettier-PHP is going, I'd like to start moving my code in that direction. If short echo tag semicolons are under discussion or being considered as an option, I vote for omitting them.
The text was updated successfully, but these errors were encountered: