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

[WIP] Orm querybuilder set parameters to collection v2 #346

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcelthole
Copy link
Contributor

Additional checks to #326

…ection for the setParameters ORM QueryBuilder method
…ters if the variable is used in a ORM QueryBuilder
Copy link

@JoolsMcFly JoolsMcFly left a comment

Choose a reason for hiding this comment

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

Hi @marcelthole.

Thought I could chime in and comment on your code a bit.

$arrayValueType = $this->nodeTypeResolver->getType($value->value);
if (! $arrayValueType instanceof ObjectType || ! $arrayValueType->isInstanceOf(
'Doctrine\\ORM\\Query\\Parameter'
)->yes()) {

Choose a reason for hiding this comment

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

Same here

$arrayValueType->isInstanceOf('Doctrine\\ORM\\Query\\Parameter')->no()

return null;
}

if (! $varType->isInstanceOf('Doctrine\\ORM\\QueryBuilder')->yes()) {

Choose a reason for hiding this comment

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

Same here:

$varType->isInstanceOf('Doctrine\\ORM\\QueryBuilder')->no()

&& $stmt->expr->name->name === 'setParameters'
) {
$varType = $this->nodeTypeResolver->getType($stmt->expr->var);
if (! $varType->isInstanceOf('Doctrine\\ORM\\QueryBuilder')->yes()) {

Choose a reason for hiding this comment

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

Instead of not yes you could just use no so

! $varType->isInstanceOf('Doctrine\\ORM\\QueryBuilder')->yes()

can be changed to:

$varType->isInstanceOf('Doctrine\\ORM\\QueryBuilder')->no()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

overall i would say the same but the varType as also the type MAYBE - And in that cases i do not want to modify the values. But i will try to test this also with an fixture

@@ -0,0 +1,27 @@
<?php

Copy link
Member

Choose a reason for hiding this comment

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

like other PR, please add namespace if possible

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 will rebase this PR and apply all the fixes after the other one is done if this is fine for you

@@ -0,0 +1,27 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

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

use underscored fixture file name instead of dash

foreach ($variables as $variable) {
$this->iterateThroughStmts($node->getStmts(), $variable);
}

Copy link
Member

Choose a reason for hiding this comment

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

verify to return null if no change

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.

3 participants