worse-reflection icon indicating copy to clipboard operation
worse-reflection copied to clipboard

How to infer type for method completion?

Open Slamdunk opened this issue 3 years ago • 0 comments

Hi, implementing a custom \Phpactor\WorseReflection\Core\Inference\FrameWalker I've been able to infer a custom type to a variable during assignment:

/** @var MyContainer $container */

$foo = $container->get(MyService::class);
<> // $foo is now MyService just like I need it to be

Now I'm looking for doing the same at direct call level:

/** @var MyContainer $container */
$container->get(MyService::class)-><> // MyService ordinary completion should pop up

But I fail to understand the proper way to do it. I've dug into FrameWalker and also WorseClassMemberCompletor: I don't need to create a custom properties/methods list, I'm just looking for inferring MyServce type as the return type of the get method.

Any help or hint would be lovely welcomed.

Slamdunk avatar Jul 06 '21 06:07 Slamdunk