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
Please sign in to leave a comment.
Hi there,
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.
Now should work:
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)
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
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.
This is what you need.
http://stackoverflow.com/questions/6395737/how-do-i-make-my-php-ide-understand-dependency-injection-containers