Skip to content

Autocomplete for Doctrine findBy and findAll methods shows setters/getters from way too many entities #1422

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

Open
MrFox42 opened this issue Jan 21, 2020 · 2 comments

Comments

@MrFox42
Copy link

MrFox42 commented Jan 21, 2020

In this example, I have a small application with only a few entities: Entry, EntryPicture, and User.

After writing the following code in a controller function:

$entries = $this->getDoctrine()->getRepository('App:Entry')->findAll();

autocomplete for the returned objects lists methods from Entry and EntryPicture.

If I add one more line, for example to fetch all users, it gets even messier.

$entries = $this->getDoctrine()->getRepository('App:Entry')->findAll();
$users = $this->getDoctrine()->getRepository('App:User')->findAll();

Now autocomplete lists methods from all 3 of my entities for objects from both $entries and $users.

phpstormsymfonyfindall

Using findBy results in the same problem, however find and findOneBy works fine.

I've tried this with multiple projects ranging from Symfony version 4.2 to 4.4 to make sure it's not an isolated issue.

Additional info: I have this issue in both PhpStorm 2019.3.1 and 2019.3.2 RC.

@jackbentley
Copy link

Having a similar issue. Sometimes I just get it not resolving the return type of the findBy to any entity. Other times it's resolving to the wrong entity.

Symfony: 3.4.37
Doctrine ORM: 2.7.1
Doctrine DBAL: 2.9.3

@chiqui3d
Copy link

chiqui3d commented May 5, 2020

$user = $this->getDoctrine()->getManager()->getRepository(User::class)->find(1);
$user->... not autocomplete
$user = $this->getDoctrine()->getRepository(User::class)->createQueryBuilder('u')->..not autocomplete;

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

No branches or pull requests

3 participants