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 269760 - Return type of `self` not recognised
Summary: Return type of `self` not recognised
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: issues@php
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-06 16:05 UTC by WebSmithery
Modified: 2017-02-06 16:33 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description WebSmithery 2017-02-06 16:05:14 UTC

    
Comment 1 WebSmithery 2017-02-06 16:31:36 UTC
`return $this` causes a method to return its own object.

1) When this code is used and PHP Doc comments are then added, NetBeans automatically puts `@return $this` which, as far as I understand it, is not valid PhpDoc usage. Rather it should be `@return self` or `@return TheNameOfTheClass`

2) If a return type declaration is attempted in the PHP, e.g. `public function MyMethod(): self`, then once the colon has been typed and code completion is requested the six data types are suggested and the names of classes, but not `self`.

3) If `self` is added manually and PHP Doc comments are then added, NetBeans will treat `self` as it is the name of a class, meaning that if you're in a namespace, it will prepend a backslash for the root namespace i.e. `@return \self`, which again is not correct documentation.

It seems that NetBeans does not recognise the keyword `self` as a return-type alias for the current class.