Skip to content
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

Allow short PHP echo tags #142

Open
justintadlock opened this issue Mar 10, 2018 · 6 comments
Open

Allow short PHP echo tags #142

justintadlock opened this issue Mar 10, 2018 · 6 comments

Comments

@justintadlock
Copy link

Short PHP <? tags should be disallowed (see: #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:

<?= esc_html( $var ) ?>

// vs.

<?php echo esc_html( $var ) ?>

Reference:

@justintadlock justintadlock changed the title All short PHP echo tags Allow short PHP echo tags Mar 10, 2018
@jrfnl
Copy link
Contributor

jrfnl commented May 31, 2018

@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 ?

@justintadlock
Copy link
Author

If you can point me to the correct place to post the issue, I'd be happy to create a ticket.

@jrfnl
Copy link
Contributor

jrfnl commented Jun 1, 2018

@jrfnl
Copy link
Contributor

jrfnl commented Jun 7, 2018

@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.

@justintadlock
Copy link
Author

Cool. I closed that ticket out.

@dingo-d
Copy link
Member

dingo-d commented May 18, 2019

Should this be added in the ruleset? The

<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound"/>

Or should we leave this out? @justintadlock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants