question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doctrine2 magic repository methods

See original GitHub issue

In 0.8.0 release there was a note:

  • Detect EntityRepository::find/findOneBy/findAll/findBy result type

At the moment doctrine2 support behaves like this:

$repo = $this->getDoctrine()->getRepository('Namespace:Entity');
$entity = $repo->findOneByProperty('value'); // $entity does not resolve as an Entity
$entity = $repo->findOneBy(array('property' => 'value')) // $entity does resolve as an Entity and autocomplete works

Could you please implement resolving of magic methods like findOneBy* and findBy*?

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:2
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

8reactions
picks44commented, Oct 26, 2016

Same here, would love to have the “magic” Doctrine methods to be resolved in PHPStorm like findOneBy*

2reactions
Haehnchencommented, May 23, 2020

return type is resolved; did a quick test on the method completion, but there is now new API available to attach it

Read more comments on GitHub >

github_iconTop Results From Across the Web

PHPUnit Doctrine Repository magic methods - Stack Overflow
I have one method in my class that uses that magic method findOneBy... from the Doctrine EntityRepository, as showed below:.
Read more >
Working with Objects - Doctrine
The Repository implement the Doctrine\Common\Collections\Selectable interface. That means you can build Doctrine\Common\Collections\Criteria and pass them to ...
Read more >
How to use Repository with Doctrine as Service in Symfony
Mostly due to traditional registration of Doctrine repositories. ... You can use prepared methods like findBy() , findOneBy() right away ✓ ...
Read more >
How is Doctrine 2 different to Eloquent? - Culttt
This repository object has a number of helpful methods for querying the database, such as: $users = EntityManager::getRepository("Cribbb\ ...
Read more >
Inject a repository instead of an entity manager
However, I wasn't talking about entity repositories here. ... call that relies on the magic __call() method of the EntityRepository class.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found