鍍金池/ 問(wèn)答/PHP  HTML/ 動(dòng)態(tài)實(shí)例化的類怎么在PHPStorm中實(shí)現(xiàn)代碼提示

動(dòng)態(tài)實(shí)例化的類怎么在PHPStorm中實(shí)現(xiàn)代碼提示

在Yii2中可以這樣通過(guò)依賴注入取得一個(gè)類的實(shí)例

        $test = \Yii::$container->get('\common\service\test');
        $test->aa();

點(diǎn)擊aa()并不會(huì)跳到對(duì)應(yīng)的函數(shù),輸入$test->也不會(huì)列出test這個(gè)類下面的方法

下面這種寫(xiě)法也沒(méi)有代碼提示,點(diǎn)擊aa()也不會(huì)跳轉(zhuǎn)

        $testClass = '\common\service\test';
        $test = new $testClass;
        $test->aa();
回答
編輯回答
墨沫

增加注釋 看行不行

$testClass = '\common\service\test';
/** @var \common\service\test $test */
$test = new $testClass;
$test->aa();
2017年10月7日 12:20
編輯回答
笑忘初

目前找到的解決辦法,針對(duì)第一種情況
https://confluence.jetbrains....

2017年7月21日 01:45