ChangeMockObjectReturnUnionToIntersectionRector

Change a MockObject @return union docblock to an intersection type

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     /**
-     * @return Event|\PHPUnit\Framework\MockObject\MockObject
+     * @return Event&\PHPUnit\Framework\MockObject\MockObject
      */
     private function createEvent(): \PHPUnit\Framework\MockObject\MockObject
     {
         return $this->createMock(Event::class);
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\ChangeMockObjectReturnUnionToIntersectionRector;

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