-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Does WPCS do php -l as well? #522
Comments
No. PHPCS doesn't explicitly check for syntax errors. There are times when a sniff may detect some tokens that it thinks are invalid, and sometimes the sniff will flag these with an error. But it doesn't intentionally run a syntax check. That's what |
👍 I run |
Thanks. Out of curiosity, might this be a feature worth considering? Seems like the # 1 rule for WPCS should be "Make sure code is valid". :) |
Yes, but this would be an issue to introduce upstream in the PHPCS project itself: https://github.com/squizlabs/PHP_CodeSniffer Nevertheless, since the project specifically calls out the use of |
It really isn't something that WPCS can do efficiently, because PHPCS doesn't actually parse/execute the code. It would be a lot of work to make a hammer do the job of a screw driver—when we already have a screw driver ( WPCS is just one tool in your arsenal. The wp-dev-lib repo that @westonruter is a great example of how you can use it along with many others to run a variety of different types of checks on your code. Syntax checking is one check, coding standards is another. |
IIRC, it has already been suggested on several occasions, and rejected. PHPCS strives not to blow up when handed malformed code, but it doesn't try to catch every syntax error either. |
FYI: there is actually a sniff upstream available which will run the parser over the file. Not sure how well it works, but could be worth looking into ? Link: |
@jrfnl looks like it is just a wrapper for calling |
Just curious if it will catch broken PHP as well.
The text was updated successfully, but these errors were encountered: