DX: rector rules upt to PHP 74

This commit is contained in:
2023-04-15 00:20:19 +02:00
parent a68190f0c6
commit 858ade467c
213 changed files with 433 additions and 1052 deletions

View File

@@ -828,9 +828,7 @@ class AccompanyingPeriod implements
$collection = $this
->getParticipationsContainsPerson($person)
->filter(
static function (AccompanyingPeriodParticipation $participation): bool {
return null === $participation->getEndDate();
}
static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate()
);
return $collection->count() > 0 ? $collection->first() : null;
@@ -844,9 +842,7 @@ class AccompanyingPeriod implements
return $this
->getParticipations()
->filter(
static function (AccompanyingPeriodParticipation $participation): bool {
return null === $participation->getEndDate();
}
static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate()
);
}

View File

@@ -44,20 +44,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
* @Assert\NotBlank
* @Assert\NotNull
*/
private ?string $content;
private ?string $content = null;
/**
* @ORM\Column(type="datetime")
* @Groups({"read", "docgen:read"})
*/
private ?DateTimeInterface $createdAt;
private ?DateTimeInterface $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read", "docgen:read"})
*/
private ?User $creator;
private ?User $creator = null;
/**
* @ORM\Id
@@ -65,20 +65,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="integer")
* @Groups({"read", "docgen:read"})
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\Column(type="datetime")
* @Groups({"read"})
*/
private ?DateTimeInterface $updatedAt;
private ?DateTimeInterface $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read"})
*/
private ?User $updatedBy;
private ?User $updatedBy = null;
public function getAccompanyingPeriod(): ?AccompanyingPeriod
{

View File

@@ -200,13 +200,11 @@ class Household
*/
public function getCurrentAddress(?DateTime $at = null): ?Address
{
$at = $at ?? new DateTime('today');
$at ??= new DateTime('today');
$addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) {
return $a->getValidFrom() <= $at && (
null === $a->getValidTo() || $a->getValidTo() > $at
);
});
$addrs = $this->getAddresses()->filter(static fn(Address $a) => $a->getValidFrom() <= $at && (
null === $a->getValidTo() || $a->getValidTo() > $at
));
if ($addrs->count() > 0) {
return $addrs->first();
@@ -338,9 +336,7 @@ class Household
public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection
{
return $this->getCurrentMembers($now)
->map(static function (HouseholdMember $m) {
return $m->getPerson();
});
->map(static fn(HouseholdMember $m) => $m->getPerson());
}
public function getId(): ?int
@@ -367,9 +363,7 @@ class Household
$membership->getStartDate(),
$membership->getEndDate()
)->filter(
static function (HouseholdMember $m) use ($membership) {
return $m->getPerson() !== $membership->getPerson();
}
static fn(HouseholdMember $m) => $m->getPerson() !== $membership->getPerson()
);
}
@@ -508,9 +502,7 @@ class Household
usort(
$compositionOrdered,
static function (HouseholdComposition $a, HouseholdComposition $b) {
return $a->getStartDate() <=> $b->getStartDate();
}
static fn(HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate()
);
$iterator = new ArrayIterator($compositionOrdered);

View File

@@ -142,7 +142,7 @@ class HouseholdMember
public function isCurrent(?DateTimeImmutable $at = null): bool
{
$at = $at ?? new DateTimeImmutable('now');
$at ??= new DateTimeImmutable('now');
return $this->getStartDate() < $at && (
null === $this->getEndDate() || $this->getEndDate() > $at

View File

@@ -775,9 +775,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
): int {
// TODO should be optimized to avoid loading accompanying period ?
return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor)
->filter(function (AccompanyingPeriod $p) {
return $p->getStep() !== AccompanyingPeriod::STEP_DRAFT;
})
->filter(fn(AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT)
->count();
}
@@ -1341,9 +1339,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->getAccompanyingPeriodParticipations()
->matching($criteria)
->filter(static function (AccompanyingPeriodParticipation $app) {
return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep();
});
->filter(static fn(AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep());
}
public function getOtherPhoneNumbers(): Collection

View File

@@ -50,7 +50,7 @@ class PersonCurrentAddress
/**
* @ORM\Column(name="valid_to", type="date_immutable")
*/
protected ?DateTimeImmutable $validTo;
protected ?DateTimeImmutable $validTo = null;
public function getAddress(): Address
{

View File

@@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="integer")
* @Groups({"read", "docgen:read"})
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources")

View File

@@ -41,7 +41,7 @@ class PersonPhone
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id;
private ?int $id = null;
/**
* @ORM\ManyToOne(
@@ -59,7 +59,7 @@ class PersonPhone
/**
* @ORM\Column(type="text", length=40, nullable=true)
*/
private ?string $type;
private ?string $type = null;
public function __construct()
{

View File

@@ -45,7 +45,7 @@ class Result
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $desactivationDate;
private ?DateTime $desactivationDate = null;
/**
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")