Boolean Return Simplification¶
This pass checks whether a boolean return value could be simplified:
// Instead of
function foo(A $a) {
if ($a->isValid()) {
return true;
} else {
return false;
}
}
// it will suggest
function foo(A $a) {
return $a->isValid();
}
In the example above, we assumed that $a->isValid()
already returns a boolean.
If that is not the case, it would suggest (boolean) $a->isValid()
instead.