AddReturnTypeDeclarationFromYieldsRector

Add return type declarations from yields

 class SomeClass
 {
-    public function provide()
+    /**
+     * @return Iterator<int>
+     */
+    public function provide(): Iterator
     {
         yield 1;
     }
 }

Configure your rector.php:

<?php

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

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