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

Fix non-facade classes will result in no autocomplete #841

Merged
merged 2 commits into from Feb 7, 2024

Conversation

netpok
Copy link
Contributor

@netpok netpok commented Oct 28, 2019

Currently non-facade classes are resulting non functioning autocomplete. The reason of this that an empty class will be defined in the ide helper class, which will be used for the auto-completion. This pull request prevents this behavior by only handling facades in the namespaced part of the helper file.

Unlike #802 this pull request will keep the alias registration.

Fixes #784

@mfn
Copy link
Collaborator

mfn commented Oct 28, 2019

@netpok
Copy link
Contributor Author

netpok commented Oct 28, 2019

Hoops, I accidentally removed the spaces (not that they should be there).

@mfn
Copy link
Collaborator

mfn commented Jan 4, 2020

Seems to me this is the same as #802 but with less "noise"?

@netpok
Copy link
Contributor Author

netpok commented Jan 25, 2020

Sorry for the late reply, the problem with #802 is that it will remove the Arr and Str classes from the

namespace{
    // ...
}

section so the \Arr and \Str calls will lose autocomplete.

Also the import

use Illuminate\Support\Facades;

should be

use Illuminate\Support\Facades\Facade;

because currently it filters out all the facades. I think this was some newer change because originally it worked for me (I think).


This version does not have the mentioned issues. Also I rebased my pull request to the latest master.

Copy link

@nalatreb nalatreb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should update your branch, because there are changes in this method: getAliasesByExtendsNamespace

@netpok
Copy link
Contributor Author

netpok commented Feb 27, 2021

Ok. I rebased it to current master.

Comment on lines -24 to -26
<?php if ($namespace == '\Illuminate\Database\Eloquent') :
continue;
endif; ?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

Copy link
Contributor Author

@netpok netpok Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was originally filtered out because it's not a facade so it doesn't need to be there but all non facade classes are filtered out already.

I found the original issue: #451, it was basically the same as this but then it was only limited to one class (Model) instead of three (Model, Arr, Str).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice, thank you 👍

Copy link
Collaborator

@mfn mfn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM

There's one thing I'm not sure: AFAIK people sometimes expect non-Facades also to show up here, which would have happened before.

Also I hope at some day we can have some tests for this, but I see that this isn't easy here…

@mfn mfn requested a review from barryvdh March 12, 2021 17:04
@netpok
Copy link
Contributor Author

netpok commented Mar 12, 2021

Basically you don't want the non Facade classes show up there as they would be empty and break the aliased classes. They still show up in the alias section, so Illuminate\Support\Arr will not be here but \Arr extends Illuminate\Support\Arr will be here.

@mfn
Copy link
Collaborator

mfn commented Mar 12, 2021

Thank you for your clarification, makes sense to me!

@netpok
Copy link
Contributor Author

netpok commented Apr 15, 2021

Does this PR needs any more attention from me or is it good for now?

@mfn
Copy link
Collaborator

mfn commented Apr 15, 2021

Good question, I think we wait for approval from @barryvdh

image

@netpok
Copy link
Contributor Author

netpok commented Jun 14, 2021

@barryvdh Any blocking reason here I should resolve?

@KentarouTakeda
Copy link
Contributor

@barryvdh @mfn
Do we have any update?
With this nice fix, It will prevent phpstan>=1.7 from reporting many errors to empty helper class.

@mfn
Copy link
Collaborator

mfn commented Jul 1, 2022

Still has my 👍🏼 !

@snmatsui
Copy link
Contributor

ping

@barryvdh barryvdh merged commit f465625 into barryvdh:master Feb 7, 2024
d3v2a pushed a commit to d3v2a/laravel-ide-helper that referenced this pull request Feb 16, 2024
* Filter out non-facade base classes

* Remove Model as it is already skipped because it's not a facade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Laravel added aliases for 'Arr' and 'Str' no autocomplete from helper
6 participants