關於注釋的寫法與疑問

來源:互聯網
上載者:User
最近在學習Yii2,晃了幾眼原始碼,看到了類似怎樣的注釋:

@ - 1/** * User model * * @property integer $id * @property string $username * @property string $password_hash * @property string $password_reset_token * @property string $email * @property string $auth_key * @property integer $status * @property integer $created_at * @property integer $updated_at * @property string $password write-only password */@ - 2/** * @inheritdoc */public static function tableName(){    return '{{%user}}';}@ - 3/** * @var \common\models\User */

不知道為什麼要怎樣寫。求路過大神賜教。

回複內容:

最近在學習Yii2,晃了幾眼原始碼,看到了類似怎樣的注釋:

@ - 1/** * User model * * @property integer $id * @property string $username * @property string $password_hash * @property string $password_reset_token * @property string $email * @property string $auth_key * @property integer $status * @property integer $created_at * @property integer $updated_at * @property string $password write-only password */@ - 2/** * @inheritdoc */public static function tableName(){    return '{{%user}}';}@ - 3/** * @var \common\models\User */

不知道為什麼要怎樣寫。求路過大神賜教。

這是符合phpdoc的注釋格式,有很多工具可以解析這類注釋並且直接產生文檔,例如phpDocumentor, doxygen等等。IDE例如eclipse的PDT,InteliJ的IDEA和PHPStorm也能解析這種注釋格式,並且根據注釋來輔助產生代碼提示

@vimac 是正解,這是phpDoc的注釋規範,和YII2無關。

詳情樓主可以Google一下phpdoc,這樣有利於各種IDE和編輯器對代碼進行自動提示。YII APIDOC功能也是需要這個的。

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.