DX: type-hing oneToMany and ManyToMany properties as collection

This commit is contained in:
2023-07-19 16:21:17 +02:00
parent 224c2c74e8
commit 075aca493b
32 changed files with 130 additions and 73 deletions

View File

@@ -72,12 +72,12 @@ class Event implements HasCenterInterface, HasScopeInterface
private $name;
/**
* @var Participation
* @var Collection<Participation>
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Participation",
* mappedBy="event")
*/
private $participations;
private Collection $participations;
/**
* @var EventType
@@ -174,11 +174,11 @@ class Event implements HasCenterInterface, HasScopeInterface
*/
public function getParticipationsOrdered(): \ArrayIterator|\Traversable
{
$iterator = $this->participations->getIterator();
$iterator = iterator_to_array($this->participations->getIterator());
$iterator->uasort(static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()));
uasort($iterator, static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()));
return $iterator;
return new ArrayIterator($iterator);
}
/**