PHP:通过@var提供多个类/接口的文档/提示

I am making usage of

/* @var $var Type */ 

really often for NetBeans can then autocomplete methods and stuff in code. Still I think its a very useful feature but sometimes I got objects of classes extending one more class and implementing multiple interfaces. Or I even got a transitive class hierarchy.

I don't know a way to tell NetBeans that it shall be using autocomplete for all these interfaces and upper-layer parent classes.

I would like to do so for of course every of these interfaces / classes got dedicated methods (which are defined somewhere in case of interfaces...)

I tried something like this:

/* @var $var TypeA|\TypeB|\TypeC */

because I saw NetBeans will generate a similar documentation for methods returning different class objects due a switch/case. But this seems to work only for the @return notation.

I also tried

/* @var $var TypeA|TypeB */ 

Also not working...

NetBeans will autocomplete the last told Type in this case but not a combination of both/all told classes.

How can I document so my autocomplete works as desired (a summary of methods of all classes /interfaces I listed)?

regards!

If I understand you correctly, you are asking to chain hint through your PHP code.

The problem is netbeans has no way of knowing what an object actually is; unless you tell it. The solution is to use the @property command in your object decleration to forward type define the objects members , be it a class or interface.

/**
@property classMyClass1 $clsMyClass1
@property classMyClass2 $clsMyClass2
*/
class baseClass{
    public $clsMyclass1; 
    public $clsMyClass2;

    public function __construct() {
        $this->clsMyClass1 = new classMyClass1();
        $this->clsMyClass2 = new classMyClass2();
    }
}

$foo = new baseClass();

Now when you type your code in netbeans it will know what hinting to display on your last typed object

$foo->clsMyClass1->

So long as each class has a forward property decleration you can chain as long as you want

$foo->class1->class2->class3->...

The above code would need the autoload() function to load the correct class files....

Hope this helps you!