DX: fix phpstan issues

This commit is contained in:
2023-03-28 22:32:08 +02:00
parent 331443ae12
commit 48772efd54
27 changed files with 76 additions and 1309 deletions

View File

@@ -42,6 +42,7 @@ use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\ORM\Mapping as ORM;
use Iterator;
use LogicException;
@@ -615,9 +616,9 @@ class AccompanyingPeriod implements
/**
* Get a list of person which have an adresse available for a valid location.
*
* @return Collection|Person[]
* @return ReadableCollection<(int|string), Person>
*/
public function getAvailablePersonLocation(): Collection
public function getAvailablePersonLocation(): ReadableCollection
{
return $this->getOpenParticipations()
->filter(
@@ -675,8 +676,9 @@ class AccompanyingPeriod implements
/**
* @Groups({"read"})
* @return ReadableCollection<(int|string), Comment>
*/
public function getComments(): Collection
public function getComments(): ReadableCollection
{
$pinnedComment = $this->pinnedComment;
@@ -700,7 +702,7 @@ class AccompanyingPeriod implements
/**
* @Groups({"docgen:read"})
*/
public function getCurrentParticipations(): Collection
public function getCurrentParticipations(): ReadableCollection
{
return $this->getOpenParticipations();
}
@@ -834,7 +836,10 @@ class AccompanyingPeriod implements
return $collection->count() > 0 ? $collection->first() : null;
}
public function getOpenParticipations(): Collection
/**
* @return ReadableCollection<(int|string), AccompanyingPeriodParticipation>
*/
public function getOpenParticipations(): ReadableCollection
{
return $this
->getParticipations()
@@ -860,8 +865,9 @@ class AccompanyingPeriod implements
/**
* Get the participation containing a person.
* @return ReadableCollection<(int|string), AccompanyingPeriodParticipation>
*/
public function getParticipationsContainsPerson(Person $person): Collection
public function getParticipationsContainsPerson(Person $person): ReadableCollection
{
return $this
->getParticipations()

View File

@@ -22,6 +22,7 @@ use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
@@ -265,7 +266,7 @@ class Household
* @Serializer\Groups({"read"})
* @Serializer\SerializedName("current_members_id")
*/
public function getCurrentMembersIds(?DateTimeImmutable $now = null): Collection
public function getCurrentMembersIds(?DateTimeImmutable $now = null): ReadableCollection
{
return $this->getCurrentMembers($now)->map(
static fn (HouseholdMember $m) => $m->getId()
@@ -332,9 +333,9 @@ class Household
*
* Return a list of Person, instead of a list of HouseholdMembers
*
* @return Person[]
* @return ReadableCollection<(int|string), Person>
*/
public function getCurrentPersons(?DateTimeImmutable $now = null): Collection
public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection
{
return $this->getCurrentMembers($now)
->map(static function (HouseholdMember $m) {
@@ -358,9 +359,9 @@ class Household
/**
* get all the members during a given membership.
*
* @return Collection|HouseholdMember[]
* @return ReadableCollection<(int|string), HouseholdMember>
*/
public function getMembersDuringMembership(HouseholdMember $membership): Collection
public function getMembersDuringMembership(HouseholdMember $membership): ReadableCollection
{
return $this->getMembersOnRange(
$membership->getStartDate(),
@@ -384,7 +385,7 @@ class Household
return $this->getMembers()->matching($criteria);
}
public function getMembersOnRange(DateTimeImmutable $from, ?DateTimeImmutable $to): Collection
public function getMembersOnRange(DateTimeImmutable $from, ?DateTimeImmutable $to): ReadableCollection
{
return $this->getMembers()->filter(static function (HouseholdMember $m) use ($from, $to) {
if (null === $m->getEndDate() && null !== $to) {