Skip to content

Add rule to avoid redundant ternaries #154

Description

@rmccue

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions