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

 <?php
 
 declare(strict_types=1);
 use RuntimeException;
 use Throwable;
 
-final class ReproException extends RuntimeException
-{
-    public function __construct(
-        private readonly bool $flag,
-        string $message,
-        int $code = 0,
-        ?Throwable $previous = null,
-    ) {
-        parent::__construct($message, $code, $previous);
-    }
+final class ReproException extends RuntimeException
+{
 }
 
 final class ThrowWithPreviousNamedArgRepro
         try {
             throw new RuntimeException('root');
         } catch (Throwable $e) {
-            throw new ReproException(flag: true, message: $e->getMessage(), previous: $e);
+            throw new ReproException(flag: true, message: $e->getMessage(), previous: $e, previous: $e);
         }
     }
 }
PHP snippet to change
Config  rector.php
Rector version: 2.4.2 - released at 2026-04-16 14:00