From 075aca493bd1e89df32d3cca36858e0e26f188bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Jul 2023 16:21:17 +0200 Subject: [PATCH] DX: type-hing oneToMany and ManyToMany properties as collection --- .../ChillActivityBundle/Entity/Activity.php | 13 +++++-- .../Entity/ActivityReasonCategory.php | 5 ++- .../src/Entity/AsideActivityCategory.php | 4 +- .../ChillCalendarBundle/Entity/Calendar.php | 8 +++- .../Entity/CustomFieldLongChoice/Option.php | 4 +- .../Entity/CustomFieldsGroup.php | 5 +-- src/Bundle/ChillEventBundle/Entity/Event.php | 10 ++--- .../ChillEventBundle/Entity/EventType.php | 8 ++-- src/Bundle/ChillMainBundle/Entity/Address.php | 2 +- src/Bundle/ChillMainBundle/Entity/Center.php | 4 +- .../Entity/GeographicalUnitLayer.php | 1 + .../ChillMainBundle/Entity/Notification.php | 3 ++ .../Entity/PermissionsGroup.php | 10 ++--- .../ChillMainBundle/Entity/RoleScope.php | 4 +- src/Bundle/ChillMainBundle/Entity/Scope.php | 4 +- src/Bundle/ChillMainBundle/Entity/User.php | 1 + .../Entity/Workflow/EntityWorkflow.php | 8 ++-- .../Entity/Workflow/EntityWorkflowStep.php | 3 ++ .../Entity/AccompanyingPeriod.php | 17 ++++++--- .../AccompanyingPeriodWork.php | 5 +++ .../AccompanyingPeriodWorkGoal.php | 1 + .../AccompanyingPeriod/ClosingMotive.php | 1 + .../Entity/Household/Household.php | 10 +++-- .../ChillPersonBundle/Entity/Person.php | 37 +++++++++++-------- .../Entity/SocialWork/Evaluation.php | 1 + .../Entity/SocialWork/Goal.php | 2 + .../Entity/SocialWork/Result.php | 4 ++ .../Entity/SocialWork/SocialAction.php | 10 +++-- .../Entity/SocialWork/SocialIssue.php | 6 ++- .../ChillTaskBundle/Entity/RecurringTask.php | 2 +- .../ChillTaskBundle/Entity/SingleTask.php | 5 ++- .../Entity/ThirdParty.php | 5 ++- 32 files changed, 130 insertions(+), 73 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 32ceb2e74..c4c56fafb 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -104,6 +104,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"}) * @Assert\Valid(traverse=true) + * @var Collection */ private Collection $documents; @@ -140,8 +141,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") * @Groups({"read", "docgen:read"}) + * @var Collection */ - private ?Collection $persons = null; + private Collection $persons; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_") @@ -151,6 +153,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") * @Groups({"docgen:read"}) + * @var Collection */ private Collection $reasons; @@ -170,6 +173,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction") * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction") * @Groups({"read", "docgen:read"}) + * @var Collection */ private Collection $socialActions; @@ -177,14 +181,16 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue") * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue") * @Groups({"read", "docgen:read"}) + * @var Collection */ private Collection $socialIssues; /** * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") * @Groups({"read", "docgen:read"}) + * @var Collection */ - private ?Collection $thirdParties = null; + private Collection $thirdParties; /** * @ORM\Column(type="time", nullable=true) @@ -200,8 +206,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") * @Groups({"read", "docgen:read"}) + * @var Collection */ - private ?Collection $users = null; + private Collection $users; public function __construct() { diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php index ab63232a5..1bae408dc 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -47,12 +48,12 @@ class ActivityReasonCategory implements \Stringable /** * Array of ActivityReason. * - * @var ArrayCollection + * @var Collection * @ORM\OneToMany( * targetEntity="Chill\ActivityBundle\Entity\ActivityReason", * mappedBy="category") */ - private $reasons; + private Collection $reasons; /** * ActivityReasonCategory constructor. diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 2ccab56d0..44777f110 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -25,8 +25,9 @@ class AsideActivityCategory { /** * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") + * @var Collection */ - private $children; + private Collection $children; /** * @ORM\Id @@ -36,7 +37,6 @@ class AsideActivityCategory private int $id; /** - * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") * @ORM\Column(type="boolean") */ private bool $isActive = true; diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index dc98c47d9..10a675278 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -30,6 +30,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\ReadableCollection; +use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping as ORM; use LogicException; use Symfony\Component\Serializer\Annotation as Serializer; @@ -125,7 +126,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente private int $dateTimeVersion = 0; /** - * @var Collection + * @var Collection * @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true) */ private Collection $documents; @@ -154,8 +155,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * ) * @ORM\JoinTable(name="chill_calendar.calendar_to_invites") * @Serializer\Groups({"read", "docgen:read"}) + * @var Collection&Selectable */ - private Collection $invites; + private Collection&Selectable $invites; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") @@ -184,6 +186,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) * @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.") + * @var Collection */ private Collection $persons; @@ -194,6 +197,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente private PrivateCommentEmbeddable $privateComment; /** + * @var Collection * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") * @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties") * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php index 08233886d..39eb7a153 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php @@ -28,12 +28,12 @@ class Option private $active = true; /** - * @var Collection + * @var Collection