netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Importing global PHP functions

Open szymach opened this issue 2 years ago • 3 comments

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

szymach avatar Aug 22 '22 11:08 szymach

Could you also write an example code?

junichi11 avatar Feb 14 '24 05:02 junichi11

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);
    }
}

szymach avatar Feb 16 '24 15:02 szymach

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.

  1. Copy & paste the example code
  2. ...
  3. ...

Actual result:

...

Expected result:

...

BTW, we are going to add the "Auto Import" feature in NetBeans 22 (https://github.com/apache/netbeans/pull/7027)

junichi11 avatar Feb 16 '24 15:02 junichi11