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 243760 - Generation of fluent setters should create "@return $this" instead of "@return \ClassName"
Summary: Generation of fluent setters should create "@return $this" instead of "@retur...
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: PHPDoc (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL: http://www.phpdoc.org/docs/latest/gui...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-11 09:39 UTC by fabiang
Modified: 2014-04-11 09:51 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fabiang 2014-04-11 09:39:59 UTC
Hallo,

the generation of fluent setters over the "Generate Getters and Setters" dialog currently creates the following PHPDoc comments for the following class:

Class A 
{
    /**
     * …
     * @return \A
     */
    public function setB($b)
    {
        …
    }
}

Latest PHPDoc version define a keyword "$this": "This exact object instance, usually used to denote a fluent interface." (http://www.phpdoc.org/docs/latest/guides/types.html#keywords). So instead of the above, Netbeans could simply generate:

Class A
{
    /**
     * …
     * @return $this
     */
    public function setB($b)
    {
        …
    }
}

This should also make the code for fetching the class name obsolete.
Also if the comment is manually changed to "@return $this" code completion still works, since NB seems to rely on the "return $this" statement inside the function.

Thanks.

By the way is Bug #239987 related to this?