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

Configuration loading #10

Open
2 of 3 tasks
weirdan opened this issue Mar 13, 2019 · 9 comments
Open
2 of 3 tasks

Configuration loading #10

weirdan opened this issue Mar 13, 2019 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@weirdan
Copy link
Member

weirdan commented Mar 13, 2019

This plugin needs to be able to load doctrine configuration for functionality like checking entity types, findBy* methods, etc.

Requires:

  • stubbing the connection so that no database is required
  • replacing reflection service so that classes need not to be loaded
  • fixing the annotation reader (or replacing it with custom one) so that classes need not to be loaded
@weirdan weirdan added the enhancement New feature or request label Mar 13, 2019
@weirdan weirdan self-assigned this Mar 13, 2019
This was referenced Mar 13, 2019
weirdan added a commit that referenced this issue Mar 23, 2019
Limitation: only XML mapping is supported. Annotations require more
work, and YAML mapping requires test infra support.

Refs #10
@vv12131415
Copy link

@ weirdan Can you please describe in more details?
I would like to try my self to fix\resolve this

@vv12131415
Copy link

@weirdan some why you have not been mentioned

@iluuu1994
Copy link

phpstan-doctrine allows providing an EntityManager instance so that the plugin can infer repositories. Maybe that would be easier?

@vv12131415
Copy link

stubbing the connection so that no database is required
replacing reflection service so that classes need not to be loaded

@iluuu1994 I think those comments mean that @weirdan doesn't want to load whole application in order to get entity manager.

But on the other hand, I'm more on the @iluuu1994 side, only the real entity manager can tell us real return types. And it will also be able to parse and validate DQL.

On the other hand, it will be dynamic code analysis ( nothing bad, but its not SA anymore)

@weirdan can you please explain your POV

@iluuu1994
Copy link

@vladyslavstartsev

I think those comments mean that @weirdan doesn't want to load whole application in order to get entity manager.

Yeah but it could also be opt-in. If you want more accurate analysis you'd need to provide a real EntityManager instance. Otherwise we'd either have to:

  1. Repeat the whole configuration in a psalm config
  2. Make psalm understand every type of doctrine configuration (xml, yaml, annotations, etc) which is just not practical

@beberlei
Copy link

Doctrine has a static metadata driver / reflection component where you can read the configuration almost without executing code, only reading the configuration. You can look at the EntityGenerator or Convert Database to Entity commands to see how to use them. If you go low level enough, you don't need the EntityManager as far as i remember.

Another option that the Symfony psalm plugin uses is to load the "cached" metadata (or cahced container.xml in that case). Doctrine writes configuration to the cache as serialized class metadata. You could load that without needing much of anything runtime doctrine code.

@vv12131415
Copy link

I should probably mention it here
https://twitter.com/IssecMura/status/1274068540950302720?s=19

@michnovka
Copy link
Contributor

Hi @weirdan just wanted to ask whether you have some spare time for this in the near future. Thanks!

@weirdan
Copy link
Member Author

weirdan commented Apr 18, 2022

Unlikely to happen anytime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants