Skip to content

Conversation

@garak
Copy link
Collaborator

@garak garak commented Jan 19, 2026

Removing useless any() calls (which, by the way, are deprecated in the latest phpUnit version)

@garak garak requested a review from stof January 19, 2026 08:30
@stof
Copy link
Collaborator

stof commented Jan 19, 2026

shouldn't most of them be migrated to createStub actually, if this is about preparing for deprecations in the latest PHPUnit ?

@garak
Copy link
Collaborator Author

garak commented Jan 19, 2026

shouldn't most of them be migrated to createStub actually, if this is about preparing for deprecations in the latest PHPUnit ?

The ones I changed here have all expectations, so I don't think we can migrate them to stubs.
Probably we have some other ones that are useless mocks (mocks without expectations) but we should migrate them in a different PR

@stof
Copy link
Collaborator

stof commented Jan 19, 2026

The ones I changed here have all expectations, so I don't think we can migrate them to stubs.

that's not true. Looking at the first test in the diff, it only configures willReturn. It does not define any expectation (that's precisely why it was using ->expects($this->any()) to not expect anything)

@garak
Copy link
Collaborator Author

garak commented Jan 19, 2026

The ones I changed here have all expectations, so I don't think we can migrate them to stubs.

that's not true. Looking at the first test in the diff, it only configures willReturn. It does not define any expectation (that's precisely why it was using ->expects($this->any()) to not expect anything)

Which one exactly? The first one I see is $child->method('getName')->willReturn('Foo'), which expects the getName method to be called.

@stof
Copy link
Collaborator

stof commented Jan 19, 2026

No. This does not expect the method to be called (which is why it is using ->expect($this->any()) in the current code).
This defines the behavior of the stub method when it is called, which is totally supported on stubs.

@garak
Copy link
Collaborator Author

garak commented Jan 19, 2026

I see. Nevertheless, using a mock like the ones we're using here doesn't trigger a deprecation in the most recent version of phpUnit, which is only triggered when you create a mock and use it directly.
So I'm not sure if we want to add your suggested changes here or in a second iteration. Let me know.

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