PSR-12 if statement

1.2k Views Asked by At

Can I use if statement like:

if (!true) {
    return false
}

Or something like this:

if (! true) {
    return false
}
1

There are 1 best solutions below

1
PatNowak On BEST ANSWER

According to PSR example all conditions in if clauses have no space before or after the expressions. In your case then

if (!true) {
    return false;
}

would be a case. Remember that with short expressions you can always use ternary operator and if you have complex condition to be checked, consider to put it into variable.