netbeans
netbeans copied to clipboard
Anonymous class using a trait with asbtract method inside another class
Apache NetBeans version
Apache NetBeans 26 latest release candidate
What happened
Using anonymous class inside a class that uses a trait with an asbtract method causes a missing implementation issue on the wrapping class
Language / Project Type / NetBeans Component
PHP
How to reproduce
The issue can be reproduced just using the following code. For simplicity I added both a test trait and a consumer test class in the same file
<?php
trait MyTrait
{
abstract function doSomething();
public function doNothing()
{
}
}
class MyClass
{
public function getMyTraitAwareObject()
{
return new class() {
use MyTrait;
// doSomething is declared abstract in MyTrait.php
public function doSomething()
{
}
};
}
}
Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux mint/ubuntu 22.04
JDK
java-17-openjdk-amd64
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
Affects version 25 and 26, not checked previous versions
Are you willing to submit a pull request?
No