Skip to content

ManagerRegistry::getRepository returns correct EntityRepository #46

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

Merged
merged 1 commit into from
Feb 12, 2019

Conversation

mcfedr
Copy link
Contributor

@mcfedr mcfedr commented Feb 12, 2019

Similar to how ObjectManager:: getRepository works, but for ManagerRegistry

@ondrejmirtes
Copy link
Member

Hi, please also add some error on purpose to the example file so that it can be seen it’s the right type detected. It will generate a JSON file you also need to commit. Thanks.

@mcfedr mcfedr force-pushed the manager-registry branch 2 times, most recently from ecfb34f to 3318782 Compare February 12, 2019 10:29

public function findDynamicType(): void
{
$test = $this->managerRegistry->getRepository(MyEntity::class)->createQueryBuilder('e');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think its a bit more obvious now, createQueryBuilder is only on EntityRepository, not ObjectRepository that would normally be the type

Copy link
Member

Choose a reason for hiding this comment

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

This isn't what I meant. I didn't want phpstan-negative.neon that doesn't have the extension. Rather, I wanted to verify that the extension works. So I'd like to have only a single integration "levels" test that verifies that ManagerRegistry::getRepository() actually returns EntityRepository, by calling something nonexistent on the EntityRepository object.

So besides verifying that "Call to an undefined method Doctrine\Common\Persistence\ObjectRepository::createQueryBuilder()." does NOT GET reported, I'd also like to know that $this->managerRegistry->getRepository(MyEntity::class)->nonexistent() GETS reported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I think I see what you mean, so you want to prove its an entity manager because the error will say its an entity manager, and they dont have function x.

One moment :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the negative option didnt seem great, but i didnt understand what you where asking...

Copy link
Member

Choose a reason for hiding this comment

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

I want to see that $this->managerRegistry->getRepository(MyEntity::class) returns the right thing and not just mixed (that silents all errors).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its done now.

@mcfedr mcfedr force-pushed the manager-registry branch 2 times, most recently from f1c03b2 to 20f2eb1 Compare February 12, 2019 12:44
@ondrejmirtes
Copy link
Member

Thanks, perfect!

@ondrejmirtes ondrejmirtes merged commit 1a2ea00 into phpstan:master Feb 12, 2019
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