AddClosureParamTypeFromVariableCallRector

Add closure param object type based on the argument the assigned closure variable is called with

-$printItem = function ($item) {
+$printItem = function (Item $item) {
     echo $item->name;
 };

 $printItem(new Item());

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeFromVariableCallRector;

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