NarrowPreviousExceptionCodeArgRector
Remove code of previous exception from new exception, as previous exception already carries it
try {
$someCode = 1;
} catch (Throwable $throwable) {
- throw new \RuntimeException('ups', $throwable->getCode(), $throwable);
+ throw new \RuntimeException('ups', previous: $throwable);
}
Configure your rector.php:
<?php
use Rector\CodeQuality\Rector\New_\NarrowPreviousExceptionCodeArgRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
NarrowPreviousExceptionCodeArgRector::class,
]);