InlineStubPropertyToCreateStubMethodCallRector

Inline stub property only used to pass as new argument to a method call

 use PHPUnit\Framework\TestCase;
-use PHPUnit\Framework\MockObject\Stub;

 final class SomeTest extends TestCase
 {
-    private Stub $someStub;
-
-    protected function setUp(): void
-    {
-        $this->someStub = $this->createStub(SomeClass::class);
-    }
-
     public function testAnother()
     {
-        $anotherObject = new AnotherObject($this->someStub);
+        $anotherObject = new AnotherObject($this->createStub(SomeStub::class));
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\InlineStubPropertyToCreateStubMethodCallRector;

return RectorConfig::configure()
    ->withRules([
        InlineStubPropertyToCreateStubMethodCallRector::class,
    ]);
SETS:  Code Quality