Cherry-pick phpstan fixes after rector changes

This commit is contained in:
Julie Lenaerts 2024-08-27 15:57:10 +02:00
parent 94d6b5eff8
commit 85e2466611
7 changed files with 69 additions and 64 deletions

View File

@ -103,7 +103,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
private int $dateTimeVersion = 0;
/**
* @var Collection<CalendarDoc>
* @var Collection<int, \Chill\CalendarBundle\Entity\CalendarDoc>
*/
#[ORM\OneToMany(mappedBy: 'calendar', targetEntity: CalendarDoc::class, orphanRemoval: true)]
private Collection $documents;
@ -120,12 +120,12 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
private ?int $id = null;
/**
* @var Collection&Selectable<int, Invite>
* @var ArrayCollection<int, Invite>
*/
#[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\OneToMany(mappedBy: 'calendar', targetEntity: Invite::class, cascade: ['persist', 'remove', 'merge', 'detach'], orphanRemoval: true)]
#[ORM\JoinTable(name: 'chill_calendar.calendar_to_invites')]
private Collection&Selectable $invites;
private Collection $invites;
#[Serializer\Groups(['read', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A location is required')]
@ -143,7 +143,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
private ?Person $person = null;
/**
* @var Collection<Person>
* @var Collection<int, Person>
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\Count(min: 1, minMessage: 'calendar.At least {{ limit }} person is required.')]
@ -157,7 +157,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
private PrivateCommentEmbeddable $privateComment;
/**
* @var Collection<ThirdParty>
* @var Collection<int, ThirdParty>
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[ORM\ManyToMany(targetEntity: ThirdParty::class)]

View File

@ -192,7 +192,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
{
$iterator = iterator_to_array($this->participations->getIterator());
uasort($iterator, static fn ($first, $second) => strnatcasecmp((string) $first->getPerson()->getFirstName(), (string) $second->getPerson()->getFirstName()));
uasort($iterator, static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()));
return new \ArrayIterator($iterator);
}

View File

@ -64,7 +64,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
private bool $enabled = true;
/**
* @var Collection<GroupCenter>
* @var Collection<int, \Chill\MainBundle\Entity\GroupCenter>
*/
#[ORM\ManyToMany(targetEntity: GroupCenter::class, inversedBy: 'users')]
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')]
@ -83,10 +83,10 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
private ?Location $mainLocation = null;
/**
* @var Collection&Selectable<int, UserScopeHistory>
* @var ArrayCollection<int, UserScopeHistory>
*/
#[ORM\OneToMany(targetEntity: UserScopeHistory::class, mappedBy: 'user', cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection&Selectable $scopeHistories;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserScopeHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private ArrayCollection $scopeHistories;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
private string $password = '';
@ -98,10 +98,10 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
private ?string $salt = null;
/**
* @var Collection&Selectable<int, UserJobHistory>
* @var ArrayCollection<int, UserJobHistory>
*/
#[ORM\OneToMany(targetEntity: UserJobHistory::class, mappedBy: 'user', cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection&Selectable $jobHistories;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserJobHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private ArrayCollection $jobHistories;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 80)]
private string $username = '';

View File

