Hello. Diving more into test driven development, I've come across a situation in which the code analyzer doesn't recognize that a
Mockery::mock(MyClass::class) is sort of a wrapper object for
MyClass. This is a situation that Intelephense faced and tackled not long ago:
The problem causes the code analyzer to give errors when passing these Mock objects as arguments to other methods for example, even though it's valid.
Here are some screenshots illustrating the problem.
In this one, the top is the DEVSENSE PHP extension, and the bottom is the Intelephense extension:
Here's where the error happens while passing the object as an argument to a function which expects an
AuthenticationManagerInterface type. Top two are the PHP extension, and the bottom is Intelephense where you can see it properly recognizing the intersected type.
I haven't found how exactly PHPStorm or Intelephense is discerning these types, but they are very helpful to have of course. Hopefully this kind of support can be implemented without much headache. Thank you!