We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Dependency Injection, get, I set an object, code completion, phpdoc?

so I set something with DI:

$di->setShared('env', function() { return MyOwnClass(); });

and reach it

$this->getDI()->get('env')

or

$this->getDI()->getEnv()

but now there is no chance to use autocompletion by my IDE. Is there a way to set "what 'env' is" ? Its class?



1.3k

In PhpStorm you may use Phpdoc for autocomplete mechanism

/**

* Class CoreController

*

* @package Core\Controllers

* @property-read \Phalcon\Http\Request request

*/