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 239987 - "@return $this" in phpDoc
Summary: "@return $this" in phpDoc
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal with 4 votes (vote)
Assignee: Tomas Mysik
URL:
Keywords:
: 245129 258440 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-01-04 16:12 UTC by Aequiternus
Modified: 2016-03-20 02:53 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
patch (35.86 KB, patch)
2016-01-22 06:09 UTC, junichi11
Details | Diff
patch-v2 (35.13 KB, patch)
2016-01-27 05:53 UTC, junichi11
Details | Diff
a missing file (7.40 KB, patch)
2016-01-28 14:06 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aequiternus 2014-01-04 16:12:56 UTC
I'v found that there is keyword "$this" for type definitions in phpDocumentor: http://phpdoc.org/docs/latest/guides/types.html. NetBeans uses keyword "this" instead. I suggest to add keyword "$this" as alias for "this".
Comment 1 Barryvdh 2014-08-05 10:31:18 UTC
Agreed, more and more frameworks are using '$this'. The behavior already exists in Netbeans, it just uses 'this' for some reason. The valid return types are 'self', 'static' and '$this'.
As said, this is in the latest docs and in the PSR-5 Proposal: https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#keyword
Comment 2 junichi11 2016-01-22 06:09:34 UTC
Created attachment 158216 [details]
patch

I've created a patch.
Comment 3 junichi11 2016-01-22 06:16:04 UTC
Tomas, could you please review it?

1. VariousUtils, ModelVisitor
Currently, "\this" is supported. So if "$this" is written with @return, just replace it to "\this".

2. FunctionScopeImpl
Now, there are a few differences between "@retern \this" and "return $this".
e.g.
- If "@return \this" is used, resolves the caller type. "return $this" doesn't.
- If "@return \this" is used with other types(@return \this|MyClass|MyClass2), the other types(MyClass, MyClass2) are ignored.

So I fixed them.

3. test/unit/data/testfiles/completion/lib/test216119/test216119.php.testUseCase1.completion

In this context, $this means the Test class.

4. PHPCommentGenerator
If return type is "\this", convert to "$this". 

5. about trait case
I think that it is related to issue 256106[1]. I'll look at it later.

[1] https://netbeans.org/bugzilla/show_bug.cgi?id=256106

Thanks.
Comment 4 Tomas Mysik 2016-01-22 07:55:48 UTC
Will have a look at it, thanks a lot, Junichi!
Comment 5 junichi11 2016-01-27 05:53:01 UTC
Created attachment 158238 [details]
patch-v2

> 3.
> test/unit/data/testfiles/completion/lib/test216119/test216119.php.
> testUseCase1.completion

This is wrong, sorry. I noticed that there is a part I forgot to remove(I fixed a little when I look at issue 256106). I think that it should be fixed with 256106. So, I recreated a patch.

Thanks.
Comment 6 Tomas Mysik 2016-01-28 10:05:56 UTC
Patch applied, thanks a lot for it, Junichi!

http://hg.netbeans.org/web-main/rev/b5f567919204
Comment 7 junichi11 2016-01-28 14:06:33 UTC
Created attachment 158267 [details]
a missing file

I'm sorry. I forgot to add a test file...
Comment 8 Tomas Mysik 2016-01-28 14:26:00 UTC
(In reply to junichi11 from comment #7)
> I'm sorry. I forgot to add a test file...

Pushed, thanks for it!

http://hg.netbeans.org/web-main/rev/35bd17068827
Comment 9 junichi11 2016-01-28 14:30:55 UTC
Thanks for applying it quickly!
Comment 10 Quality Engineering 2016-01-29 02:37:33 UTC
Integrated into 'main-silver', will be available in build *201601290002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b5f567919204
User: Tomas Mysik <tmysik@netbeans.org>
Log: #239987 - "@return $this" in phpDoc

Patch contributed by junichi11@netbeans.org.
Comment 11 junichi11 2016-03-16 12:28:58 UTC
*** Bug 245129 has been marked as a duplicate of this bug. ***
Comment 12 junichi11 2016-03-20 02:53:35 UTC
*** Bug 258440 has been marked as a duplicate of this bug. ***