This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 171418

Summary: setter with fluent interface
Product: php Reporter: derk <derk>
Component: EditorAssignee: Ondrej Brejla <obrejla>
Severity: blocker CC: maghiel, OndrejBrejla
Priority: P3    
Version: 7.1   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description derk 2009-09-03 16:30:36 UTC
Default template for setter should encourage fluent interface:

public function setVar($var){
     return $this;
Comment 1 Filip Zamboj 2010-09-15 12:29:59 UTC
batch reassigning
Comment 2 majkl578 2011-12-30 18:17:26 UTC
Comment 3 maghiel 2011-12-30 23:22:29 UTC
I disagree, this would be really not desirable. I use Fluent Interface many times too, but in *some* classes. 
IMHO IF this would be implemented, please implement it as an (non default) option.

Consider following:
class Apple
    public function setColor($color)
        $this->_color = $color;

        return $this;

    public function setCanBeRed($canBeRed)
        $this->_canBeRed = (bool) $canBeRed; 

        return $this;

$apple = new Apple();

Now I would have to raise an exception in setColor if canBeRed is false, or just let setColor return an instance of self, but imho the code isnt that fluent anymore then :p
A bit a bad example, but it's late and tomorrow is holiday so I'm already drunk, but I hope you'll get my point ;)
Comment 4 derk 2011-12-31 09:45:41 UTC
I mean it's not real-world example. Use "enable" instead "set" in this specific case.
Comment 5 Ondrej Brejla 2012-06-18 13:23:53 UTC
P3 since 4 votes...
Comment 6 Ondrej Brejla 2012-06-18 13:58:43 UTC
Fixed in web-main #b666f7d49969
Comment 7 Quality Engineering 2012-06-20 04:37:57 UTC
Integrated into 'main-golden', will be available in build *201206200001* on (upload may still be in progress)
User: Ondrej Brejla <>
Log: #171418 - setter with fluent interface
Comment 8 maghiel 2012-09-05 22:57:57 UTC
Just tested it, exactly how I wanted to see the implementation :) This feature will save me tons of time.

Want me to mark as VERIFIED FIXED?
Comment 9 Ondrej Brejla 2012-09-06 07:08:06 UTC
Thanks. I thinks that it's QA privilege ;)
Comment 10 maghiel 2012-09-06 13:00:20 UTC
(In reply to comment #9)
> Thanks. I thinks that it's QA privilege ;)

Ah ok, maybe I could only do it when I was in netcat then ;)