Skip to content

[CodeQuality] Add ChangeMockObjectReturnUnionToIntersectionRector#703

Merged
TomasVotruba merged 2 commits into
mainfrom
code-quality/return-union-to-intersection
Jul 1, 2026
Merged

[CodeQuality] Add ChangeMockObjectReturnUnionToIntersectionRector#703
TomasVotruba merged 2 commits into
mainfrom
code-quality/return-union-to-intersection

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds code quality rule that converts a @return docblock union with MockObject into an intersection type.

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

Mirrors the existing AddIntersectionVarToMockObjectPropertyRector (for @var), applied to method @return tags in test classes.

Registered in the phpunit-code-quality set.

@TomasVotruba TomasVotruba merged commit 879ea50 into main Jul 1, 2026
8 checks passed
@TomasVotruba TomasVotruba deleted the code-quality/return-union-to-intersection branch July 1, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant