pine3ree opened a new issue, #6119:
URL: https://github.com/apache/netbeans/issues/6119
### Apache NetBeans version
Apache NetBeans 18
### What happened
An "Abstract class `SomeClass` cannot be instantiated" appears when it
shouldn't.
This seems a class-variable name collision bug. Changing the variable name,
or reassigning it solves the issue.
### How to reproduce
Create a php file with the following content and open it:
```php
<?php
interface MyClassInterface
{
public function doSomething();
}
abstract class MyClass
{
public function doSomething()
{
}
abstract public function doSomethingElse();
}
class MySubClass extends MyClass implements MyClassInterface
{
public function doSomethingElse()
{
}
}
class MyClassFactory
{
public function buildObject(string $myClass)
{
if (class_exists($myClass) && is_subclass_of($myClass,
MyClass::class))
{
// This causes "can not be instantiated error"
$myObject = new $myClass();
// Just using another variable name prevents the bug
$myFQCN = $myClass;
$myObject = new $myFQCN();
}
}
// no error
public function createObject(string $myFQCN)
{
if (class_exists($myFQCN) && is_subclass_of($myFQCN,
MyClass::class)) {
$myObject = new $myFQCN();
}
}
}
```
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
mint/ubuntu 22.04
### JDK
java-11-openjdk-amd64
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else

### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists