TypedPropertyFromCreateMockAssignRector

Add typed property from assigned mock

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
-    private $someProperty;
+    private \PHPUnit\Framework\MockObject\MockObject $someProperty;

     protected function setUp(): void
     {
         $this->someProperty = $this->createMock(SomeMockedClass::class);
     }
 }

Configure your rector.php:

<?php

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

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