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

[Implement sniff] No PHP short tags #2

Closed
2 tasks done
jrfnl opened this issue Jul 10, 2016 · 3 comments
Closed
2 tasks done

[Implement sniff] No PHP short tags #2

jrfnl opened this issue Jul 10, 2016 · 3 comments

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Jul 10, 2016

Rule:

No short open tags allowed.

Ref: https://make.wordpress.org/themes/handbook/review/required/theme-check-plugin/#additional-checks

Theme check file covering this rule:

https://github.com/Otto42/theme-check/blob/master/checks/phpshort.php

Decision needed by Theme Review Board:

In the Theme Check plugin, this rule currently generates a warning and the rule is not mentioned on the Theme Review Requirements page.

The existing PHPCS sniff implementation for this - Generic.PHP.DisallowShortOpenTag - generates an error. If this should be a warning, either a PR needs to be submitted upstream to PHPCS to allow for changing the error level or alternatively the existing sniff would need to be extended/copied to a WP specific sniff which would do the same, but generate a warning instead of an error.

Advice: As short open tags have been removed in PHP 7, I would suggest making this rule a requirement and raising the error level to error instead of warning.

To do:

  • If agreed this should be an error - add existing Generic.PHP.DisallowShortOpenTag sniff to the ruleset.
  • Add the rule in the Theme Review handbook to the Requirements page.
@grappler
Copy link
Member

@grappler
Copy link
Member

I just ran the sniff phpcs --standard=WordPress-Theme * on a theme and it returned an error for .MD and .jpg files which does not make sense.

@jrfnl
Copy link
Contributor Author

jrfnl commented Jul 16, 2016

Interesting. As far as I know, by default, PHPCS runs on PHP, JS and CSS files. Nothing else. (according to the docs)
Would need to look into what's going there.

[Edit] Actually had a look at more detailed docs and it's more like, it presumes every file is PHP unless you tell it otherwise.

I can add a list of file patterns to exclude from the sniffs, but would need input what extensions should be excluded.
I'm currently thinking:
*.jpeg, *.jpg, *.png, *.gif, *.swf, .htaccess, *.pot, *.po, *.mo, *.ttf, *.eof, *.svg, *.woff, *.txt, *.md

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

No branches or pull requests

2 participants