Skip to content

Commit c94f43b

Browse files
committed
Fix QueryBuilder methods affecting result type with a denylist rather than allowlist
1 parent 2043b72 commit c94f43b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/Type/Doctrine/QueryBuilder/QueryBuilderGetQueryDynamicReturnTypeExtension.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@ class QueryBuilderGetQueryDynamicReturnTypeExtension implements DynamicMethodRet
3636
* Those are critical methods where we need to understand arguments passed to them, the rest is allowed to be more dynamic
3737
* - this list reflects what is implemented in QueryResultTypeWalker
3838
*/
39-
private const METHODS_AFFECTING_RESULT_TYPE = [
40-
'add',
41-
'select',
42-
'addselect',
43-
'from',
44-
'join',
45-
'innerjoin',
46-
'leftjoin',
47-
'indexby',
39+
private const METHODS_NOT_AFFECTING_RESULT_TYPE = [
40+
'where',
41+
'andwhere',
42+
'orwhere',
43+
'setparameter',
44+
'setparameters',
45+
'addcriteria',
46+
'addorderby',
47+
'orderby',
48+
'addgroupby',
49+
'groupby',
50+
'having',
51+
'andhaving',
52+
'orhaving',
4853
];
4954

5055
/** @var ObjectMetadataResolver */
@@ -154,7 +159,7 @@ public function getTypeFromMethodCall(
154159
try {
155160
$args = $this->argumentsProcessor->processArgs($scope, $methodName, $calledMethodCall->getArgs());
156161
} catch (DynamicQueryBuilderArgumentException $e) {
157-
if (!in_array($lowerMethodName, self::METHODS_AFFECTING_RESULT_TYPE, true)) {
162+
if (in_array($lowerMethodName, self::METHODS_NOT_AFFECTING_RESULT_TYPE, true)) {
158163
continue;
159164
}
160165
return $defaultReturnType;

0 commit comments

Comments
 (0)