Autocomple for Objects from Factory

Hi,

I think this should be a problem for many people (and so I hope, there is a solution.

We have a Factory in our Application. It is used like that:

$order_coo = MainFactory::create_object('Order');



So the $order_coo is an Instance of the Order-Class.

I know, that I can tell PHPStorm (or IntellJ :)) that with using PHPDoc like this:

/** @var Order $order */
$order
= MainFactory::create_object('Order');


But is it possible to tell the Factory, that it will alway return an Object from the Class which is the parameter?

So I don't have to make every call from Manfactory wrap with that PHPDoc /** @var Order....

cu

2 comments
Comment actions Permalink

Well, that is solution for phpstorm but there is also php plugin for intelij IDEA - so can be that solution used (and if yes then what changes are required) in intelij IDEA

0

Please sign in to leave a comment.