Answer the question
In order to leave comments, you need to log in
How to make phpStorm determine the type of a variable in files of a certain type?
Good afternoon!
I need phpStorm to correctly determine the type of the $this variable in all *.phtml type files. There are already a lot of files, so adding PHPDoc to each is not an option. How can the problem be solved globally?
Answer the question
In order to leave comments, you need to log in
In the yii view, I add a small header section:
<?php
/**
* @var int $something_count Количество чего-то
* @var Model $model модель чего-то
* @var Controller $controller контроллер
*/
$controller = $this;
?>
Head-on solution: phpStorm can create docks automatically for the files it creates.
A follow-up question. How to write phpDoc for $this correctly so that PS doesn't swear at private methods? That is, when the file is included from the class and in the file write:
<?php
/**
*@var myClass $this
*/
$this->_privateMethod(); // PS Ругается красным.
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question