mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -571,7 +571,7 @@ class AccompanyingPeriod implements
|
||||
*
|
||||
* @param mixed $person
|
||||
*/
|
||||
public function closeParticipationFor($person): ?AccompanyingPeriodParticipation
|
||||
public function closeParticipationFor(mixed $person): ?AccompanyingPeriodParticipation
|
||||
{
|
||||
$participation = $this->getOpenParticipationContainsPerson($person);
|
||||
|
||||
@@ -950,10 +950,9 @@ class AccompanyingPeriod implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person|ThirdParty
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
public function getRequestor()
|
||||
public function getRequestor(): \Chill\PersonBundle\Entity\Person|\Chill\ThirdPartyBundle\Entity\ThirdParty
|
||||
{
|
||||
return $this->requestorPerson ?? $this->requestorThirdParty;
|
||||
}
|
||||
@@ -1215,7 +1214,7 @@ class AccompanyingPeriod implements
|
||||
*
|
||||
* @return AccompanyingPeriod
|
||||
*/
|
||||
public function setClosingDate($closingDate)
|
||||
public function setClosingDate(mixed $closingDate)
|
||||
{
|
||||
$this->closingDate = $closingDate;
|
||||
|
||||
@@ -1274,11 +1273,10 @@ class AccompanyingPeriod implements
|
||||
/**
|
||||
* Set openingDate.
|
||||
*
|
||||
* @param mixed $openingDate
|
||||
*
|
||||
* @return AccompanyingPeriod
|
||||
*/
|
||||
public function setOpeningDate($openingDate)
|
||||
public function setOpeningDate(mixed $openingDate)
|
||||
{
|
||||
if ($this->openingDate !== $openingDate) {
|
||||
$this->openingDate = $openingDate;
|
||||
|
@@ -365,11 +365,9 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
|
||||
/**
|
||||
* Arbitrary data, used for client.
|
||||
*
|
||||
* @param mixed $key
|
||||
*
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setKey($key): self
|
||||
public function setKey(mixed $key): self
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
|
@@ -147,11 +147,9 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $key
|
||||
*
|
||||
* @return AccompanyingPeriodWorkEvaluationDocument
|
||||
*/
|
||||
public function setKey($key)
|
||||
public function setKey(mixed $key)
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
|
@@ -94,10 +94,9 @@ class Resource
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person|ThirdParty
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
public function getResource()
|
||||
public function getResource(): \Chill\PersonBundle\Entity\Person|\Chill\ThirdPartyBundle\Entity\ThirdParty
|
||||
{
|
||||
return $this->person ?? $this->thirdParty;
|
||||
}
|
||||
|
@@ -26,12 +26,6 @@ class UserHistory implements TrackCreationInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
@@ -49,17 +43,18 @@ class UserHistory implements TrackCreationInterface
|
||||
*/
|
||||
private DateTimeImmutable $startDate;
|
||||
|
||||
/**
|
||||
public function __construct(/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, /**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private User $user;
|
||||
|
||||
public function __construct(AccompanyingPeriod $accompanyingPeriod, User $user, ?DateTimeImmutable $startDate = null)
|
||||
{
|
||||
private User $user,
|
||||
?DateTimeImmutable $startDate = null
|
||||
) {
|
||||
$this->startDate = $startDate ?? new DateTimeImmutable('now');
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): AccompanyingPeriod
|
||||
|
@@ -28,12 +28,6 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
*/
|
||||
class AccompanyingPeriodParticipation
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
* @Groups({"read", "docgen:read"})
|
||||
@@ -48,24 +42,24 @@ class AccompanyingPeriodParticipation
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
|
||||
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=false)
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?DateTime $startDate = null;
|
||||
|
||||
public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person)
|
||||
{
|
||||
public function __construct(/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
||||
*/
|
||||
private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, /**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
|
||||
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?\Chill\PersonBundle\Entity\Person $person
|
||||
) {
|
||||
$this->startDate = new DateTime('now');
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
$this->person = $person;
|
||||
$person->getAccompanyingPeriodParticipations()->add($this);
|
||||
}
|
||||
|
||||
|
@@ -60,8 +60,6 @@ class MaritalStatus
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*
|
||||
* @return MaritalStatus
|
||||
*/
|
||||
public function setId(string $id): self
|
||||
{
|
||||
@@ -74,8 +72,6 @@ class MaritalStatus
|
||||
* Set name.
|
||||
*
|
||||
* @param string array $name
|
||||
*
|
||||
* @return MaritalStatus
|
||||
*/
|
||||
public function setName(array $name): self
|
||||
{
|
||||
|
@@ -74,7 +74,7 @@ use function in_array;
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
*/
|
||||
class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface
|
||||
class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface, \Stringable
|
||||
{
|
||||
public const BOTH_GENDER = 'both';
|
||||
|
||||
@@ -554,7 +554,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
@@ -631,7 +631,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @return true | array True if the accompanying periods are not collapsing,
|
||||
* an array with data for displaying the error
|
||||
*/
|
||||
public function checkAccompanyingPeriodsAreNotCollapsing()
|
||||
public function checkAccompanyingPeriodsAreNotCollapsing(): bool|array
|
||||
{
|
||||
$periods = $this->getAccompanyingPeriodsOrdered();
|
||||
$periodsNbr = count($periods);
|
||||
@@ -1165,19 +1165,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*/
|
||||
public function getGenderNumeric()
|
||||
{
|
||||
switch ($this->getGender()) {
|
||||
case self::FEMALE_GENDER:
|
||||
return 1;
|
||||
|
||||
case self::MALE_GENDER:
|
||||
return 0;
|
||||
|
||||
case self::BOTH_GENDER:
|
||||
return 2;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return match ($this->getGender()) {
|
||||
self::FEMALE_GENDER => 1,
|
||||
self::MALE_GENDER => 0,
|
||||
self::BOTH_GENDER => 2,
|
||||
default => -1,
|
||||
};
|
||||
}
|
||||
|
||||
public function getHouseholdAddresses(): Collection
|
||||
@@ -1360,7 +1353,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* @return PersonResource[]|Collection
|
||||
*/
|
||||
public function getResources()
|
||||
public function getResources(): array|\Doctrine\Common\Collections\Collection
|
||||
{
|
||||
return $this->resources;
|
||||
}
|
||||
@@ -1606,9 +1599,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person
|
||||
*/
|
||||
public function setCFData(?array $cFData): self
|
||||
{
|
||||
$this->cFData = $cFData;
|
||||
@@ -1824,16 +1814,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
|
||||
$histories = $this->centerHistory->matching($criteria);
|
||||
|
||||
switch ($histories->count()) {
|
||||
case 0:
|
||||
return null;
|
||||
|
||||
case 1:
|
||||
return $histories->first();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('It should not contains more than one center at a time');
|
||||
}
|
||||
return match ($histories->count()) {
|
||||
0 => null,
|
||||
1 => $histories->first(),
|
||||
default => throw new UnexpectedValueException('It should not contains more than one center at a time'),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,11 +32,6 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Center::class)
|
||||
*/
|
||||
private ?Center $center = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
@@ -49,21 +44,20 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerHistory")
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*/
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
|
||||
public function __construct(?Person $person = null, ?Center $center = null, ?DateTimeImmutable $startDate = null)
|
||||
{
|
||||
$this->person = $person;
|
||||
$this->center = $center;
|
||||
$this->startDate = $startDate;
|
||||
public function __construct(
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerHistory")
|
||||
*/
|
||||
private ?\Chill\PersonBundle\Entity\Person $person = null,
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Center::class)
|
||||
*/
|
||||
private ?\Chill\MainBundle\Entity\Center $center = null,
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*/
|
||||
private ?\DateTimeImmutable $startDate = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function getCenter(): ?Center
|
||||
|
@@ -221,10 +221,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @Assert\Callback
|
||||
*
|
||||
* @param mixed $payload
|
||||
*/
|
||||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
public function validate(ExecutionContextInterface $context, mixed $payload)
|
||||
{
|
||||
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
|
||||
$context->buildViolation('You must associate at least one entity')
|
||||
|
@@ -151,7 +151,7 @@ class SocialAction
|
||||
*
|
||||
* @return Collection|SocialAction[] a list with the elements of the given list which are parent of other elements in the given list
|
||||
*/
|
||||
public static function findAncestorSocialActions(Collection $socialActions): Collection
|
||||
public static function findAncestorSocialActions(\Doctrine\Common\Collections\Collection|array $socialActions): Collection
|
||||
{
|
||||
$ancestors = new ArrayCollection();
|
||||
|
||||
@@ -231,7 +231,7 @@ class SocialAction
|
||||
/**
|
||||
* @param Collection|SocialAction[] $socialActions
|
||||
*/
|
||||
public static function getDescendantsWithThisForActions($socialActions): Collection
|
||||
public static function getDescendantsWithThisForActions(\Doctrine\Common\Collections\Collection|array $socialActions): Collection
|
||||
{
|
||||
$unique = [];
|
||||
|
||||
|
@@ -74,7 +74,6 @@ class SocialIssue
|
||||
/**
|
||||
* @internal use @see{SocialIssue::setParent} instead
|
||||
*
|
||||
* @param SocialIssue $child
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -109,7 +108,7 @@ class SocialIssue
|
||||
*
|
||||
* @return Collection|SocialIssue[]
|
||||
*/
|
||||
public static function findAncestorSocialIssues(Collection $socialIssues): Collection
|
||||
public static function findAncestorSocialIssues(\Doctrine\Common\Collections\Collection|array $socialIssues): Collection
|
||||
{
|
||||
$ancestors = new ArrayCollection();
|
||||
|
||||
|
Reference in New Issue
Block a user