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

[Feature Request]: Add possibility to disable facades aliases generation to _ide_helper_facades.php #984

Closed
swayok opened this issue May 2, 2024 · 12 comments

Comments

@swayok
Copy link

swayok commented May 2, 2024

Feature Description

Feature Description
Hello.

I have disabled aliases for facades in config/app.php:

'aliases' => [],

But plugin still generates code assists for aliases in _ide_helper_facades.php:

namespace {
    class App extends Illuminate\Support\Facades\App {}
    class Arr extends Illuminate\Support\Arr {}
    ...
}

I think that some people also disable some or all aliases and then receive errors like "Class "Str" not found" when code assist suggests \Str instead of \Illuminate\Support\Str.

I asked about this some time ago (Issue #752) but after recent updates it started to generate helpers again. I think the best solution here will be an option in plugin settings like "Do not generate helper code for global Laravel facades".

Thank you for this great plugin!

@adelf
Copy link
Member

adelf commented May 2, 2024

I made some changes in aliases fetching just yesterday) I'll try to fix that somehow. Thank you.

@swayok
Copy link
Author

swayok commented May 2, 2024

It stopped working at least several weeks ago.
Also with Laravel 11, it may be harder to find out really declared Facades, so specific plugin setting for this situation may be easier to implement.

@adelf
Copy link
Member

adelf commented May 2, 2024

Packages can declare facade aliases by the composer.json "extras" section. You don't want to see them too?)

@swayok
Copy link
Author

swayok commented May 2, 2024

Yes. Magical global classes is bad for architecture. Actually all magic is bad, but some of it can be tolerated =)

@olivernybroe
Copy link

@adelf I can't seem to find the setting for this? Did I misunderstand and this wasn't added as a setting? 👀

The reason why I want to disable it is that it will block auto-import of the facades, because the global facade has the same name.

@adelf
Copy link
Member

adelf commented Jun 29, 2024

It's not released yet. I hope to do it next week.

@olivernybroe
Copy link

Ah that makes sense, thank you. 👍 You are doing an awesome work!

@adelf
Copy link
Member

adelf commented Jul 18, 2024

Fixed in Laravel Idea 8.2

@adelf adelf closed this as completed Jul 18, 2024
@NickSdot
Copy link

After upgrading to Laravel Idea 8.2, I had to do the following to make it actually work

1 ) Uncheck Laravel -> Helper Code Parameters -> Generate Facades helper code

image

2 ) Manually delete vendor/_laravel_idea/_ide_helper_facades.php

3 ) Regenerate Helper Code

@adelf
Copy link
Member

adelf commented Jul 22, 2024

I'm sorry, forgot to say. You can turn off this option, and the facades helper code will be generated without aliases.

image

@olivernybroe
Copy link

Thank you for this work :) Really nice for auto import!

@swayok
Copy link
Author

swayok commented Jul 22, 2024

@adelf Thank you! Works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants