-
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
PSR12 standard reports errors for multi-line FOR definitions #2763
Comments
@andre-exads Could you share the ruleset configuration you are using ? Or at the very least, please check that your ruleset does not include both |
I'm not using phpcs file of any kind in my project (when I tried it was an even bigger mess) I only have the following setting on VScode settings.json: "phpcs.standard": "PSR12", But if I run it straight from the command line I have the same result: phpcs --standard=PSR12 /full/path/to/code/file.php
FILE: /full/path/to/code/file.php
--------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------
236 | ERROR | [x] Expected 1 space after first semicolon of FOR loop; newline found
237 | ERROR | [x] Expected 1 space after second semicolon of FOR loop; newline found
--------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------
Time: 105ms; Memory: 8MB I'm on Fedora Workstation 31 - |
…finitions This was done by adding a new ignoreNewlines property to Squiz.ControlStructures.ForLoopDeclaration so that the PSR12 standard could use it. In the case of newlines, PSR12 should ignore the statement and let other sniffs enforce the multi-line rules. But when there is no newline, it needs this sniff to enforce a single space.
I've committed a fix for this, which will be in 3.5.4. The solution required a new Thanks for reporting this. |
Current PSR-12 configuration on CodeSniffer treat multi-line conditions in a for loop as incorrect, but according to https://www.php-fig.org/psr/psr-12/#54-for it is allowed. Example bellow.
The text was updated successfully, but these errors were encountered: