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 267563 - "Implement all abstract methods" incorrectly handles "self" special return type
Summary: "Implement all abstract methods" incorrectly handles "self" special return type
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-12 20:31 UTC by zyxist
Modified: 2016-08-16 02:51 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 zyxist 2016-08-12 20:31:11 UTC
Hello again, I'm still playing with "Implement all abstract methods" feature and I noticed that "self" special type is incorrectly handled, resulting in a PHP code that ends up with a fatal error.

Example interface:

~~~
namespace Aaa;

interface FooInterface {
   public function xyz(): self;
}
~~~

According to PHP manual for 'self': "The parameter must be an instanceof the same class as the one the method is defined on". In case of implementing an interface or overwriting a method in a child class, `self` must be replaced with a concrete *parent* type name. Otherwise, PHP shows an error that the declaration of the overwriting method does not match to the prototype.

Expected result of "Implement all abstract methods" from the interface above:

~~~
namespace Aaa;

class Bar implements FooInterface {
   public function xyz(): FooInterface {

   }
}
~~~

Actual result:

~~~
namespace Aaa;

class Bar implements FooInterface {
   public function xyz(): \self {

   }
}
~~~

The same may also apply to the method arguments. Tested on the nightly build 2016081220002.
Comment 1 Tomas Mysik 2016-08-15 06:59:30 UTC
Thanks for catching that and for perfect report. Should be fixed now, please verify if possible.

Thanks.

http://hg.netbeans.org/web-main/rev/0c5a425b55b2
Comment 2 Quality Engineering 2016-08-16 02:51:34 UTC
Integrated into 'main-silver', will be available in build *201608160002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0c5a425b55b2
User: Tomas Mysik <tmysik@netbeans.org>
Log: #267563 - "Implement all abstract methods" incorrectly handles "self" special return type