【问题标题】:Annotate a class member that doesn't exist (virtual property)注释一个不存在的类成员(虚拟属性)
【发布时间】:2015-03-26 11:21:14
【问题描述】:

有没有办法为未明确声明的类成员添加注释?喜欢

class Foo
{
    /** @var string $bar */
    // public $bar; // <--- without this line

    ...other stuff...
}

背景:我使用__get 为我的类提供虚拟属性,并希望这些属性出现在 phpstorm/idea 自动完成框中。

【问题讨论】:

标签: php intellij-idea phpstorm phpdoc


【解决方案1】:

在类上使用@property* 注解。

/**
 * @property string $bar
 */
class Foo {}


*或@property-read@property-write视情况而定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    • 2019-05-06
    • 2013-03-11
    • 1970-01-01
    • 2015-09-10
    • 2010-11-14
    相关资源
    最近更新 更多