关于注释的写法与疑问

发布于 2022-09-01 21:57:29 字数 593 浏览 31 评论 0

最近在学习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
 */

不知道为什么要怎样写。求路过大神赐教。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戈亓 2022-09-08 21:57:29

这是符合phpdoc的注释格式,有很多工具可以解析这类注释并且直接生成文档,例如phpDocumentor, doxygen等等。IDE例如eclipse的PDT,InteliJ的IDEA和PHPStorm也能解析这种注释格式,并且根据注释来辅助生成代码提示

唠甜嗑 2022-09-08 21:57:29

@vimac 是正解,这是phpDoc的注释规范,和YII2无关。

详情楼主可以谷歌一下phpdoc,这样有利于各种IDE和编辑器对代码进行自动提示。YII APIDOC功能也是需要这个的。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文