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); } } }
Applied Rules:
Not a change you expect?
rector.php