-
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
Space after brace and PSR-2 #347
Comments
Could you please attach (maybe in gist form) complete file, because I suspect something around that code might be affecting the final shown error. |
I pushed it here: https://github.com/Jumashev/test/blob/master/ChecklistController.php (no editing, just copied from one repo to another) |
Specifically this bit:
PSR-2 requires a single space between the closing brace of the IF and the ELSE keyword. You need to write it like this: if (...) {
// code here
} else {
// code here
} In your code, the else keyword is on the line following the brace, not on the same line, hence the error message mentioning that newline it found. Does this clear things up? |
Feel ashamed, so sorry for inconvenience :) But if i would like not to strictly follow the PSR-2 - is there any chance to add there some exclusions to CS like as for this case? Thank you! |
@jumashev that's where custom rulesets comes in. In there you can extend existing standards by adding/removing/tuning their sniffs or even completely create own standard. |
Great! Thank you! |
These docs might help you get started: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml |
…-up-use-statements CS: clean up use statements
Found a strange error in Jenkins
So i didn't found a word in PSR-2 about needing a space before newline. Maybe there's a bug that CS does not tract newline as a space?
The text was updated successfully, but these errors were encountered: