Add "never" return-type for methods that never return anything
final class SomeClass
{
- public function run()
+ public function run(): never
{
throw new InvalidException();
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
return RectorConfig::configure()
->withRules([
ReturnNeverTypeRector::class,
]);