Summer Sale! All accounts are 50% off this week.

Hom's avatar
Level 4

How Does VS Code Infer Complex Type from Mockery Mock Objects?

I've encountered a type inference issue while using Mockery to create mock objects for unit testing.

I expect the mock object created by the mock method to be of the App\Command\ApplicationChecker type while also implementing Mockery\MockInterface.

However, the PHPDoc for the mock method doesn't specify App\Command\ApplicationChecker. Here's how I call mock:

$checker = Mockery::mock(App\Command\ApplicationChecker::class);

How does VS Code know that $checker is both App\Command\ApplicationChecker and Mockery\MockInterface? I've tried looking into Mockery documentation and checking VS Code plugins but haven't found an answer.

I would like to understand the mechanism behind this..

0 likes
0 replies

Please or to participate in this conversation.