Skip to content

Commit 148fd32

Browse files
committed
Reproduce internal error unsuccessfully
Ref #425
1 parent 44e77f0 commit 148fd32

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

tests/Type/Doctrine/QueryBuilder/QueryBuilderGetQueryDynamicReturnTypeExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
/**

tests/Type/Doctrine/data/QueryResult/Entities/Many.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\ORM\Mapping\JoinColumn;
99
use Doctrine\ORM\Mapping\JoinColumns;
1010
use 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+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

0 commit comments

Comments
 (0)