Netbeans:在注释中声明变量不起作用

时间:2011-01-17 09:33:44

标签: php netbeans

..当变量是$ this->成员时。

例如:

/ * @var $ this-> myObject MyClass * /

不起作用。

/ * @var $ foo SomeOtherClass * /

作品。

$ this会员需要什么特殊编码?

(另见http://netbeans.org/kb/docs/php/php-variables-screencast.html

1 个答案:

答案 0 :(得分:2)

您可以对类变量进行类型设置,但您必须在定义它们的位置执行此操作。每个例子:

<?php
class Foo { 
    function bar( ) {
        return 'foo-bar';
    }
}

class Bar {
    /**
     * Contains a Foo.
     * @var Foo
     */
     protected $foo;

     public function foobar( ) {
         return $this->foo; /** Here, you'd get autocompletion when you add ->. */
     }
}