diff --git a/src/Type/Doctrine/ArgumentsProcessor.php b/src/Type/Doctrine/ArgumentsProcessor.php index 4a5b316d..3c6d0637 100644 --- a/src/Type/Doctrine/ArgumentsProcessor.php +++ b/src/Type/Doctrine/ArgumentsProcessor.php @@ -47,6 +47,12 @@ public function processArgs( $args[] = $array; continue; } + + if ($value->isClassStringType()->yes() && count($value->getClassStringObjectType()->getObjectClassNames()) === 1) { + $args[] = $value->getClassStringObjectType()->getObjectClassNames()[0]; + continue; + } + if (count($value->getConstantScalarValues()) !== 1) { throw new DynamicQueryBuilderArgumentException(); } diff --git a/tests/Type/Doctrine/data/QueryResult/queryBuilderGetQuery.php b/tests/Type/Doctrine/data/QueryResult/queryBuilderGetQuery.php index b27e8e29..3f4bd916 100644 --- a/tests/Type/Doctrine/data/QueryResult/queryBuilderGetQuery.php +++ b/tests/Type/Doctrine/data/QueryResult/queryBuilderGetQuery.php @@ -233,4 +233,33 @@ public function testDynamicMethodCall( assertType('mixed', $result); } + + /** + * @param class-string $many + */ + public function testRegularClassString(EntityManagerInterface $em, string $many) + { + $result = $em->createQueryBuilder() + ->select("m") + ->from($many, 'm') + ->getQuery() + ->getResult(); + + assertType('list', $result); + } + /** + * @param class-string $many + * @template T of Many + */ + public function testTemplatedClassString(EntityManagerInterface $em, string $many) + { + $result = $em->createQueryBuilder() + ->select("m") + ->from($many, 'm') + ->getQuery() + ->getResult(); + + assertType('list', $result); + } + }