Skip to content

Enable TypedPropertyFromCreateMockAssignRector#1272

Open
samsonasik wants to merge 4 commits into
spiral:masterfrom
samsonasik:typed-prop-create-mock
Open

Enable TypedPropertyFromCreateMockAssignRector#1272
samsonasik wants to merge 4 commits into
spiral:masterfrom
samsonasik:typed-prop-create-mock

Conversation

@samsonasik

@samsonasik samsonasik commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

What was changed

Add PHPUnit\Framework\MockObject\MockObject typed property from assigned mock to clearly separate from real objects

Why?

  • Makes test intent clearer by explicitly identifying properties that store PHPUnit mocks.
  • Helps distinguish mocked dependencies from real objects at a glance.
  • Improves IDE and static analysis support for mock-specific methods.
  • Reduces ambiguity when maintaining or extending the tests later.

Checklist

  • Tested
    • Tested manually

@samsonasik

Copy link
Copy Markdown
Contributor Author

@roxblnfk ready to merge 👍

@roxblnfk

Copy link
Copy Markdown
Member

I think it's better to use union types there

@samsonasik

Copy link
Copy Markdown
Contributor Author

@roxblnfk do you mean intersection?

-private RequestHandlerInterface $handler;
+private MockObject&RequestHandlerInterface $handler;

@roxblnfk

Copy link
Copy Markdown
Member

the intersection is better, yes 👍

@samsonasik samsonasik force-pushed the typed-prop-create-mock branch from a1fb803 to 330c4e1 Compare June 13, 2026 18:56
@samsonasik

Copy link
Copy Markdown
Contributor Author

@roxblnfk sure, I've updated to intersection 330c4e1

Ready to merge 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants