-
Notifications
You must be signed in to change notification settings - Fork 50
Fixes failing to recognize mock methods when using getMockForTrait() #29
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
Conversation
I noticed that it is currently not possible to have all tests passing on Travis because of a BC break in phpstan from 0.10.2 to 0.10.3.
Should I change the dependency in composer.json to "phpstan/phpstan": "^0.10.3"
?
Hi, this isn’t that easy to fix, trait is not a standalone type, your solution probably doesn’t work or it would break in some situation. Correct solution is to generate an intersection type of ObjectWithoutClassType and HasMethodType + HasPropertyType of all the traits methods and properties.
Okay, this surpasses my knowledge about how phpstan works internally so I won't be able to fix it that way myself. (I did a quick test, and for my case phpstan recognized both the mock methods and the trait methods.)
What’s the BC break?
The constructor of ImpossibleCheckTypeHelper
changed (now expecting Broker as first parameter), which is used in the failing tests. It's only in the test though, not in the actual source.
This pull request fixes that PHPStan failed to recognize the mock methods when calling getMockForTrait() on the mock builder.
I also repaired the two failing tests of the current master.
Example:
This would always trigger
Call to an undefined method PHPUnit\Framework\MockObject\MockBuilder<MyFancyTrait>::expects().
.