File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed
Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class QueryBuilderGetQueryDynamicReturnTypeExtensionTest extends TypeInferenceTe
1111 public function dataFileAsserts (): iterable
1212 {
1313 yield from $ this ->gatherAssertTypes (__DIR__ . '/../data/QueryResult/queryBuilderGetQuery.php ' );
14+ yield from $ this ->gatherAssertTypes (__DIR__ . '/../data/QueryResult/bug-245.php ' );
1415 }
1516
1617 /**
Original file line number Diff line number Diff line change 88use Doctrine \ORM \Mapping \JoinColumn ;
99use Doctrine \ORM \Mapping \JoinColumns ;
1010use Doctrine \ORM \Mapping \ManyToOne ;
11+ use Doctrine \ORM \Mapping as ORM ;
1112
1213/**
1314 * @Entity
@@ -102,3 +103,38 @@ class Many
102103 */
103104 public $ compoundPkAssoc ;
104105}
106+
107+ /**
108+ * @Entity
109+ */
110+ class Bug245Episode
111+ {
112+ /**
113+ * @var \Doctrine\Common\Collections\Collection<Bug245Segment>
114+ * @ORM\OneToMany(
115+ * targetEntity="App\VideoBundle\Entity\Segment",
116+ * mappedBy="episode",
117+ * cascade={"persist", "remove"},
118+ * orphanRemoval=true
119+ * )
120+ * @ORM\OrderBy({"position" = "ASC"})
121+ */
122+ private $ segments ;
123+ }
124+
125+ /**
126+ * @ORM\Entity
127+ */
128+ class Bug245Segment
129+ {
130+ /**
131+ * @ORM\ManyToOne(
132+ * targetEntity="App\VideoBundle\Entity\Episode",
133+ * inversedBy="segments",
134+ * cascade={"persist"}
135+ * )
136+ * @ORM\JoinColumn(name="episode_id", referencedColumnName="id", nullable=false)
137+ * @var Bug245Episode
138+ */
139+ private $ episode ;
140+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace QueryResult \CreateQuery ;
4+
5+ use Doctrine \ORM \EntityManager ;
6+ use QueryResult \Entities \Bug245Episode ;
7+ use QueryResult \Entities \Bug245Segment ;
8+ use function PHPStan \Testing \assertType ;
9+
10+ class Foo
11+ {
12+
13+ /** @var EntityManager */
14+ private $ em ;
15+
16+ public function doFoo (): void
17+ {
18+ $ result = $ this ->em ->createQueryBuilder ()
19+ ->select ('episode.id ' )
20+ ->from (Bug245Episode::class, 'episode ' , 'episode.id ' )
21+ ->where ('episode.segmentsComplete = false ' )
22+ ->andWhere ('0 != SIZE(episode.segments) ' )
23+ ->andWhere (
24+ '0 < (SELECT COUNT(last_segment.id) FROM ' . Bug245Segment::class . ' as last_segment
25+ WHERE last_segment.episode = episode.id AND last_segment.isLastSegment = true) '
26+ )
27+ ->andWhere (
28+ "0 = (SELECT COUNT(segment.id) FROM " . Bug245Segment::class . " as segment
29+ WHERE segment.episode = episode.id AND segment.state != 'distributed') "
30+ )->getQuery ()->getResult ();
31+ assertType ('mixed ' , $ result );
32+ }
33+
34+ }
You can’t perform that action at this time.
0 commit comments