-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Flag for allowing short echo tags #2045
Comments
The easiest way to do this is to exclude that specific error message. The short echo and short open error messages have different codes, so you can do this in your ruleset: <rule ref="Generic.PHP.DisallowShortOpenTag"/>
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound"/> That includes the sniff as normal, but then excludes the specific error message that complains when short echos are found. It will still report errors for short open tags as they use the Does that do what you're after? |
@gsherwood Thanks for the response. I'd completely overlooked the different error code. |
I'm going to close this issue then since it seems like we have what we need. Thanks for the response! |
* Take advantage of PHP 5.4+ short echo https://php.net/migration54.new-features thanks to #2495 Use `<?= ?>` instead of `<?php echo; ?>` 10kB of code saved :-) Done with regular expression: ``` <\?php echo (.+?);? *\?> <?= \1 ?> ``` * Try Travis fix squizlabs/PHP_CodeSniffer#2045 (comment)
* Take advantage of PHP 5.4+ short echo https://php.net/migration54.new-features thanks to FreshRSS#2495 Use `<?= ?>` instead of `<?php echo; ?>` 10kB of code saved :-) Done with regular expression: ``` <\?php echo (.+?);? *\?> <?= \1 ?> ``` * Try Travis fix squizlabs/PHP_CodeSniffer#2045 (comment)
In my case the above did not work. I think in the latest version, there is another syntax.
My version is: PHP_CodeSniffer version 3.7.2 (stable) by Squiz |
This is a request from the WordPress themes codesniffer, which is an extension of this project. See original ticket: WPTT/WPThemeReview#142
Essentially, we want to allow short echo tags (
<?=
), which are always available since PHP 5.4.Reference:
I'm not familiar enough with the code on the project to say exactly what needs to be done, so I'm just going to copy/paste the response from one of the devs on the project:
The text was updated successfully, but these errors were encountered: