We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've seen in a few places we have code like this:
return $foo ? true : false;
The ternary here is redundant and is actually just casting the variable to a boolean. Using an actual cast is cleaner:
return (bool) $foo;
(The reverse is true as well, return $foo ? false : true; can be replaced with return ! $foo)
return $foo ? false : true;
return ! $foo
The text was updated successfully, but these errors were encountered:
Is there a PHPCS sniff for this? @rmccue to investigate. I'm 👍 on the change proposed here
Sorry, something went wrong.
Neither PHPCS nor WP have a sniff for this.
Also nothing in the wider market :( Let's move to backlog; it's nice, but would require some custom work, so someday...
tfrommen
No branches or pull requests
I've seen in a few places we have code like this:
The ternary here is redundant and is actually just casting the variable to a boolean. Using an actual cast is cleaner:
(The reverse is true as well,
return $foo ? false : true;
can be replaced withreturn ! $foo
)The text was updated successfully, but these errors were encountered: