netbeans
netbeans copied to clipboard
Importing global PHP functions
Description
Hello!
Right now only functions from other namespaces can be imported (and count
for some reason) with the use function
directive. All other display the cannot be resolved
in the Fix imports in Current Namespace
window.
Use case/motivation
I have found the use function
to be far more elegant than the prefixed syntax, but I have to do it manually. Being able to import them automatically like the class names would save a lot of tedious minor work.
Related issues
No response
Are you willing to submit a pull request?
No
Code of Conduct
Yes
Could you also write an example code?
Does this explain my meaning, or should I also include how it should happen in the IDE?
namespace Demo;
use function in_array;
class someClass
{
public function someMethod(string $key): bool
{
return in_array($key, ['a value'], true);
}
}
should I also include how it should happen in the IDE
Yes, well, it would be nice if you write your exact steps, an actual result, and an expected result.
- Copy & paste the example code
- ...
- ...
Actual result:
...
Expected result:
...
BTW, we are going to add the "Auto Import" feature in NetBeans 22 (https://github.com/apache/netbeans/pull/7027)