Closed
Description
I have the following code:
$qb = $this->em->createQueryBuilder()
->addSelect('tvs.title')
->addSelect('tvs.broadcastDate')
->addSelect('COUNT(tva.id) AS count')
->addSelect('SUM(CASE WHEN tva.freePeriod = TRUE THEN 1 ELSE 0 END) AS freePeriodCount')
->addSelect('SUM(CASE WHEN tva.subscriptions IS NOT NULL THEN 0 ELSE 1 END) AS userStreamingCount')
->from(TvActivity::class, 'tva')
->join('tva.tvShow', 'tvs')
->addGroupBy('tvs.id');
$dbRows = $qb->getQuery()->getResult();
\PHPStan\dumpType($dbRows);
The dumped type is:
list<array{
title: string,
broadcastDate: DateTimeImmutable,
count: int<0, max>|numeric-string,
freePeriodCount: 0|1|'0'|'1'|null,
userStreamingCount: 0|1|'0'|'1'|null,
}>
The last two fields can be arbitrary numbers, but are reported as 0 and 1 only. If it helps I can create a full reproduction repo, but hopefully things are clear like this. It's also wrong when doing SUM(1)
, so the exact entity definitions might not matter.
Using phpstan-doctrine 1.3.40.
Metadata
Metadata
Assignees
Labels
No labels