mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
Apply rector rules: symfony up to 54
This commit is contained in:
@@ -32,12 +32,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
* name="chill_person_household"
|
||||
* )
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household": Household::class
|
||||
* })
|
||||
*
|
||||
* @MaxHolder(groups={"household_memberships"})
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household' => Household::class])]
|
||||
class Household
|
||||
{
|
||||
/**
|
||||
@@ -52,9 +49,8 @@ class Household
|
||||
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
||||
*
|
||||
* @ORM\OrderBy({"validFrom": "DESC", "id": "DESC"})
|
||||
*
|
||||
* @Serializer\Groups({"write"})
|
||||
*/
|
||||
#[Serializer\Groups(['write'])]
|
||||
private Collection $addresses;
|
||||
|
||||
/**
|
||||
@@ -73,9 +69,8 @@ class Household
|
||||
* )
|
||||
*
|
||||
* @ORM\OrderBy({"startDate": "DESC"})
|
||||
*
|
||||
* @Assert\Valid(traverse=true, groups={"household_composition"})
|
||||
*/
|
||||
#[Assert\Valid(traverse: true, groups: ['household_composition'])]
|
||||
private Collection&Selectable $compositions;
|
||||
|
||||
/**
|
||||
@@ -84,9 +79,8 @@ class Household
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
@@ -96,23 +90,20 @@ class Household
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="household"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private Collection $members;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
private bool $waitingForBirth = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
private ?\DateTimeImmutable $waitingForBirthDate = null;
|
||||
|
||||
public function __construct()
|
||||
@@ -159,8 +150,6 @@ class Household
|
||||
* By default, the addresses are ordered by date, descending (the most
|
||||
* recent first).
|
||||
*
|
||||
* @Assert\Callback(methods={"validate"})
|
||||
*
|
||||
* @return Collection<Address>
|
||||
*/
|
||||
public function getAddresses(): Collection
|
||||
@@ -209,11 +198,8 @@ class Household
|
||||
return $this->compositions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\SerializedName("current_address")
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Serializer\SerializedName('current_address')]
|
||||
public function getCurrentAddress(?\DateTime $at = null): ?Address
|
||||
{
|
||||
$at ??= new \DateTime('today');
|
||||
@@ -229,11 +215,8 @@ class Household
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*
|
||||
* @Serializer\SerializedName("current_composition")
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[Serializer\SerializedName('current_composition')]
|
||||
public function getCurrentComposition(?\DateTimeImmutable $at = null): ?HouseholdComposition
|
||||
{
|
||||
$at ??= new \DateTimeImmutable('today');
|
||||
@@ -259,9 +242,7 @@ class Household
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));
|
||||
@@ -281,11 +262,9 @@ class Household
|
||||
* get current members ids.
|
||||
*
|
||||
* Used in serialization
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @Serializer\SerializedName("current_members_id")
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[Serializer\SerializedName('current_members_id')]
|
||||
public function getCurrentMembersIds(?\DateTimeImmutable $now = null): ReadableCollection
|
||||
{
|
||||
return $this->getCurrentMembers($now)->map(
|
||||
@@ -606,9 +585,8 @@ class Household
|
||||
* This will force the startDate's address on today.
|
||||
*
|
||||
* Used on household creation.
|
||||
*
|
||||
* @Serializer\Groups({"create"})
|
||||
*/
|
||||
#[Serializer\Groups(['create'])]
|
||||
public function setForceAddress(Address $address)
|
||||
{
|
||||
$address->setValidFrom(new \DateTime('today'));
|
||||
@@ -629,6 +607,7 @@ class Household
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
{
|
||||
$addresses = $this->getAddresses();
|
||||
|
Reference in New Issue
Block a user