AutoComplete dependency injection container

Hello!

I use the dependency injection container of Sympony Framework.

Unfortunately, does not auto-complete for this container.


$pimple = $this->getInvokeArg('bootstrap')->getResource('Container');

/** $pimple['tabelleAdressen'] Application_Model_DbTable_adressen */
$pimple['tabelleAdressen'] = function($c){
          return new Application_Model_DbTable_adressen();
};

// Autocomplete don't work ?????
$test = $pimple['tabelleAdressen'];
$test-> // Here is the Error


Who can help with an idea?

Sincerely yours

Stephan

4 comments

Hi there,

/** $pimple['tabelleAdressen'] Application_Model_DbTable_adressen */

PhpStorm does not support such complex type hints (type hint for specific array element -- only for ordinary variables). This is not a valid PHPDoc anyway.

// Autocomplete don't work ?????
$test = $pimple['tabelleAdressen'];
$test-> // Here is the Error


Now should work:

/** @var Application_Model_DbTable_adressen $test */

$test = $pimple['tabelleAdressen'];
$test->


P.S.
Since WI-6027 is now implemented (maybe you can utilize it in your code somehow), then the next step should be http://youtrack.jetbrains.com/issue/WI-3350 , I guess (which should address your issue directly, so no additional type hints would be required)

0

Hello!

Thanks for the information.
I want to define the container only once in the controller.

When I use the container in the model, then I would like an automatic code

completion without new Php Doc comment.

----------- my controller --------------

          $pimple = $this->getInvokeArg('bootstrap')->getResource('Container');

            /** @var Application_Model_DbTable_adressen $pimple['tabelleAdressen'] */
            $pimple['tabelleAdressen'] = function($c){
                return new Application_Model_DbTable_adressen();
            };

--------------- my model -------------------------------

// without new Php Doc Comment
$test = $this->_pimple['tabelleAdressen'];
$test->bla(); // Here is the error

------------------------------------------------------------

Is that possible?

Sincerely yours

Stephan

0

Is that possible?


The way you do (via array) -- NO (PhpStorm has no such functionality yet).

But if you use ordinary class variable (e.g. $pimple_tabelleAdressen) then yes, it should work OK.

0

Please sign in to leave a comment.