繁体   English   中英

注释不存在的类成员(虚拟属性)

[英]Annotate a class member that doesn't exist (virtual property)

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

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

    ...other stuff...
}

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

在类上使用@property *批注。

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

PHPStorm自动完成框演示的屏幕截图。


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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM