Run Rector on your code to see what it can do for you:

 {
     public function undefinedVarAfter()
     {
-        if ($a = $this->methodX()) {
-            $this->out = $a;
-        } else {
-            $this->out = $this->methodY();
-        }
+        $this->out = $a = $this->methodX() ? $a : $this->methodY();
     }
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: b09565 - released at 2026-05-25 06:37