AddClosureNeverReturnTypeRector

Add "never" return-type for closure that never return anything

-function () {
+function (): never {
     throw new InvalidException();
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Closure\AddClosureNeverReturnTypeRector;

return RectorConfig::configure()
    ->withRules([
        AddClosureNeverReturnTypeRector::class,
    ]);