Add @return docblock array of objects, that are dim assigned to returned variable
final class ItemProvider
{
+ /**
+ * @return Item[]
+ */
public function provide(array $input): array
{
$items = [];
foreach ($input as $value) {
$items[] = new Item($value);
}
return $items;
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\AddReturnDocblockForArrayDimAssignedObjectRector;
return RectorConfig::configure()
->withRules([
AddReturnDocblockForArrayDimAssignedObjectRector::class,
]);