Skip to content

Calling QueryBuilder::update is updating the type of the vairable or $this. #219

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
VincentLanglet opened this issue Oct 7, 2021 · 3 comments

Comments

@VincentLanglet
Copy link
Contributor

\PHPStan\dumpType($this);
$this->getEntityManager()->getRepository(WaitingList::class)->createQueryBuilder('w')->update();
\PHPStan\dumpType($this);

give me

263    Dumped type: $this(App\Core\Workflow\WorkflowProductStoreEventSubscriber)     
265    Dumped type: Doctrine\ORM\QueryBuilder

In the same way

$repo = $this->getEntityManager()->getRepository(WaitingList::class);
$repo->createQueryBuilder('w')->update();
\PHPStan\dumpType($repo);

is giving Dumped type: Doctrine\ORM\QueryBuilder instead of a repository.

If I manually remove the QueryBuilderTypeSpecifyingExtension, it fix my issue.

@VincentLanglet
Copy link
Contributor Author

I would say the part https://github.com/phpstan/phpstan-doctrine/blob/master/src/Type/Doctrine/QueryBuilder/QueryBuilderTypeSpecifyingExtension.php#L84-L86 is false.

while ($queryBuilderNode instanceof MethodCall) {
    $queryBuilderNode = $queryBuilderNode->var;
}

doesn't work when the var is not a QueryBuilder initially.

I can work on a PR but I would need some recommendation about the purpose of this class and how to fix it. @ondrejmirtes
Is there a way to check the variable is a QueryBuilder ?

@ondrejmirtes
Copy link
Member

Fixed by #220

@github-actions
Copy link

github-actions bot commented Nov 9, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants