VoidMethodWithCallbackToWillReturnCallbackRector

Flip a ->with($this->callback(...)) matcher on a void mocked method to a ->willReturnCallback() call, dropping the value return and typing the closure as void

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     public function test()
     {
         $this->createMock(SomeClass::class)
             ->method('run')
-            ->with($this->callback(function ($arg) {
+            ->willReturnCallback(function ($arg): void {
                 echo $arg;
-
-                return true;
-            }));
+            });
     }
 }

 final class SomeClass
 {
     public function run($arg): void
     {
     }
 }

Configure your rector.php:

<?php

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

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