From 7ee554b48dc5cfb7ad6eaf5add4014bab5da1058 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 25 Jan 2022 11:56:30 +0100 Subject: [PATCH] Update minor things. --- .../Entity/AccompanyingPeriod.php | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a41130807..4508d6d2c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -45,7 +45,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\GroupSequenceProviderInterface; use UnexpectedValueException; -use function count; use function in_array; use const SORT_REGULAR; @@ -545,17 +544,17 @@ class AccompanyingPeriod implements public function getAvailablePersonLocation(): Collection { return $this->getOpenParticipations() - ->filter(static function (AccompanyingPeriodParticipation $p) { - return $p->getPerson()->hasCurrentHouseholdAddress(); - }) - ->map(static function (AccompanyingPeriodParticipation $p) { - return $p->getPerson(); - }); + ->filter( + static fn (AccompanyingPeriodParticipation $p): bool => $p->getPerson()->hasCurrentHouseholdAddress() + ) + ->map( + static fn (AccompanyingPeriodParticipation $p): ?Person => $p->getPerson() + ); } public function getCenter(): ?Center { - if (count($this->getPersons()) === 0) { + if ($this->getPersons()->count() === 0) { return null; } @@ -596,9 +595,11 @@ class AccompanyingPeriod implements */ public function getComments(): Collection { - return $this->comments->filter(function (Comment $c) { - return $c !== $this->pinnedComment; - }); + return $this + ->comments + ->filter( + static fn (Comment $c): bool => $c !== $this->pinnedComment + ); } public function getCreatedAt(): ?DateTime @@ -739,9 +740,7 @@ class AccompanyingPeriod implements return $this ->getParticipations() ->filter( - static function (AccompanyingPeriodParticipation $participation) use ($person): bool { - return $participation->getPerson() === $person; - } + static fn (AccompanyingPeriodParticipation $participation): bool => $participation->getPerson() === $person ); } @@ -763,9 +762,7 @@ class AccompanyingPeriod implements return $this ->participations ->map( - static function (AccompanyingPeriodParticipation $participation): Person { - return $participation->getPerson(); - } + static fn (AccompanyingPeriodParticipation $participation): ?Person => $participation->getPerson() ); }