Yii2: Wrong order of parameters in @var in view files

Created on 16 Jul 2018  ·  7Comments  ·  Source: yiisoft/yii2

@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;
}

phpDocumentor

What steps will reproduce the problem?

Open any view file in framework.

What is the expected result?

/* @var \yii\web\View $this */
/* @var \yii\gii\generators\module\Generator $generator */

What do you get instead?

/* @var $this yii\web\View */
/* @var $generator yii\gii\generators\module\Generator */

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.15.1

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings