Open justintadlock opened 6 years ago
@justintadlock I've just looked into this. The current sniff we use - Generic.PHP.DisallowShortOpenTag
- does not allow for an exception easily, however as it is a good sniff, it would be kind of silly to duplicate it.
As the sniff comes from PHPCS itself, I think the best course of action would be to propose a custom property to be added to the sniff which can toggle whether "short open echo" is allowed or not.
If this would be acceptable to PHPCS, I'd happily create the PR for it.
Would you be willing to write up & open the issue yourself in the PHPCS repo please ?
If you can point me to the correct place to post the issue, I'd be happy to create a ticket.
@justintadlock https://github.com/squizlabs/PHP_CodeSniffer/issues/ ;-)
@justintadlock Just saw the upstream issue & Greg's response. I had looked at the sniff, but must have completely overlooked the different error codes. Oh well... at least that means this can be fixed really easily.
Cool. I closed that ticket out.
Should this be added in the ruleset? The
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound"/>
Or should we leave this out? @justintadlock
Short PHP
<?
tags should be disallowed (see: https://github.com/WPTRT/WordPress-Coding-Standards/issues/2). However, as of PHP 5.4, the short echo syntax<?=
is always available. The sniffer should make a distinction between the two.For those of us no longer coding for PHP versions that have reached EOL, it'd be nice to be able to use the short echo syntax, especially within templates.
Here's an example:
Reference: