From 19ffef156bf0cde619e5fe898d3722f3dfabdd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 8 Apr 2024 13:09:24 +0200 Subject: [PATCH] Fix use of Ordering constant in doctrine orm association See https://github.com/doctrine/orm/issues/11313 for a follow-up --- phpstan-baseline-deprecations-doctrine-orm.neon | 8 ++++++++ src/Bundle/ChillCalendarBundle/Entity/Calendar.php | 4 ++-- src/Bundle/ChillMainBundle/Entity/User.php | 2 +- .../ChillPersonBundle/Entity/AccompanyingPeriod.php | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/phpstan-baseline-deprecations-doctrine-orm.neon b/phpstan-baseline-deprecations-doctrine-orm.neon index aad0db175..824c0371f 100644 --- a/phpstan-baseline-deprecations-doctrine-orm.neon +++ b/phpstan-baseline-deprecations-doctrine-orm.neon @@ -48,3 +48,11 @@ parameters: """ count: 2 path: src/Bundle/ChillPersonBundle/Entity/Person.php + + - + message: """ + #^Fetching deprecated class constant DESC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Descending instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 1ae1e966d..39340e117 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -105,7 +105,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @var Collection */ - #[ORM\OneToMany(targetEntity: CalendarDoc::class, mappedBy: 'calendar', orphanRemoval: true)] + #[ORM\OneToMany(mappedBy: 'calendar', targetEntity: CalendarDoc::class, orphanRemoval: true)] private Collection $documents; #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] @@ -123,7 +123,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * @var Collection&Selectable */ #[Serializer\Groups(['read', 'docgen:read'])] - #[ORM\OneToMany(targetEntity: Invite::class, mappedBy: 'calendar', orphanRemoval: true, cascade: ['persist', 'remove', 'merge', 'detach'])] + #[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; diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 56ed66761..d00b241b2 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -493,7 +493,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter $this->scopeHistories[] = $newScope; $criteria = new Criteria(); - $criteria->orderBy(['startDate' => \Doctrine\Common\Collections\Order::Ascending, 'id' => \Doctrine\Common\Collections\Order::Ascending]); + $criteria->orderBy(['startDate' => 'ASC', 'id' => 'ASC']); /** @var \Iterator $scopes */ $scopes = $this->scopeHistories->matching($criteria)->getIterator(); diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 3f4b7c8fe..117f3a090 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -157,7 +157,7 @@ class AccompanyingPeriod implements */ #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_DRAFT])] #[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'accompanyingPeriod', cascade: ['persist', 'remove'], orphanRemoval: true)] - #[ORM\OrderBy(['createdAt' => Order::Descending, 'id' => 'DESC'])] + #[ORM\OrderBy(['createdAt' => Criteria::DESC, 'id' => 'DESC'])] private Collection $comments; #[Groups(['read', 'write', 'docgen:read'])]