TypedPropertyFromContainerGetSetUpRector

Add strict typed property to a private test case property based on its @var object type, when assigned via container fetch in setUp()

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
-    /**
-     * @var SomeService
-     */
-    private $someService;
+    private SomeService $someService;

     protected function setUp(): void
     {
         $this->someService = static::getContainer()->get(SomeService::class);
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromContainerGetSetUpRector;

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