From 7f02130ff24f563c3eef05bd4de1746209ed0208 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 16 Nov 2021 20:58:28 +0100 Subject: [PATCH] fix: Return type of getAge(). Issue highlighted by c68bda5c9b894236860fe1bacca8c9467052eb07. --- src/Bundle/ChillPersonBundle/Entity/Person.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index e17bd5ceb..fc6a7058f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -839,16 +839,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * If the person has a deathdate, calculate the age at the deathdate. * - * @param string $at a valid string to create a DateTime - * @return int|null + * @param string $at A valid string to create a DateTime. */ - public function getAge($at = 'now'): ?int + public function getAge(string $at = 'now'): ?int { if ($this->birthdate instanceof \DateTimeInterface) { if ($this->deathdate instanceof \DateTimeInterface) { - return date_diff($this->birthdate, $this->deathdate)->format("%y"); + return (int) date_diff($this->birthdate, $this->deathdate)->format('%y'); } - return date_diff($this->birthdate, date_create($at))->format("%y"); + + return (int) date_diff($this->birthdate, date_create($at))->format('%y'); } return null;