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 221725 - Adding a new object declaration in a fluent method call gives the wrong suggestions
Summary: Adding a new object declaration in a fluent method call gives the wrong sugge...
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-08 13:07 UTC by shanethehat
Modified: 2012-11-13 02:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of autocomplete suggestion (81.75 KB, image/png)
2012-11-08 13:07 UTC, shanethehat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description shanethehat 2012-11-08 13:07:54 UTC
Created attachment 127394 [details]
Screenshot of autocomplete suggestion

If a new object is created in a call to a setter that implements a fluent interface, the autocomplete suggestions for the next call will be for the wrong object.

e.g.

class MyClass
{
    public function setFoo($foo)
    {
        $this->foo = $foo;
        return this;
    }

    public function setBar($bar)
    {
        ...
    }
}


$class = new MyClass();
$class->setFoo(newDateTime)->  // autocomplete now displays the interface for DateTime
Comment 1 Ondrej Brejla 2012-11-08 13:33:08 UTC
You have 2 mistakes in your code, but it's reproducible in this code:

<?php

class MyClass1
{
    public function setFoo($foo)
    {
        $this->foo = $foo;
        return $this;
    }

    public function setBar($bar)
    {
        
    }
}

$class = new MyClass1();
$class->setFoo(new DateTime())->
        
?>
Comment 2 Ondrej Brejla 2012-11-08 13:33:54 UTC
It doesn't work in 7.2 either.
Comment 3 shanethehat 2012-11-08 13:38:32 UTC
(In reply to comment #1)
> You have 2 mistakes in your code, but it's reproducible in this code:
> 
> <?php
> 
> class MyClass1
> {
>     public function setFoo($foo)
>     {
>         $this->foo = $foo;
>         return $this;
>     }
> 
>     public function setBar($bar)
>     {
> 
>     }
> }
> 
> $class = new MyClass1();
> $class->setFoo(new DateTime())->
> 
> ?>

Sorry, typed too fast. The attachment shows it actually happening without the typos.
Comment 4 Ondrej Brejla 2012-11-12 13:35:09 UTC
Fixed in web-main #823d4423f8d1
Comment 5 Quality Engineering 2012-11-13 02:43:25 UTC
Integrated into 'main-golden', will be available in build *201211130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/823d4423f8d1
User: Ondrej Brejla <obrejla@netbeans.org>
Log: #221725 - Adding a new object declaration in a fluent method call gives the wrong suggestions