[PR #9318] Document PHPUnit mocks with intersection types #11522

Open
opened 2026-01-22 16:11:02 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/9318

State: closed
Merged: Yes


PHPUnit's createMock() will return an object that extends the mocked type and implements MockObject at the same time. The accurate way to document this is an intersection type, but we often document a union type instead. This declaration is too wide because virtally any mock object would pass it.

This might look nit-picking now, but it will become more important later when we try to infer native types from the docblock types in an automated manner.

**Original Pull Request:** https://github.com/doctrine/orm/pull/9318 **State:** closed **Merged:** Yes --- PHPUnit's `createMock()` will return an object that extends the mocked type and implements `MockObject` at the same time. The accurate way to document this is an intersection type, but we often document a union type instead. This declaration is too wide because virtally any mock object would pass it. This might look nit-picking now, but it will become more important later when we try to infer native types from the docblock types in an automated manner.
admin added the pull-request label 2026-01-22 16:11:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#11522