From 5c86459f8404631fb4f93da668b3d3e377a70c45 Mon Sep 17 00:00:00 2001 From: Pier <61907396+Pier-d@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:24:33 +0200 Subject: [PATCH] Update WhatsAppTemplate.php (#508) Avoiding Error Typed property Vonage\Messages\Channel\WhatsApp\WhatsAppTemplate::$context must not be accessed before initialization --- src/Messages/Channel/WhatsApp/WhatsAppTemplate.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php b/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php index f2141263..186b8f5f 100644 --- a/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php +++ b/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php @@ -34,9 +34,7 @@ public function toArray(): array ] ]; - if (!is_null($this->context)) { - $returnArray['context'] = $this->context; - } + $returnArray['context'] = $this->context ?? null; return array_merge($this->getBaseMessageUniversalOutputArray(), $returnArray); } @@ -50,4 +48,4 @@ public function setLocale($locale): void { $this->locale = $locale; } -} \ No newline at end of file +}