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

 
 class Test {
     function method() {
-        $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
+        set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
             if ($file === __FILE__) {
                 throw $signalingException;
             }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: 367edb - released at 2026-01-28 17:10