You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHPStan returns Return type of call to static method Mockery::mock() contains unresolvable type. when I try to mock a class that is final (in this case it's also readonly, but the issue is caused by the final statement).
$dto = \Mockery::mock(MyFinalClass::class);
In my PHPUnit bootstrap I setup dg\bypass-finals so it "technically" possible to create the mock. This has always worked up to and including version 1.6.9. It's only the last 2 releases of Mockery that PHPStan started reporting the above errors.
Steps to Reproduce
Create a final class.
Try and mock the final class in a PHPUnit test with dg/bypass-finals configured in PHPUnit's bootstrap file.
Run PHPStan.
Expected Behavior
No errors PHPStan errors
Actual Behavior
PHPStan reports on the line with Mockery::mock():
Return type of call to static method Mockery::mock() contains unresolvable type.
Exception or Error
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Ilyes512
changed the title
Mocking final classes is broken with latest 2 releases
Mocking final classes reports unresolvable type by PHPStan
Apr 15, 2024
You are absolutely right, that was my mistake, the doc comments were incomplete.
I believe we are working on this in #1410, can you please test that branch "mockery/mockery": "1.6.x-dev#1c67601", and report any other issues found by each tool you’re using for static analysis.
Mockery Version
1.6.11
PHP Version
PHP 8.2
Issue Description
PHPStan returns
Return type of call to static method Mockery::mock() contains unresolvable type.
when I try to mock a class that isfinal
(in this case it's also readonly, but the issue is caused by the final statement).In my PHPUnit bootstrap I setup dg\bypass-finals so it "technically" possible to create the mock. This has always worked up to and including version
1.6.9
. It's only the last 2 releases of Mockery that PHPStan started reporting the above errors.Steps to Reproduce
dg/bypass-finals
configured in PHPUnit's bootstrap file.Expected Behavior
No errors PHPStan errors
Actual Behavior
PHPStan reports on the line with
Mockery::mock()
:Exception or Error
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: