]> Raphaël G. Git Repositories - airbundle/commitdiff
Replace deprecated DateTime by DateTimeImmutable
authorRaphaël Gertz <git@rapsys.eu>
Sat, 5 Dec 2026 03:20:14 +0000 (04:20 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Sat, 5 Dec 2026 03:20:14 +0000 (04:20 +0100)
Entity/Application.php
Entity/Country.php
Entity/Dance.php
Entity/GoogleCalendar.php
Entity/GoogleToken.php
Entity/Location.php
Entity/Session.php
Entity/Slot.php
Entity/Snippet.php

index b2672a19aa898ff58a383fed4bb273c27fe7e957..23f44bf44bab1f7de0044038a86d4f1c53f41d10 100644 (file)
@@ -35,17 +35,17 @@ class Application {
        /**
         * Cancel datetime
         */
-       private ?\DateTime $canceled = null;
+       private ?\DateTimeImmutable $canceled = null;
 
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Session instance
@@ -62,8 +62,8 @@ class Application {
         */
        public function __construct() {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
        }
 
        /**
@@ -122,11 +122,11 @@ class Application {
        /**
         * Set canceled
         *
-        * @param \DateTime $canceled
+        * @param \DateTimeImmutable $canceled
         *
         * @return Application
         */
-       public function setCanceled(?\DateTime $canceled): Application {
+       public function setCanceled(?\DateTimeImmutable $canceled): Application {
                $this->canceled = $canceled;
 
                return $this;
@@ -135,20 +135,20 @@ class Application {
        /**
         * Get canceled
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCanceled(): ?\DateTime {
+       public function getCanceled(): ?\DateTimeImmutable {
                return $this->canceled;
        }
 
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Application
         */
-       public function setCreated(\DateTime $created): Application {
+       public function setCreated(\DateTimeImmutable $created): Application {
                $this->created = $created;
 
                return $this;
@@ -157,20 +157,20 @@ class Application {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Application
         */
-       public function setUpdated(\DateTime $updated): Application {
+       public function setUpdated(\DateTimeImmutable $updated): Application {
                $this->updated = $updated;
 
                return $this;
@@ -179,9 +179,9 @@ class Application {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -236,7 +236,7 @@ class Application {
                //Check that we have an application instance
                if (($application = $eventArgs->getObject()) instanceof Application) {
                        //Set updated value
-                       $application->setUpdated(new \DateTime('now'));
+                       $application->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 }
index 48a3037d7639c6063484b6fbbfd4b6c074b47de0..b6b43918762c7f48af66766ffb878b7617ab075b 100644 (file)
@@ -27,12 +27,12 @@ class Country {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Users collection
@@ -48,8 +48,8 @@ class Country {
         */
        public function __construct(private string $code, private string $alpha, private string $title) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
 
                //Set collections
                $this->users = new ArrayCollection();
@@ -133,11 +133,11 @@ class Country {
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Country
         */
-       public function setCreated(\DateTime $created): Country {
+       public function setCreated(\DateTimeImmutable $created): Country {
                $this->created = $created;
 
                return $this;
@@ -146,20 +146,20 @@ class Country {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Country
         */
-       public function setUpdated(\DateTime $updated): Country {
+       public function setUpdated(\DateTimeImmutable $updated): Country {
                $this->updated = $updated;
 
                return $this;
@@ -168,9 +168,9 @@ class Country {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -212,7 +212,7 @@ class Country {
                //Check that we have an country instance
                if (($country = $eventArgs->getObject()) instanceof Country) {
                        //Set updated value
-                       $country->setUpdated(new \DateTime('now'));
+                       $country->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 
index 6ae5f1bb14dcd72bd7e7e47b4a3f94ba44cc3887..888a56890a38571888309c206b5ceb11d62336e3 100644 (file)
@@ -27,12 +27,12 @@ class Dance {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Applications collection
@@ -52,8 +52,8 @@ class Dance {
         */
        public function __construct(private string $name, private string $type) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
 
                //Set collections
                $this->applications = new ArrayCollection();
@@ -116,11 +116,11 @@ class Dance {
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Dance
         */
-       public function setCreated(\DateTime $created): Dance {
+       public function setCreated(\DateTimeImmutable $created): Dance {
                $this->created = $created;
 
                return $this;
@@ -129,20 +129,20 @@ class Dance {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Dance
         */
-       public function setUpdated(\DateTime $updated): Dance {
+       public function setUpdated(\DateTimeImmutable $updated): Dance {
                $this->updated = $updated;
 
                return $this;
@@ -151,9 +151,9 @@ class Dance {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -240,7 +240,7 @@ class Dance {
                //Check that we have a dance instance
                if (($dance = $eventArgs->getObject()) instanceof Dance) {
                        //Set updated value
-                       $dance->setUpdated(new \DateTime('now'));
+                       $dance->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 
index f4ef2cec7cbf6c63065e487d50867c7b92b06009..edf124c7393bd5db8a711fb3162c9232ebb3974a 100644 (file)
@@ -25,12 +25,12 @@ class GoogleCalendar {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Constructor
@@ -38,12 +38,12 @@ class GoogleCalendar {
         * @param GoogleToken $googleToken The google token
         * @param string $mail The google calendar id
         * @param string $summary The google calendar summary
-        * @param \DateTime $synchronized The google calendar last synchronization
+        * @param \DateTimeImmutable $synchronized The google calendar last synchronization
         */
-       public function __construct(private GoogleToken $googleToken, private string $mail, private string $summary, private \DateTime $synchronized = new \DateTime('now')) {
+       public function __construct(private GoogleToken $googleToken, private string $mail, private string $summary, private \DateTimeImmutable $synchronized = new \DateTime('now')) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
        }
 
        /**
@@ -100,11 +100,11 @@ class GoogleCalendar {
        /**
         * Set synchronized
         *
-        * @param \DateTime $synchronized
+        * @param \DateTimeImmutable $synchronized
         *
         * @return GoogleCalendar
         */
-       public function setSynchronized(\DateTime $synchronized): GoogleCalendar {
+       public function setSynchronized(\DateTimeImmutable $synchronized): GoogleCalendar {
                $this->synchronized = $synchronized;
 
                return $this;
@@ -113,20 +113,20 @@ class GoogleCalendar {
        /**
         * Get synchronized
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getSynchronized(): \DateTime {
+       public function getSynchronized(): \DateTimeImmutable {
                return $this->synchronized;
        }
 
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return GoogleCalendar
         */
-       public function setCreated(\DateTime $created): GoogleCalendar {
+       public function setCreated(\DateTimeImmutable $created): GoogleCalendar {
                $this->created = $created;
 
                return $this;
@@ -135,20 +135,20 @@ class GoogleCalendar {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return GoogleCalendar
         */
-       public function setUpdated(\DateTime $updated): GoogleCalendar {
+       public function setUpdated(\DateTimeImmutable $updated): GoogleCalendar {
                $this->updated = $updated;
 
                return $this;
@@ -157,9 +157,9 @@ class GoogleCalendar {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -192,7 +192,7 @@ class GoogleCalendar {
                //Check that we have an snippet instance
                if (($entity = $eventArgs->getObject()) instanceof GoogleCalendar) {
                        //Set updated value
-                       return $entity->setUpdated(new \DateTime('now'));
+                       return $entity->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 }
index e44b176adf2c7c743377c600f2896fb365cb10be..5f297814263359febf855e950e19e281d2cc1e8f 100644 (file)
@@ -27,12 +27,12 @@ class GoogleToken {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Google calendars collection
@@ -45,13 +45,13 @@ class GoogleToken {
         * @param User $user The user instance
         * @param string The token user mail
         * @param string The access token identifier
-        * @param \DateTime The access token expires
+        * @param \DateTimeImmutable The access token expires
         * @param ?string The refresh token identifier
         */
-       public function __construct(private User $user, private string $mail, private string $access, private \DateTime $expired, private ?string $refresh = null) {
+       public function __construct(private User $user, private string $mail, private string $access, private \DateTimeImmutable $expired, private ?string $refresh = null) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
 
                //Set collections
                $this->googleCalendars = new ArrayCollection();
@@ -134,11 +134,11 @@ class GoogleToken {
        /**
         * Set expired
         *
-        * @param \DateTime $expired
+        * @param \DateTimeImmutable $expired
         *
         * @return GoogleToken
         */
-       public function setExpired(\DateTime $expired): GoogleToken {
+       public function setExpired(\DateTimeImmutable $expired): GoogleToken {
                $this->expired = $expired;
 
                return $this;
@@ -147,20 +147,20 @@ class GoogleToken {
        /**
         * Get expired
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getExpired(): \DateTime {
+       public function getExpired(): \DateTimeImmutable {
                return $this->expired;
        }
 
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return GoogleToken
         */
-       public function setCreated(\DateTime $created): GoogleToken {
+       public function setCreated(\DateTimeImmutable $created): GoogleToken {
                $this->created = $created;
 
                return $this;
@@ -169,20 +169,20 @@ class GoogleToken {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return GoogleToken
         */
-       public function setUpdated(\DateTime $updated): GoogleToken {
+       public function setUpdated(\DateTimeImmutable $updated): GoogleToken {
                $this->updated = $updated;
 
                return $this;
@@ -191,9 +191,9 @@ class GoogleToken {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -257,7 +257,7 @@ class GoogleToken {
                //Check that we have an snippet instance
                if (($entity = $eventArgs->getObject()) instanceof GoogleToken) {
                        //Set updated value
-                       return $entity->setUpdated(new \DateTime('now'));
+                       return $entity->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 }
index d70bddf5694320a19d487fbe55d465fd9756d7e7..db76b03d73ce5da1bb2720c77346693c0bf81b5b 100644 (file)
@@ -32,12 +32,12 @@ class Location {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Sessions collection
@@ -59,8 +59,8 @@ class Location {
         */
        public function __construct(private string $title = '', private string $address = '', private string $zipcode = '0', private string $city = '', private string $latitude = '0', private string $longitude = '0', private bool $hotspot = false, private bool $indoor = false) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
 
                //Set collections
                $this->sessions = new ArrayCollection();
@@ -278,11 +278,11 @@ class Location {
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Location
         */
-       public function setCreated(\DateTime $created): Location {
+       public function setCreated(\DateTimeImmutable $created): Location {
                $this->created = $created;
 
                return $this;
@@ -291,20 +291,20 @@ class Location {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Location
         */
-       public function setUpdated(\DateTime $updated): Location {
+       public function setUpdated(\DateTimeImmutable $updated): Location {
                $this->updated = $updated;
 
                return $this;
@@ -313,9 +313,9 @@ class Location {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -432,7 +432,7 @@ class Location {
                //Check that we have a location instance
                if (($location = $eventArgs->getObject()) instanceof Location) {
                        //Set updated value
-                       $location->setUpdated(new \DateTime('now'));
+                       $location->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 
index f74963cdb338dd2914d7c9fc189e2733abb12761..8d897690017d51d506d3eaadd0787bf9a8d218e3 100644 (file)
@@ -29,22 +29,22 @@ class Session {
        /**
         * Begin time
         */
-       private ?\DateTime $begin = null;
+       private ?\DateTimeImmutable $begin = null;
 
        /**
         * Computed start datetime
         */
-       private ?\DateTime $start = null;
+       private ?\DateTimeImmutable $start = null;
 
        /**
         * Length time
         */
-       private ?\DateTime $length = null;
+       private ?\DateTimeImmutable $length = null;
 
        /**
         * Computed stop datetime
         */
-       private ?\DateTime $stop = null;
+       private ?\DateTimeImmutable $stop = null;
 
        /**
         * Premium
@@ -94,17 +94,17 @@ class Session {
        /**
         * Lock datetime
         */
-       private ?\DateTime $locked = null;
+       private ?\DateTimeImmutable $locked = null;
 
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Application instance
@@ -119,10 +119,10 @@ class Session {
        /**
         * Constructor
         */
-       public function __construct(private \DateTime $date, private Location $location, private Slot $slot) {
+       public function __construct(private \DateTimeImmutable $date, private Location $location, private Slot $slot) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
 
                //Set collections
                $this->applications = new ArrayCollection();
@@ -140,11 +140,11 @@ class Session {
        /**
         * Set date
         *
-        * @param \DateTime $date
+        * @param \DateTimeImmutable $date
         *
         * @return Session
         */
-       public function setDate(\DateTime $date): Session {
+       public function setDate(\DateTimeImmutable $date): Session {
                $this->date = $date;
 
                return $this;
@@ -153,20 +153,20 @@ class Session {
        /**
         * Get date
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getDate(): \DateTime {
+       public function getDate(): \DateTimeImmutable {
                return $this->date;
        }
 
        /**
         * Set begin
         *
-        * @param \DateTime $begin
+        * @param \DateTimeImmutable $begin
         *
         * @return Session
         */
-       public function setBegin(?\DateTime $begin): Session {
+       public function setBegin(?\DateTimeImmutable $begin): Session {
                $this->begin = $begin;
 
                return $this;
@@ -175,18 +175,18 @@ class Session {
        /**
         * Get begin
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getBegin(): ?\DateTime {
+       public function getBegin(): ?\DateTimeImmutable {
                return $this->begin;
        }
 
        /**
         * Get start
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getStart(): \DateTime {
+       public function getStart(): \DateTimeImmutable {
                //With start
                if ($this->start !== null) {
                        return $this->start;
@@ -215,11 +215,11 @@ class Session {
        /**
         * Set length
         *
-        * @param \DateTime $length
+        * @param \DateTimeImmutable $length
         *
         * @return Session
         */
-       public function setLength(?\DateTime $length): Session {
+       public function setLength(?\DateTimeImmutable $length): Session {
                $this->length = $length;
 
                return $this;
@@ -228,18 +228,18 @@ class Session {
        /**
         * Get length
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getLength(): ?\DateTime {
+       public function getLength(): ?\DateTimeImmutable {
                return $this->length;
        }
 
        /**
         * Get stop
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getStop(): \DateTime {
+       public function getStop(): \DateTimeImmutable {
                //Check start
                if ($this->stop !== null) {
                        return $this->stop;
@@ -459,11 +459,11 @@ class Session {
        /**
         * Set locked
         *
-        * @param \DateTime $locked
+        * @param \DateTimeImmutable $locked
         *
         * @return Session
         */
-       public function setLocked(?\DateTime $locked): Session {
+       public function setLocked(?\DateTimeImmutable $locked): Session {
                $this->locked = $locked;
 
                return $this;
@@ -472,20 +472,20 @@ class Session {
        /**
         * Get locked
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getLocked(): ?\DateTime {
+       public function getLocked(): ?\DateTimeImmutable {
                return $this->locked;
        }
 
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Session
         */
-       public function setCreated(\DateTime $created): Session {
+       public function setCreated(\DateTimeImmutable $created): Session {
                $this->created = $created;
 
                return $this;
@@ -494,20 +494,20 @@ class Session {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Session
         */
-       public function setUpdated(\DateTime $updated): Session {
+       public function setUpdated(\DateTimeImmutable $updated): Session {
                $this->updated = $updated;
 
                return $this;
@@ -516,9 +516,9 @@ class Session {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -626,7 +626,7 @@ class Session {
                //Check that we have a session instance
                if (($session = $eventArgs->getObject()) instanceof Session) {
                        //Set updated value
-                       $session->setUpdated(new \DateTime('now'));
+                       $session->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 
index 25ef3e8427e642693c058eba7b2cd75d1575f7cf..1977b93791977dad4fe7f468a64cd8d77eff4930 100644 (file)
@@ -27,12 +27,12 @@ class Slot {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Sessions collection
@@ -44,8 +44,8 @@ class Slot {
         */
        public function __construct(private string $title) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
 
                //Set collections
                $this->sessions = new ArrayCollection();
@@ -85,11 +85,11 @@ class Slot {
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Slot
         */
-       public function setCreated(\DateTime $created) {
+       public function setCreated(\DateTimeImmutable $created) {
                $this->created = $created;
 
                return $this;
@@ -98,20 +98,20 @@ class Slot {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Slot
         */
-       public function setUpdated(\DateTime $updated) {
+       public function setUpdated(\DateTimeImmutable $updated) {
                $this->updated = $updated;
 
                return $this;
@@ -120,9 +120,9 @@ class Slot {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -164,7 +164,7 @@ class Slot {
                //Check that we have a slot instance
                if (($slot = $eventArgs->getObject()) instanceof Slot) {
                        //Set updated value
-                       $slot->setUpdated(new \DateTime('now'));
+                       $slot->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 
index dea8897dd0fe3e0b68416b46378d0edec0fb0c38..e645a69e81d94ecb639462c898dc73fe4d908c9a 100644 (file)
@@ -70,12 +70,12 @@ class Snippet {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Constructor
@@ -86,8 +86,8 @@ class Snippet {
         */
        public function __construct(private string $locale, private Location $location, private User $user) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
        }
 
        /**
@@ -321,11 +321,11 @@ class Snippet {
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return Snippet
         */
-       public function setCreated(\DateTime $created): Snippet {
+       public function setCreated(\DateTimeImmutable $created): Snippet {
                $this->created = $created;
 
                return $this;
@@ -334,20 +334,20 @@ class Snippet {
        /**
         * Get created
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getCreated(): \DateTime {
+       public function getCreated(): \DateTimeImmutable {
                return $this->created;
        }
 
        /**
         * Set updated
         *
-        * @param \DateTime $updated
+        * @param \DateTimeImmutable $updated
         *
         * @return Snippet
         */
-       public function setUpdated(\DateTime $updated): Snippet {
+       public function setUpdated(\DateTimeImmutable $updated): Snippet {
                $this->updated = $updated;
 
                return $this;
@@ -356,9 +356,9 @@ class Snippet {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -413,7 +413,7 @@ class Snippet {
                //Check that we have an snippet instance
                if (($snippet = $eventArgs->getObject()) instanceof Snippet) {
                        //Set updated value
-                       $snippet->setUpdated(new \DateTime('now'));
+                       $snippet->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 }