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
fix mock method $args parameter type #1397
Conversation
c5fbe34
to
79a07bd
Compare
This still does not fix alias: and such usages, but most normal use cases PHPStan undestands it properly. and if no parameters given at all also still fails. But in those cases it might be able to solve with this: https://github.com/phpstan/phpstan-mockery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, going to merge this pull request.
Thank you.
Thank you, made a note to take care of that. |
@@ -468,7 +468,7 @@ public static function isSame($expected): IsSame | |||
* | |||
* @template TMock | |||
* | |||
* @param TMock ...$args | |||
* @param array<class-string<TMock>|TMock> $args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is invalid type, because according in the doc you can
$mock = \Mockery::mock('MyClass', 'MyInterface', [$constructorArg1, $constructorArg2]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. There are still a lot of different use cases that this does not cover.
While this update fixes a lot of phpstan errors. It also introduces a new one for an edge case in my code:
It seems that like it only excepts 1 parameter? |
fix for #1395