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

Summary: "Implement all abstract methods" incorrectly handles "self" special return type
Product: php Reporter: zyxist
Component: EditorAssignee: Tomas Mysik <tmysik>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 8.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

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