I w开发者_运维知识库onder how to use autocompletion with inherited class. For exemple i have this kind of code :
<?php
class A {
/**
* @return $this
*/
function a(){
return $this;
}
/**
* @return $this
*/
function b(){
return $this;
}
}
class B extends A{
function c() {
}
}
$object = new b();
$object->a()->b()->c();
?>
When i try to navigate with ctrl+click i can find a and b function but how can i reach c?
Thanks.
You have to use the correct PHPDoc style documentation for Eclipse to add autocompletion. In your @return Statement you have to indicate the actual type (name of your class) returned, not the variable:
<?php
class A {
/**
* @return A
*/
function a(){
return $this;
}
/**
* @return A
*/
function b(){
return $this;
}
}
class B extends A{
/**
* @return B
*/
function c() {
}
}
$object = new B();
$object->a()->b()->c();
?>
Now in your example the problem is, that it won't really work with the subclass, because the documentation says that you e.g. for $object->a() return an instance of class A. Therefore autocomplete won't show the methods from class B (you can call them though).
精彩评论