-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for PHPUnit 12.0.9 #222
Comments
I also remember talking to Ondrej and/or Markus last year about whether the stubs in phpstan-phpunit are still needed. Ideally, this part of this extension can just be removed. |
I assume that some of this code might be conditionally removed for recent version of phpunit but not all of them. For instance the MockMethodCallRule is made to report code like
Those file were introduced in #72,
|
I just found one more method (see sebastianbergmann/phpunit@4b7f2a8) that is part of the public API for configuring test doubles which was missing |
I can confirm that without the extension PHPStan works fine for the mocks. |
So is there still a need for the extension then? |
I imagine it depends on which features of phpunit you use. |
The extension is not just about mock stubs but also
I'm okay trying to work on this issue in the next days/week(s). I would say that the first step would be to run the CI with phpunit 10, 11 and 12. But currently it's not possible because of Lines 19 to 24 in 0f857bf
@ondrejmirtes any advice about how you want to solve this ? Should I override the confirm.platform.php in the CI and try installing more recent phpunit versions ? Or should I remove the |
I added testing with multiple PHPUnit versions: #223 I started testing v12: #224 But I feel like not enough tests are failing. @VincentLanglet The biggest help for me would if you contributed some new tests in a separate PR that simply pass with PHPUnit v9-v11, but fail with v12. That way I can verify if the fixes I actually plan to do are valid. |
So ideally you need to look at the places that currently mention InvocationMocker, and figure out what breaks:
|
The current failure
from your PR @ondrejmirtes is legit because the MockMethodCallRule was implemented around the This was the "only" test failing because it's the only code which rely on InvocationMocker.
and all three of them were introduced for the MockMethodCallRule (as explained in #222 (comment)) I'm not sure there is a lot more tests to add then, but still I added #225 as a non-regression test for this issue.
Do you want to first try your solution or should I try a fix for the PHPUnit 12 build ? |
I want to look into it myself. Thanks! |
See sebastianbergmann/phpunit#6156 (comment)
In 12.0.9 PHPUnit removed the InvocationMocker classes, the PR is sebastianbergmann/phpunit@fb4df53
Current references are
phpstan-phpunit/stubs/InvocationMocker.stub
Line 10 in 0f857bf
phpstan-phpunit/src/Type/PHPUnit/InvocationMockerDynamicReturnTypeExtension.php
Line 12 in 0f857bf
phpstan-phpunit/extension.neon
Line 15 in 0f857bf
phpstan-phpunit/src/Type/PHPUnit/MockObjectDynamicReturnTypeExtension.php
Line 12 in 0f857bf
phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php
Line 10 in 0f857bf
I feel like
PHPUnit\Framework\MockObject\Builder\InvocationMocker
was basically replaced byPHPUnit\Framework\MockObject\InvocationStubberImplementation
Currently don't know if it will require a StubFilesExtensionLoader like this one
https://github.com/phpstan/phpstan-doctrine/blob/2.0.x/src/Stubs/Doctrine/StubFilesExtensionLoader.php
or if a there is a better strategy.
One first step would be to test this lib with phpunit 10/11 (and 12) but it's currently forbidden by the hardcoded php config
phpstan-phpunit/composer.json
Lines 19 to 24 in 0f857bf
The text was updated successfully, but these errors were encountered: