ReturnTypeFromMockObjectRector

Add known property and return MockObject types

 class SomeTest extends TestCase
 {
-    public function createSomeMock()
+    public function createSomeMock(): \PHPUnit\Framework\MockObject\MockObject
     {
         $someMock = $this->createMock(SomeClass::class);
         return $someMock;
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromMockObjectRector;

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