@@ -67,6 +67,44 @@ public function betweenNonLiteralString3(EntityManagerInterface $em): void
6767 assertType ('string ' , $ result );
6868 }
6969
70+ public function countDistinctLiteralString (EntityManagerInterface $ em ): void
71+ {
72+ $ result = $ em ->createQueryBuilder ()->expr ()->countDistinct ('A ' , 'B ' , 'C ' );
73+ assertType ("'COUNT(DISTINCT A, B, C)' " , $ result ); // A ConstantStringType isLiteralString
74+ }
75+
76+ public function countDistinctNonLiteralString1 (EntityManagerInterface $ em ): void
77+ {
78+ $ value = $ this ->nonLiteralString ('A ' );
79+ $ result = $ em ->createQueryBuilder ()->expr ()->countDistinct ($ value );
80+ assertType ('string ' , $ result );
81+ }
82+
83+ public function countDistinctNonLiteralString2 (EntityManagerInterface $ em ): void
84+ {
85+ $ value = $ this ->nonLiteralString ('A ' );
86+ $ result = $ em ->createQueryBuilder ()->expr ()->countDistinct ($ value , 'B ' , 'C ' );
87+ assertType ('string ' , $ result );
88+ }
89+
90+ // Disabled until Doctrine ORM 3.0.0, as the countDistinct() function definition does not use `countDistinct(...$x)`
91+ // https://github.com/doctrine/orm/pull/9911
92+ // https://github.com/phpstan/phpstan-doctrine/pull/352
93+ //
94+ // public function countDistinctNonLiteralString3(EntityManagerInterface $em): void
95+ // {
96+ // $value = $this->nonLiteralString('B');
97+ // $result = $em->createQueryBuilder()->expr()->countDistinct('A', $value, 'C');
98+ // assertType('string', $result);
99+ // }
100+ //
101+ // public function countDistinctNonLiteralString4(EntityManagerInterface $em): void
102+ // {
103+ // $value = $this->nonLiteralString('C');
104+ // $result = $em->createQueryBuilder()->expr()->countDistinct('A', 'B', $value);
105+ // assertType('string', $result);
106+ // }
107+
70108 // Might be a problem, as these do not return a 'literal-string'.
71109 // As in, functions to support MOD() and ABS() return stringable value objects (Expr\Func).
72110 public function isNullNonLiteralStringExprFunc (EntityManagerInterface $ em ): void
0 commit comments