@ -21,6 +21,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Order;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
@ -64,7 +65,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
public array $futureDestUsers = [];
/**
* @var Collection<EntityWorkflowComment>
* @var Collection<int, \Chill\MainBundle\Entity\Workflow\EntityWorkflowComment>
*/
#[ORM\OneToMany(targetEntity: EntityWorkflowComment::class, mappedBy: 'entityWorkflow', orphanRemoval: true)]
private Collection $comments;
@ -81,12 +82,12 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
private int $relatedEntityId;
/**
* @var Collection<EntityWorkflowStep>
* @var ArrayCollection<int, EntityWorkflowStep>
*/
#[Assert\Valid(traverse: true)]
#[ORM\OneToMany(targetEntity: EntityWorkflowStep::class, mappedBy: 'entityWorkflow', orphanRemoval: true, cascade: ['persist'])]
#[ORM\OneToMany(mappedBy: 'entityWorkflow', targetEntity: EntityWorkflowStep::class, cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['transitionAt' => \Doctrine\Common\Collections\Criteria::ASC, 'id' => 'ASC'])]
private Collection $steps;
private ArrayCollection $steps;
/**
* @var array|EntityWorkflowStep[]|null
@ -94,14 +95,14 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
private ?array $stepsChainedCache = null;
/**
* @var Collection<User>
* @var Collection<int, User>
*/
#[ORM\ManyToMany(targetEntity: User::class)]
#[ORM\JoinTable(name: 'chill_main_workflow_entity_subscriber_to_final')]
private Collection $subscriberToFinal;
/**
* @var Collection<User>
* @var Collection<int, User>
*/
#[ORM\ManyToMany(targetEntity: User::class)]
#[ORM\JoinTable(name: 'chill_main_workflow_entity_subscriber_to_step')]
@ -276,6 +277,9 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return $this->steps;
}
/**
* @throws Exception
*/
public function getStepsChained(): array
{
if (\is_array($this->stepsChainedCache)) {

View File

@ -135,14 +135,14 @@ class AccompanyingPeriod implements
private ?Location $administrativeLocation = null;
/**
* @var Collection&Selectable<int, Calendar>
* @var ArrayCollection<int, Calendar>
*/
#[ORM\OneToMany(targetEntity: Calendar::class, mappedBy: 'accompanyingPeriod')]
private Collection&Selectable $calendars;
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: Calendar::class)]
private ArrayCollection $calendars;
#[Groups(['read', 'write', 'docgen:read'])]
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CLOSED])]
#[Assert\GreaterThanOrEqual(propertyPath: 'openingDate', groups: [AccompanyingPeriod::STEP_CLOSED], message: 'The closing date must be later than the date of creation')]
#[Assert\GreaterThanOrEqual(propertyPath: 'openingDate', message: 'The closing date must be later than the date of creation', groups: [AccompanyingPeriod::STEP_CLOSED])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
private ?\DateTime $closingDate = null;
@ -153,10 +153,10 @@ class AccompanyingPeriod implements
private ?ClosingMotive $closingMotive = null;
/**
* @var Collection<Comment>
* @var Collection<(int|string), Comment>
*/
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_DRAFT])]
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'accompanyingPeriod', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: Comment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['createdAt' => Criteria::DESC, 'id' => 'DESC'])]
private Collection $comments;
@ -194,9 +194,9 @@ class AccompanyingPeriod implements
private ?UserJob $job = null;
/**
* @var Collection<AccompanyingPeriodLocationHistory>
* @var Collection<int, AccompanyingPeriodLocationHistory>
*/
#[ORM\OneToMany(targetEntity: AccompanyingPeriodLocationHistory::class, mappedBy: 'period', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(mappedBy: 'period', targetEntity: AccompanyingPeriodLocationHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection $locationHistories;
#[Groups(['read', 'write', 'docgen:read'])]
@ -212,10 +212,10 @@ class AccompanyingPeriod implements
private ?Origin $origin = null;
/**
* @var Collection<AccompanyingPeriodParticipation>
* @var Collection<int, AccompanyingPeriodParticipation>
*/
#[Groups(['read', 'docgen:read'])]
#[ORM\OneToMany(targetEntity: AccompanyingPeriodParticipation::class, mappedBy: 'accompanyingPeriod', orphanRemoval: true, cascade: ['persist', 'refresh', 'remove', 'merge', 'detach'])]
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: AccompanyingPeriodParticipation::class, cascade: ['persist', 'refresh', 'remove', 'merge', 'detach'], orphanRemoval: true)]
#[ParticipationOverlap(groups: [AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED])]
private Collection $participations;
@ -246,7 +246,7 @@ class AccompanyingPeriod implements
private ?ThirdParty $requestorThirdParty = null;
/**
* @var Collection<resource>
* @var Collection<int, Resource>
*/
#[Groups(['read', 'docgen:read'])]
#[ORM\OneToMany(targetEntity: AccompanyingPeriod\Resource::class, mappedBy: 'accompanyingPeriod', cascade: ['persist', 'remove'], orphanRemoval: true)]
@ -254,7 +254,7 @@ class AccompanyingPeriod implements
private Collection $resources;
/**
* @var Collection<Scope>
* @var Collection<int, Scope>
*/
#[Groups(['read', 'docgen:read'])]
#[Assert\Count(min: 1, groups: [AccompanyingPeriod::STEP_CONFIRMED], minMessage: 'A course must be associated to at least one scope')]
@ -263,7 +263,7 @@ class AccompanyingPeriod implements
private Collection $scopes;
/**
* @var Collection<SocialIssue>
* @var Collection<int, SocialIssue>
*/
#[Groups(['read', 'docgen:read'])]
#[Assert\Count(min: 1, groups: [AccompanyingPeriod::STEP_CONFIRMED], minMessage: 'A course must contains at least one social issue')]
@ -279,9 +279,9 @@ class AccompanyingPeriod implements
private ?string $step = self::STEP_DRAFT;
/**
* @var Collection<AccompanyingPeriodStepHistory>
* @var Collection<int, AccompanyingPeriodStepHistory>
*/
#[ORM\OneToMany(targetEntity: AccompanyingPeriodStepHistory::class, mappedBy: 'period', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(mappedBy: 'period', targetEntity: AccompanyingPeriodStepHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection $stepHistories;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])]
@ -296,7 +296,7 @@ class AccompanyingPeriod implements
private ?User $user = null;
/**
* @var Collection<UserHistory>
* @var Collection<int, UserHistory>
*/
#[ORM\OneToMany(targetEntity: UserHistory::class, mappedBy: 'accompanyingPeriod', orphanRemoval: true, cascade: ['persist', 'remove'])]
private Collection $userHistories;
@ -311,10 +311,10 @@ class AccompanyingPeriod implements
private ?User $userPrevious = null;
/**
* @var Collection<AccompanyingPeriodWork>
* @var Collection<int, AccompanyingPeriodWork>
*/
#[Assert\Valid(traverse: true)]
#[ORM\OneToMany(targetEntity: AccompanyingPeriodWork::class, mappedBy: 'accompanyingPeriod')]
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: AccompanyingPeriodWork::class)]
private Collection $works;
/**
@ -801,7 +801,7 @@ class AccompanyingPeriod implements
/**
* Get a list of all persons which are participating to this course.
*
* @psalm-return Collection<(int|string), Person|null>
* @psalm-return Collection<int, Person|null>
*/
public function getPersons(): Collection
{

View File

@ -21,6 +21,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
@ -35,7 +36,7 @@ class Household implements HasCentersInterface
/**
* Addresses.
*
* @var Collection<Address>
* @var Collection<int, \Chill\MainBundle\Entity\Address>
*/
#[Serializer\Groups(['write'])]
#[ORM\ManyToMany(targetEntity: Address::class, cascade: ['persist', 'remove', 'merge', 'detach'])]
@ -47,33 +48,33 @@ class Household implements HasCentersInterface
private CommentEmbeddable $commentMembers;
/**
* @var Collection&Selectable<int, HouseholdComposition>
* @var ArrayCollection<int, HouseholdComposition>
*/
#[Assert\Valid(traverse: true, groups: ['household_composition'])]
#[ORM\OneToMany(targetEntity: HouseholdComposition::class, mappedBy: 'household', orphanRemoval: true, cascade: ['persist'])]
#[Assert\Valid(groups: ['household_composition'], traverse: true)]
#[ORM\OneToMany(mappedBy: 'household', targetEntity: HouseholdComposition::class, cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['startDate' => Criteria::DESC])]
private Collection&Selectable $compositions;
private ArrayCollection $compositions;
#[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
/**
* @var Collection<HouseholdMember>
* @var Collection<int, HouseholdMember>
*/
#[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\OneToMany(targetEntity: HouseholdMember::class, mappedBy: 'household')]
#[ORM\OneToMany(mappedBy: 'household', targetEntity: HouseholdMember::class)]
private Collection $members;
#[Serializer\Groups(['docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'waiting_for_birth', options: ['default' => false])]
#[ORM\Column(name: 'waiting_for_birth', type: Types::BOOLEAN, options: ['default' => false])]
#[Assert\Type('boolean', groups: ['household_metadata'])]
private bool $waitingForBirth = false;
#[Serializer\Groups(['docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, name: 'waiting_for_birth_date', nullable: true, options: ['default' => null])]
#[ORM\Column(type: Types::DATE_IMMUTABLE, name: 'waiting_for_birth_date', nullable: true, options: ['default' => null])]
#[Assert\Expression('this.getWaitingForBirth() == false or value != null', message: 'The waiting for birth date must be set', groups: ['household_metadata'])]
private ?\DateTimeImmutable $waitingForBirthDate = null;

View File

@ -86,7 +86,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's accompanying periods (when the person was accompanied by the center).
*
* @var Collection<AccompanyingPeriodParticipation>
* @var Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriodParticipation>
*/
#[ORM\OneToMany(targetEntity: AccompanyingPeriodParticipation::class, mappedBy: 'person', cascade: ['persist', 'remove', 'merge', 'detach'])]
#[ORM\OrderBy(['startDate' => Criteria::DESC])]
@ -95,7 +95,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The accompanying period requested by the Person.
*
* @var Collection<AccompanyingPeriod>
* @var Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriod>
*/
#[ORM\OneToMany(targetEntity: AccompanyingPeriod::class, mappedBy: 'requestorPerson')]
private Collection $accompanyingPeriodRequested;
@ -103,7 +103,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Addresses.
*
* @var Collection<Address>
* @var Collection<int, \Chill\MainBundle\Entity\Address>
*/
#[ORM\ManyToMany(targetEntity: Address::class, cascade: ['persist', 'remove', 'merge', 'detach'])]
#[ORM\JoinTable(name: 'chill_person_persons_to_addresses')]
@ -111,7 +111,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
private Collection $addresses;
/**
* @var Collection<PersonAltName>
* @var Collection<int, \Chill\PersonBundle\Entity\PersonAltName>
*/
#[ORM\OneToMany(targetEntity: PersonAltName::class, mappedBy: 'person', cascade: ['persist', 'remove', 'merge', 'detach'], orphanRemoval: true)]
private Collection $altNames;
@ -124,13 +124,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
private ?\DateTime $birthdate = null;
/**
* @var Collection<Charge>
* @var Collection<int, \Chill\BudgetBundle\Entity\Charge>
*/
#[ORM\OneToMany(targetEntity: Charge::class, mappedBy: 'person')]
private Collection $budgetCharges;
/**
* @var Collection<resource>
* @var Collection<int, \Chill\BudgetBundle\Entity\Resource>
*/
#[ORM\OneToMany(targetEntity: Resource::class, mappedBy: 'person')]
private Collection $budgetResources;
@ -149,14 +149,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
#[ORM\ManyToOne(targetEntity: Center::class)]
private ?Center $center = null;
#[ORM\OneToOne(targetEntity: PersonCenterCurrent::class, mappedBy: 'person')]
#[ORM\OneToOne(mappedBy: 'person', targetEntity: PersonCenterCurrent::class)]
private ?PersonCenterCurrent $centerCurrent = null;
/**
* @var Collection<PersonCenterHistory>
* @var ArrayCollection<int, PersonCenterHistory>
*/
#[ORM\OneToMany(targetEntity: PersonCenterHistory::class, mappedBy: 'person', cascade: ['persist', 'remove'])]
private Collection $centerHistory;
#[ORM\OneToMany(mappedBy: 'person', targetEntity: PersonCenterHistory::class, cascade: ['persist', 'remove'])]
private ArrayCollection $centerHistory;
/**
* Array where customfield's data are stored.
@ -256,13 +256,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Read-only field, computed by the database.
*
* @var Collection<PersonHouseholdAddress>
* @var Collection<int, \Chill\PersonBundle\Entity\Household\PersonHouseholdAddress>
*/
#[ORM\OneToMany(targetEntity: PersonHouseholdAddress::class, mappedBy: 'person')]
private Collection $householdAddresses;
/**
* @var Collection<HouseholdMember>
* @var Collection<int, \Chill\PersonBundle\Entity\Household\HouseholdMember>
*/
#[ORM\OneToMany(targetEntity: HouseholdMember::class, mappedBy: 'person')]
private Collection $householdParticipations;
@ -330,14 +330,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
private ?int $numberOfChildren = null;
/**
* @var Collection<PersonPhone>
* @var Collection<int, \Chill\PersonBundle\Entity\PersonPhone>
*/
#[Assert\Valid(traverse: true)]
#[ORM\OneToMany(targetEntity: PersonPhone::class, mappedBy: 'person', cascade: ['persist', 'remove', 'merge', 'detach'], orphanRemoval: true)]
private Collection $otherPhoneNumbers;
/**
* @var Collection<AccompanyingPeriod>
* @var Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriod>
*/
#[ORM\OneToMany(targetEntity: AccompanyingPeriod::class, mappedBy: 'personLocation')]
private Collection $periodLocatedOn;
@ -361,7 +361,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
private bool $proxyAccompanyingPeriodOpenState = false; // TO-DELETE ?
/**
* @var Collection<PersonResource>
* @var Collection<int, \Chill\PersonBundle\Entity\Person\PersonResource>
*/
#[ORM\OneToMany(targetEntity: PersonResource::class, mappedBy: 'personOwner')]
private Collection $resources;
@ -1633,7 +1633,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* @param (\Doctrine\Common\Collections\Collection<int, Language>) $spokenLanguages
* @param (Collection<int, Language>) $spokenLanguages
*/
public function setSpokenLanguages(Collection $spokenLanguages): self
{