S
S
Sergey Beresnev2012-11-30 08:21:11
PHP
Sergey Beresnev, 2012-11-30 08:21:11

Netbeans, autocomplete, fluent interface

And how do you solve the problem with a fluid interface?

class Shape
    {
    /** @param type $color
     * @return \Shape */
    public function setPenColor($color)
        { return $this; }
    /** @param type $color
     * @return \Shape */
    public function setBrushColor($color)
        { return $this; }
    }

class Circle extends shape
    {
    /** @param type $x
     * @param type $y
     * @return \Circle */
    public function setCenter($x, $y)
        { return $this; }
    /** @param type $radius
     * @return \Circle */
    public function setRadius($radius)
        { return $this; }
    }

$circle = (new Circle())
    ->setBrushColor($color)
    ->|;


Accordingly, in NetBeans, in place of |, only the shape methods appear, and not circle and shape.

How do you deal with this problem in your IDE?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Vasilchuk, 2012-11-30
@Anonym

There is no such problem in phpStorm.

M
Melz, 2012-11-30
@melz

Yes, there is such a thing in NetBeans, so far I have found only 2 crutches:
1. List each class in return, if there are a lot of classes, you will be tormented.
return Shape|Circle
2. In Shape dock use method
method Circle setCenter($x, $y) Description

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question