Skip to content

Handle multiple Doctrine managers #127

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Mika56
Copy link

@Mika56 Mika56 commented May 14, 2020

This is a merge request trying to solve #53
This is a work in progress, your contributions are welcome!

I've pushed a first proof of concept for now, there's still a lot to do:

  • Completely remove ObjectMetadataResolver::getObjectManager() in favor of ObjectMetadataResolver::getObjectManagerForClass(). Remaining usages:
    • DqlRule::processNode line 57
    • QueryBuilderDqlRule::processNode line 80
    • QueryBuilderGetQueryDynamicReturnTypeExtension::getTypeFromMethodCall line 71
    • ExpressionBuilderDynamicReturnTypeExtension::getTypeFromMethodCall line 71
  • There is not tests for setting an AbstractManagerRegistry instead of an ObjectManager for parameters.doctrine.objectManagerLoader
  • We might want to use another parameter as to not introduce confusion

With these changes, PHPStan is capable of analyzing simple code that uses multiple managers

@ondrejmirtes
Copy link
Member

The hard questions are:

  1. What EM should we choose for DQL? How are DQL/QueryBuilders called when using ManagerRegistry in Doctrine in general?
  2. What should we do when the user provides ManagerRegistry to PHPStan but in code we get EntityManager without any context?

@ondrejmirtes
Copy link
Member

Please open a new PR if you decide to work on this again. Thanks.

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.

2 participants