-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Description
Consider this setup:
#[ORM\Entity]
class ProductCountry extends Entity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column]
#[Set(visibility: 'private')]
private Country $country;
}
enum Country: string
{
case CZE = 'cze';
//....
}when doing DQL to country from this entity
public function getUsedCountriesInTravelProducts(): array
{
$query = $this->entityManager->createQueryBuilder()
->select('pc.country')
->from(ProductCountry::class, 'pc')
// .. some conditions
->addGroupBy('pc.country')
->getQuery();
return array_map(static fn (array $result): Country => $result['country'], $query->getResult());
}phpstan reports error Anonymous function should return Country but returns string but in reality, $result['country'] is properly hydrated to enum
Metadata
Metadata
Assignees
Labels
No labels