A
A
agent11562017-01-10 13:18:41
Yii
agent1156, 2017-01-10 13:18:41

How to write comments in yii2?

What do these kind of comments /**
* @inheritdoc
*/ mean and how to put them in your code in phpstorm ???

/**
 * This is the model class for table "img".
 *
 * @property integer $id
 * @property string $category
 * @property string $url
 * @property string $description
 * @property string $alt
 */
class Img extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'img';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['category', 'url', 'description', 'alt'], 'required'],
            [['category', 'url', 'description', 'alt'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'category' => 'Category',
            'url' => 'Url',
            'description' => 'Description',
            'alt' => 'Alt',
        ];
    }
}

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
Decadal, 2017-01-10
@Decadal

yii2 has nothing to do with it.
It all depends on which editor or IDE the author of the code used - usually they have their own built-in comment generators. For example, PhpStorm uses https://www.phpdoc.org/ - this is the standard.
@inheritdoc - according to the standard, a reference to the documentation of the parent class.
set like this - before a function or variable, press three keys: /** , then ENTER

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question