Commit 4f58abc 1 parent 310ab0f commit 4f58abc Copy full SHA for 4f58abc
File tree 2 files changed +65
-0
lines changed
tests/Type/Doctrine/data/QueryResult
2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Type \Doctrine \data \QueryResult \Entities ;
5
+
6
+ use Doctrine \ORM \Mapping \Column ;
7
+ use Doctrine \ORM \Mapping \Entity ;
8
+ use Doctrine \ORM \Mapping \GeneratedValue ;
9
+ use Doctrine \ORM \Mapping \Id ;
10
+
11
+ interface VehicleInterface
12
+ {
13
+
14
+ }
15
+
16
+ /**
17
+ * @Entity
18
+ */
19
+ class Car implements VehicleInterface
20
+ {
21
+ /**
22
+ * @GeneratedValue()
23
+ * @Column(type="integer")
24
+ * @Id
25
+ *
26
+ * @var string
27
+ */
28
+ public $ id ;
29
+ }
30
+
31
+ /**
32
+ * @Entity
33
+ */
34
+ class Truck implements VehicleInterface
35
+ {
36
+ /**
37
+ * @GeneratedValue()
38
+ * @Column(type="integer")
39
+ * @Id
40
+ *
41
+ * @var string
42
+ */
43
+ public $ id ;
44
+ }
Original file line number Diff line number Diff line change 9
9
use Doctrine \ORM \Query \Expr \From ;
10
10
use Doctrine \ORM \QueryBuilder ;
11
11
use QueryResult \Entities \Many ;
12
+ use Type \Doctrine \data \QueryResult \Entities \Truck ;
13
+ use Type \Doctrine \data \QueryResult \Entities \VehicleInterface ;
12
14
use function PHPStan \Testing \assertType ;
13
15
14
16
class QueryBuilderGetQuery
@@ -118,6 +120,20 @@ public function testQueryResultTypeIsMixedWhenDQLIsInvalid(EntityManagerInterfac
118
120
assertType ('Doctrine\ORM\Query<mixed, mixed> ' , $ query );
119
121
}
120
122
123
+ public function testQueryResultTypeIsMixedWhenDQLIsUsingAnInterfaceTypeDefinition (EntityManagerInterface $ em ): void
124
+ {
125
+ $ vehicle = $ this ->createVehicule ();
126
+
127
+ assertType (VehicleInterface::class, $ vehicle );
128
+
129
+ $ query = $ em ->createQueryBuilder ()
130
+ ->select ('v ' )
131
+ ->from (get_class ($ vehicle ), 'v ' )
132
+ ->getQuery ();
133
+
134
+ assertType ('Doctrine\ORM\Query<null, mixed> ' , $ query );
135
+ }
136
+
121
137
public function testQueryResultTypeIsVoidWithDeleteOrUpdate (EntityManagerInterface $ em ): void
122
138
{
123
139
$ query = $ em ->getRepository (Many::class)
@@ -261,4 +277,9 @@ private function getBranchingQueryBuilder(EntityManagerInterface $em): QueryBuil
261
277
262
278
return $ queryBuilder ;
263
279
}
280
+
281
+ private function createVehicule (): VehicleInterface
282
+ {
283
+ return new Truck ();
284
+ }
264
285
}
You can’t perform that action at this time.
0 commit comments