Run Rector on your code to see what it can do for you:

 {
     public function testFooMock(): void
     {
-        $mock = $this->getMockBuilder(Foo::class)
-            ->disableOriginalConstructor()
-            ->getMock()
+        $mock = $this->createMock(Foo::class)
         ;
     }
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: 9dccc8 - released at 2026-04-04 09:34