Phalcon DI phpStorm IDE does not understand my code

I am using phalcon in a new project, but I realized that phpStorm does not understand my own injectors, for example:

/** * Registering the helper component */ $di->set('helper', function () { $helper = new \Frontend\Helpers\Common(); return $helper; }); 

from my controller I can do this:

  $this->helper->getHelp(); 

and it works fine, but the IDE does not autofill my code. Of course I could do this:

  /** @var \Frontend\Helpers\Common $helper */ $helper->... 

In this case, I can see all the methods, but then every time I need to use an assistant, I have to put these comments.

I would like to know if there is a way to use custom injectors and make the IDE not understand the code?

+4
source share
1 answer

You can use this workaround.

services.php

 /** * Registering the helper component */ $di->set('helper', function () { $helper = new \Frontend\Helpers\Common(); return $helper; }); 

AbstractController

 /** * My Abstract controller * * @property \Frontend\Helpers\Common helper */. class AbstractController extends \Phalcon\Mvc\Controller { } 

Testcontroller

 class TestController extends AbstractController { public function indexAction() { $this->helper->... } } 
+4
source

All Articles