Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing global PHP functions #4527

Open
szymach opened this issue Aug 22, 2022 · 3 comments
Open

Importing global PHP functions #4527

szymach opened this issue Aug 22, 2022 · 3 comments
Labels
kind:feature A feature request needs:triage Requires attention from one of the committers PHP [ci] enable extra PHP tests (php/php.editor)

Comments

@szymach
Copy link

szymach commented Aug 22, 2022

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 szymach added kind:feature A feature request needs:triage Requires attention from one of the committers labels Aug 22, 2022
@troizet troizet added the PHP [ci] enable extra PHP tests (php/php.editor) label Jan 23, 2024
@junichi11
Copy link
Member

Could you also write an example code?

@szymach
Copy link
Author

szymach commented Feb 16, 2024

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

@junichi11
Copy link
Member

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 (#7027)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature A feature request needs:triage Requires attention from one of the committers PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

No branches or pull requests

3 participants