S
S
Strate2012-02-22 13:39:31
PHP
Strate, 2012-02-22 13:39:31

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

3 answer(s)
D
DeusModus, 2012-02-22
@DeusModus

In the yii view, I add a small header section:

<?php
/**
 * @var int $something_count Количество чего-то
 * @var Model $model модель чего-то
 * @var Controller $controller контроллер
 */
$controller = $this;
?>

It is not possible to automate this.

N
Nikolai Vasilchuk, 2012-02-22
@Anonym

Head-on solution: phpStorm can create docks automatically for the files it creates.

@
@resurection, 2012-02-24
_

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 question

Ask a Question

731 491 924 answers to any question