I’m developing for Yii2 using PHPStorm. I’ve set up autocomplete for application components using http://www.yiiframework.com/extension/yii2-stubs-generator/ and for variables in views using PHPDoc comments at the top of each view file. However, so far I haven’t found a way of getting types automatically assigned to the results of ActiveRecord queries (e.g.,
User::find()->where(…)->one()
).
Is there any way I can do that besides (1) including a
/** @var $result common\models\User */
comment before each such query, or (2) wrapping all such queries in methods I declare in each model class?
Note: there’s an older post about this (by another user) in http://www.yiiframework.com/forum/index.php/topic/51101-yii2-and-phpstorm/, but it seems it was resurrecting a dead thread, so I’m starting a new one. Please let me know if this is poor etiquette – I’m a long-time Yii user but new to this forum, and I can see an argument either way after reading the pinned “before posting” thread.