netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Anonymous class using a trait with asbtract method inside another class

Open pine3ree opened this issue 7 months ago • 0 comments

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

Image

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

pine3ree avatar May 23 '25 17:05 pine3ree