奇怪的自动填充行为:
class myFirstClass
{
public function myFunc1() {}
public function myFunc2() {}
}
class mySecondClass
{
/**
* @return myFirstClass
*/
public function getMyFirstClass()
{
return new myFirstClass();
}
public function init()
{
$myFirstClass = new myFirstClass();
$myFirstClass-> // autoComplete works here and shows myFunc1 and myFunc2
$this->myFirstClass = new myFirstClass();
$this->myFirstClass-> // autoComplete does not work here
$this->getMyFirstClass()-> // autoComplete works here and shows myFunc1 and myFunc2
$this->myFirstClass2 = $this->getMyFirstClass();
$this->myFirstClass2-> // autoComplete does not work here
$this->myFirstClass2->myFunc1(); // cmd+click on myFunc1() in this line jumps to the myFunc1-function in myFirstClass, so netbeans "knows" the right class, but doesn't autocomplete :(
}
}
如果没有$ this,Code-Autocomplete就可以正常工作,但使用$ this->它什么都没有显示出来。这是一个已知的NetBeans错误还是有设置来解决这个问题?
答案 0 :(得分:0)
我想NetBeans只有$this->....
的自动完成功能,而不是$this->....->....
的自动完成功能,所以在第一个箭头后它没有任何支持。你纠正它不起作用,因为它并不打算这样做。
问候。
答案 1 :(得分:0)
请在mySecondClass中添加字段:
class mySecondClass {
private $myFirstClass;
private $myFirstClass2;
}
或
class mySecondClass {
/**
* @var myFirstClass
*/
private $myFirstClass;
/**
* @var myFirstClass
*/
private $myFirstClass2;
}