Skip to content

Commit

Permalink
Fix QueryBuilder methods affecting result type with a denylist rather…
Browse files Browse the repository at this point in the history
… than allowlist
  • Loading branch information
ondrejmirtes committed Nov 17, 2023
1 parent 2043b72 commit c94f43b
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ class QueryBuilderGetQueryDynamicReturnTypeExtension implements DynamicMethodRet
* Those are critical methods where we need to understand arguments passed to them, the rest is allowed to be more dynamic
* - this list reflects what is implemented in QueryResultTypeWalker
*/
private const METHODS_AFFECTING_RESULT_TYPE = [
'add',
'select',
'addselect',
'from',
'join',
'innerjoin',
'leftjoin',
'indexby',
private const METHODS_NOT_AFFECTING_RESULT_TYPE = [
'where',
'andwhere',
'orwhere',
'setparameter',
'setparameters',
'addcriteria',
'addorderby',
'orderby',
'addgroupby',
'groupby',
'having',
'andhaving',
'orhaving',
];

/** @var ObjectMetadataResolver */
Expand Down Expand Up @@ -154,7 +159,7 @@ public function getTypeFromMethodCall(
try {
$args = $this->argumentsProcessor->processArgs($scope, $methodName, $calledMethodCall->getArgs());
} catch (DynamicQueryBuilderArgumentException $e) {
if (!in_array($lowerMethodName, self::METHODS_AFFECTING_RESULT_TYPE, true)) {
if (in_array($lowerMethodName, self::METHODS_NOT_AFFECTING_RESULT_TYPE, true)) {
continue;
}
return $defaultReturnType;
Expand Down

0 comments on commit c94f43b

Please sign in to comment.