From 4db2b80ba646afaede310a511463d9e0f4933686 Mon Sep 17 00:00:00 2001 From: George Salukvadze Date: Fri, 3 Jan 2025 14:11:06 +0100 Subject: [PATCH 1/2] - add types to createdAt and updatedAt in Timestampable --- CHANGELOG.md | 2 ++ src/Timestampable/Traits/Timestampable.php | 12 ++++++------ src/Timestampable/Traits/TimestampableEntity.php | 12 ++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0668f8c14..b2a4178567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ a release. --- ## [Unreleased] +### New +- Add return types to createdAt and updatedAt ### Deprecated - Sluggable: Annotation-specific mapping parameters (#2837) diff --git a/src/Timestampable/Traits/Timestampable.php b/src/Timestampable/Traits/Timestampable.php index 8ee48c85df..3be1388932 100644 --- a/src/Timestampable/Traits/Timestampable.php +++ b/src/Timestampable/Traits/Timestampable.php @@ -21,19 +21,19 @@ trait Timestampable /** * @var \DateTime|null */ - protected $createdAt; + protected ?\DateTime $createdAt; /** * @var \DateTime|null */ - protected $updatedAt; + protected ?\DateTime $updatedAt; /** * Sets createdAt. * * @return $this */ - public function setCreatedAt(\DateTime $createdAt) + public function setCreatedAt(\DateTime $createdAt): static { $this->createdAt = $createdAt; @@ -45,7 +45,7 @@ public function setCreatedAt(\DateTime $createdAt) * * @return \DateTime|null */ - public function getCreatedAt() + public function getCreatedAt(): ?\DateTime { return $this->createdAt; } @@ -55,7 +55,7 @@ public function getCreatedAt() * * @return $this */ - public function setUpdatedAt(\DateTime $updatedAt) + public function setUpdatedAt(\DateTime $updatedAt): static { $this->updatedAt = $updatedAt; @@ -67,7 +67,7 @@ public function setUpdatedAt(\DateTime $updatedAt) * * @return \DateTime|null */ - public function getUpdatedAt() + public function getUpdatedAt(): ?\DateTime { return $this->updatedAt; } diff --git a/src/Timestampable/Traits/TimestampableEntity.php b/src/Timestampable/Traits/TimestampableEntity.php index a224e67593..aca6e55005 100644 --- a/src/Timestampable/Traits/TimestampableEntity.php +++ b/src/Timestampable/Traits/TimestampableEntity.php @@ -31,7 +31,7 @@ trait TimestampableEntity */ #[Gedmo\Timestampable(on: 'create')] #[ORM\Column(type: Types::DATETIME_MUTABLE)] - protected $createdAt; + protected ?\DateTime $createdAt; /** * @var \DateTime|null @@ -42,14 +42,14 @@ trait TimestampableEntity */ #[Gedmo\Timestampable(on: 'update')] #[ORM\Column(type: Types::DATETIME_MUTABLE)] - protected $updatedAt; + protected ?\DateTime $updatedAt; /** * Sets createdAt. * * @return $this */ - public function setCreatedAt(\DateTime $createdAt) + public function setCreatedAt(\DateTime $createdAt): static { $this->createdAt = $createdAt; @@ -61,7 +61,7 @@ public function setCreatedAt(\DateTime $createdAt) * * @return \DateTime|null */ - public function getCreatedAt() + public function getCreatedAt(): ?\DateTime { return $this->createdAt; } @@ -71,7 +71,7 @@ public function getCreatedAt() * * @return $this */ - public function setUpdatedAt(\DateTime $updatedAt) + public function setUpdatedAt(\DateTime $updatedAt): static { $this->updatedAt = $updatedAt; @@ -83,7 +83,7 @@ public function setUpdatedAt(\DateTime $updatedAt) * * @return \DateTime|null */ - public function getUpdatedAt() + public function getUpdatedAt(): ?\DateTime { return $this->updatedAt; } From ff8f678b671de26aac39beac0e1a0356d9ad9642 Mon Sep 17 00:00:00 2001 From: George Salukvadze Date: Fri, 3 Jan 2025 14:11:29 +0100 Subject: [PATCH 2/2] - add types to createdAt and updatedAt in Timestampable --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2a4178567..06793ea714 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ a release. ## [Unreleased] ### New -- Add return types to createdAt and updatedAt +- Timestampable: Add types to createdAt and updatedAt ### Deprecated - Sluggable: Annotation-specific mapping parameters (#2837)