Fork me on GitHub
a Sensio Labs Product

I ate three cookies πŸͺ (v3.40.2) edition

Rule simplified_if_returnΒΆ

Simplify if control structures that return the boolean result of their condition.

ExamplesΒΆ

Example #1ΒΆ

--- Original
+++ New
 <?php
-if ($foo) { return true; } return false;
+return (bool) ($foo)      ;

Source classΒΆ

PhpCsFixer\Fixer\ControlStructure\SimplifiedIfReturnFixer