mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 04:23:49 +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();
|
||||
|
@@ -26,11 +26,8 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household_composition"
|
||||
* )
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_composition_type": HouseholdCompositionType::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_composition_type' => HouseholdCompositionType::class])]
|
||||
class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
@@ -44,11 +41,9 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(propertyPath="startDate", groups={"Default", "household_composition"})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'startDate', groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
@@ -62,9 +57,8 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
|
||||
* @ORM\ManyToOne(targetEntity=HouseholdCompositionType::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
private ?HouseholdCompositionType $householdCompositionType = null;
|
||||
|
||||
/**
|
||||
@@ -73,29 +67,23 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(0, groups={"Default", "household_composition"})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Assert\GreaterThanOrEqual(0, groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
private ?int $numberOfChildren = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*
|
||||
* @Assert\NotNull(groups={"Default", "household_composition"})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Assert\NotNull(groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -20,11 +20,8 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household_composition_type"
|
||||
* )
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_composition_type": HouseholdCompositionType::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_composition_type' => HouseholdCompositionType::class])]
|
||||
class HouseholdCompositionType
|
||||
{
|
||||
/**
|
||||
@@ -38,18 +35,16 @@ class HouseholdCompositionType
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private array $label = [];
|
||||
|
||||
public function getId(): ?int
|
||||
|
@@ -27,40 +27,30 @@ class HouseholdMember
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?string $comment = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(
|
||||
* propertyPath="startDate",
|
||||
* message="household_membership.The end date must be after start date",
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'startDate', message: 'household_membership.The end date must be after start date', groups: ['household_memberships'])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private bool $holder = false;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||
* )
|
||||
*
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
*
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
#[Assert\Valid(groups: ['household_memberships'])]
|
||||
#[Assert\NotNull(groups: ['household_memberships'])]
|
||||
private ?Household $household = null;
|
||||
|
||||
/**
|
||||
@@ -69,9 +59,8 @@ class HouseholdMember
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
@@ -79,21 +68,17 @@ class HouseholdMember
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"docgen:person:with-household": false})
|
||||
*
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
*
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Assert\Valid(groups: ['household_memberships'])]
|
||||
#[Assert\NotNull(groups: ['household_memberships'])]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?Position $position = null;
|
||||
|
||||
/**
|
||||
@@ -103,11 +88,9 @@ class HouseholdMember
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Assert\NotNull(groups: ['household_memberships'])]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
public function getComment(): ?string
|
||||
@@ -140,9 +123,7 @@ class HouseholdMember
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
public function getShareHousehold(): ?bool
|
||||
{
|
||||
return $this->shareHousehold;
|
||||
|
@@ -18,18 +18,14 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_household_position")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_position": Position::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_position' => Position::class])]
|
||||
class Position
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
private bool $allowHolder = false;
|
||||
|
||||
/**
|
||||
@@ -38,32 +34,28 @@ class Position
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
private array $label = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
private float $ordering = 0.00;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
private bool $shareHouseHold = true;
|
||||
|
||||
public function getAllowHolder(): bool
|
||||
|
Reference in New Issue
Block a user