views:

82

answers:

1

Hi guys,

I've got an abstract base class:

abstract class BaseClass {
  /**
   * @return CLASSNAME
   */
  public function fluent() {
    // do stuff
    return $this;
  }
}

Generally, i would put BaseClass where CLASSNAME is and all would be fine, PDT would pick up the phpdoc return type and happily autocomplete.

Until, that is, I subclass BaseClass and add additional methods, and code compete on an instance of the derived class. PDT will only recognise the methods from BaseClass and not those from the derived class.

What I need is something like @return self or @return this.

Does PDT have such functionality? Or is there an alternate trick without having to declare these methods in every derived class?

+1  A: 

AFAIK there is no such feature in PDT, but you could use at least type hint:

$obj = $osomething->fluent();
/* @var $obj ChildClass */

Then you would have all methods from derived in autocompletion. I know its annoying to write this comment every time you call fluent(), but it is still better than re-defining the methods in each derived class over and over again...

Laimoncijus