-
Notifications
You must be signed in to change notification settings - Fork 28
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
One line if statement #159
Comments
Hi @PrinceOfAbyss , good morning. The closests to what you need would be excluding the filter "AddMissingCurlyBraces". But it'll affect all of your code. There's no rule "AddMissingCurlyBracesIfConditionOnSameLine". |
Would you consider adding a setting for that @driade ? |
Hello @PrinceOfAbyss At this time there are no plans to add more rules to this extension, except for bug fixes and ensuring that the existing rules continue to work with new versions of PHP. Best regards. |
Fair enough @driade ! I tried your suggestion and indeed it works exactly as I wanted it to. I mean, if I put the if() expression and a single statement in the same line, it formats it as it should. Then, if I add curly braces around the statement, again it formats it as it should! The only problem would be for someone who forgets to put curly braces around multiple statement if()'s, but that's not a problem for me, I always use them in such cases. So all in all, it's doing my work exactly as I wanted it to. Thanks a lot for your support! |
Hello. Is there an option to set phpfmt to exclude the one-liner if statements from formatting with braces?
I know it's a bad practice to do
and I always use curly braces in my code in such cases, but there are specific cases, where for simplicity I'd like to be able to write one-liner if statements, ie.
if ( condition ) return;
orif ( condition ) break;
It's so much easily readable (at least I'm used to it) and really saves space to be able to "evade" the whole braces formatting when putting the if condition and the code to execute in the same line.
The text was updated successfully, but these errors were encountered: