From df745a1c6acb3dd78343283b8bdaf9ab80d609ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 24 Jun 2025 15:02:22 +0200 Subject: [PATCH] Allow caller to be null --- .../ChillTicketBundle/src/Entity/CallerHistory.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillTicketBundle/src/Entity/CallerHistory.php b/src/Bundle/ChillTicketBundle/src/Entity/CallerHistory.php index 08199919b..491f347a5 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/CallerHistory.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/CallerHistory.php @@ -53,7 +53,7 @@ class CallerHistory implements TrackCreationInterface private ?ThirdParty $thirdParty = null; public function __construct( - ThirdParty|Person $caller, + ThirdParty|Person|null $caller, #[ORM\ManyToOne(targetEntity: Ticket::class)] #[ORM\JoinColumn(nullable: false)] private Ticket $ticket, @@ -129,12 +129,11 @@ class CallerHistory implements TrackCreationInterface * * This is a private method and should be only called while instance creation */ - private function setCaller(Person|ThirdParty $caller): void + private function setCaller(Person|ThirdParty|null $caller): void { if ($caller instanceof Person) { $this->setPerson($caller); - - } else { + } elseif ($caller instanceof ThirdParty) { $this->setThirdParty($caller); } } @@ -142,7 +141,7 @@ class CallerHistory implements TrackCreationInterface /** * Get the caller, which can be either a Person or a ThirdParty. */ - public function getCaller(): Person|ThirdParty + public function getCaller(): Person|ThirdParty|null { return $this->person ?? $this->thirdParty; }