与具有私有或protected成员变量,而不是诉诸一堆吸气的的或设置成员的类工作时如何设置代码完成功能上的Zend Studio(或任何基于Eclipse的IDE)工作瓦尔公众。

例如:

class Dog {

    protected $bark = 'woof!';

    public function __get($key) {
        if (isset($this->$key)) {
            return $this->$key;
        }
    }

}

$Dog = new Dog();
echo $Dog->bark; // <-- I want the IDE to "know" that bark is a property of Dog.
有帮助吗?

解决方案

代码完成魔术方法可以通过使用 @实现财产 @method 注释中类(未在方法文档)的文档块。

/**
 * @property string bark
 */
class Dog {
    /* ... */
}

$Dog = new Dog();
echo $Dog-> // will autocomplete now

请注意,有实际的代码和注解之间没有相关性。 Zend Studio的会告诉你什么了@property设置,无论该财产的现有的。它也不会检查是否有其实是一个神奇的方法可用。

“代码完成在Zend的工作室与@Property注释”

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top