I have the following code in an application powered by Silex:
$uknownObj->unkownRef
$uknownObj
being a dependency injection container.
I know that unkownRef
is of instance MyCoolObj
.
Now how can I tell IntelliJ / PhpStorm to actually help me with autocomplete of this said object?
Simply assign unkownRef
to a variable and provide annotation like this.
/** @var MyCoolObj $obj */
$obj = $uknownObj->unkownRef;
You can use phpdoc in container class, this is what i use with Slim framework :
/**
* @property-read \Monolog\Logger logger
* @property-read \Slim\Views\Twig view
* @property-read \PDO db
*/
class Container extends PimpleContainer implements ContainerInterface
{
}
I just solved this by creating just _ide_autocomplete.php
file in the project root where I just created a dummy class with all the slim container key as property. Then in my routes, in the beginning I just put a phpblock like this
/** @var Dummy $this */
My source codes are articles are in https://blog.shaharia.com/slim-php-framework-phpstorm-ide-autocompletion-solution/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.