@var
You may use the @var tag to document the “Type” of properties, sometimes called class variables.
Syntax
@var [“Type”] [$element_name] [
] Examples
class Foo { /** * @var string $name Should contain a description * @var string $description Should contain a description */ protected $name, $description; }
Open any view file in framework.
/* @var \yii\web\View $this */
/* @var \yii\gii\generators\module\Generator $generator */
/* @var $this yii\web\View */
/* @var $generator yii\gii\generators\module\Generator */
| Q | A
| ---------------- | ---
| Yii version | 2.0.15.1
Because it's not phpdoc, it's vardoc.
@samdark Okay, but what about moving to phpdoc syntax?
@springimport At least some time ago vardoc has better IDE support. And it is still not clear whether using phpdoc in such way is valid - phpdoc should proceed structural element, which does not exist in this case.
@rob006
\yii\bootstrap\Nav, phpdoc:
/** @var Widget $dropdownClass */
yii\db\ActiveQuery, vardoc:
/* @var $modelClass ActiveRecord */
yii\console\controllers\HelpController, ??:
/** @var $controller Controller */
As @rob006 said, neither is phpdoc. Phpdoc can't be applied to inline variables according to its specifications.
@samdark I think it will be good to have single format in yii.
Yes. Should be /* @var $modelClass ActiveRecord */ but technically vardoc allows both. If you have some free time to burn, feel free to submit a pull request.