Dmitry Leiko
Dmitry Leiko

Reputation: 4372

PSR-12 if statement

Can I use if statement like:

if (!true) {
    return false
}

Or something like this:

if (! true) {
    return false
}

Upvotes: 0

Views: 1504

Answers (1)

PatNowak
PatNowak

Reputation: 5812

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.

Upvotes: 3

Related Questions