mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-24 08:33:49 +00:00
DX: type-hing oneToMany and ManyToMany properties as collection
This commit is contained in:
@@ -23,6 +23,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
@@ -45,6 +46,7 @@ class Household
|
||||
/**
|
||||
* Addresses.
|
||||
*
|
||||
* @var Collection<Address>
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
@@ -60,6 +62,7 @@ class Household
|
||||
private CommentEmbeddable $commentMembers;
|
||||
|
||||
/**
|
||||
* @var Collection&Selectable<int, HouseholdComposition>
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdComposition::class,
|
||||
* mappedBy="household",
|
||||
@@ -69,7 +72,7 @@ class Household
|
||||
* @ORM\OrderBy({"startDate": "DESC"})
|
||||
* @Assert\Valid(traverse=true, groups={"household_composition"})
|
||||
*/
|
||||
private Collection $compositions;
|
||||
private Collection&Selectable $compositions;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
@@ -80,6 +83,7 @@ class Household
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var Collection<HouseholdMember>
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="household"
|
||||
@@ -146,9 +150,9 @@ class Household
|
||||
*
|
||||
* @Assert\Callback(methods={"validate"})
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Address[]
|
||||
* @return Collection<Address>
|
||||
*/
|
||||
public function getAddresses()
|
||||
public function getAddresses(): Collection
|
||||
{
|
||||
return $this->addresses;
|
||||
}
|
||||
|
Reference in New Issue
Block a user