php / phpDoc - @return instance of $this class?

前端 未结 5 1413
温柔的废话
温柔的废话 2021-02-07 16:08

How do I mark a method as \"returns an instance of the current class\" in my phpDoc?

In the following example my IDE (Netbeans) will see that setSomething always returns

5条回答
  •  清酒与你
    2021-02-07 16:33

    Thought I'd revisit this Q as I came across a couple of things.

    Currently "return $this" isn't supported, but there is a PhpDoc request to add exactly that in v1.5:

    http://pear.php.net/bugs/bug.php?id=16223

    There's also a request for it in Eclipse PDT:

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=276082

    Both are relatively old requests. I'm not going to get too excited about this being implemented any time soon, but here goes to hoping :) In the meantime, it seems there is no proper solution to this problem.

提交回复
热议问题