-
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
Generic.ControlStructures.InlineControlStructure confused by mixed short/long tags #2565
Comments
This is probably due to that second PHP block using short open tags. PHPCS is probably being told it is inline HTML by the PHP tokenizer, so the closing tag of the IF statement is never found. So to PHPCS it looks like a syntax error. |
I've updated the description to reflect new findings. Nonetheless, that's probably not related to the short tags, at least not in the way you mentioned. PHPCS has sniffers for that, and if you remove |
Updated to 3.4.2 and the issue is exactly the same. |
@igorsantos07 Actually it is. Sniffs work independently of each other and as you will see if you use The system on which you are running PHPCS must be configured with I think the bug fix which is needed here, is for the |
Correct, sometime later I noticed another issue, but that time with an entire class file and phpcs reported it could be a I'm not sure what to say here. How should phpcs behave when the code is incomplete? I guess we can simply ignore the fact it was complaining about something weird (inline control structures are forbidden), because in fact the rest of the code was "missing"? Not to mention it's definitely "funny" what it did with the |
Generally speaking, PHPCS will bow out and not report anything or, at the very least, not try to auto-fix code if it doesn't find the tokens which are expected, as this normally indicates that PHPCS is run during live coding or that there is a parse error. That way the fixer won't accidentally introduce (additional) syntax errors.
|
@igorsantos07 PR #2567 should fix this by bowing out in the precise situation you found yourself in. Hope it helps ;-) |
Example:
CLI output (reduced for brevity):
Resulting "fixed" file:
As can be seen in the
false
if's, using<?php
or<?
on both lines do not trigger the phpcs error. I'm not so sure whatInlineControlStructure
means in those cases (maybe the humanized message doesn't make much sense for those cases?), but we can say for sure thatphpcbf
got lost with the alt-syntax and nuts with the bracketed one 😂That's for versions 3.3.2/3.4.2 at PHP 7.2.20.
The text was updated successfully, but these errors were encountered: