When you have two classes where where the second class has name of first class as prefix and postfix (eg class "Test" and class "TestMyTest") and you use the first class (Test) in the same namespace, the "Fix imports" will always select "TestMyTest" although the name does not match.
If you use them from a different namespace, there is no automatic selection, but the selected class in the drop down is again TestMyTest``
Language / Project Type / NetBeans Component
PHP project
How to reproduce
Create three classes (separate files):
Class:
<?php
declare(strict_types=1);
namespace Issue;
class Test {
}
2. Class
<?php
declare(strict_types=1);
namespace Issue;
class TestMyTest {
}
3. Class
<?php
declare(strict_types=1);
namespace Issue;
class Main {
private Test $test;
}
Then call "Fix imports" in class Main. It will replace "private Test $test" with "private TestMyTest $test".
When you revert the change and then remove the namespace in Main.php and do "Fix imports", it will suggest "\Issue\TestMyTest" in the dropdown. It will also show "\Issue\Test", but it is not pre-selected.
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Debian 12
### JDK
OpenJDK 17.0.11
### Apache NetBeans packaging
Apache NetBeans Snap Package, Other
### Anything else
always
### Are you willing to submit a pull request?
No
Apache NetBeans version
Apache NetBeans 22
What happened
When you have two classes where where the second class has name of first class as prefix and postfix (eg class "Test" and class "TestMyTest") and you use the first class (Test) in the same namespace, the "Fix imports" will always select "TestMyTest" although the name does not match. If you use them from a different namespace, there is no automatic selection, but the selected class in the drop down is again TestMyTest``
Language / Project Type / NetBeans Component
PHP project
How to reproduce
Create three classes (separate files):
}
<?php declare(strict_types=1); namespace Issue; class TestMyTest {
}
<?php declare(strict_types=1); namespace Issue; class Main { private Test $test; }