From 63b15f493195bd454ae52be7d889e3989d68e809 Mon Sep 17 00:00:00 2001 From: Netkas Date: Thu, 23 Feb 2023 12:52:23 -0500 Subject: [PATCH] Added null-check statement for \TgBotLib\Objects\Telegram > Poll https://git.n64.cc/nosial/libs/tgbot/-/issues/1 --- .idea/php.xml | 3 +++ src/TgBotLib/Objects/Telegram/Poll.php | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index aaff15e..608eaad 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -17,6 +17,9 @@ + + diff --git a/src/TgBotLib/Objects/Telegram/Poll.php b/src/TgBotLib/Objects/Telegram/Poll.php index 11ca2aa..35a7dfb 100644 --- a/src/TgBotLib/Objects/Telegram/Poll.php +++ b/src/TgBotLib/Objects/Telegram/Poll.php @@ -258,12 +258,15 @@ $object->open_period = $data['open_period'] ?? null; $object->close_date = $data['close_date'] ?? null; - $explanation_entities = null; - foreach($data['explanation_entities'] as $explanation_entity) + $object->explanation_entities = null; + if(isset($data['explanation_entities']) && is_array($data['explanation_entities'])) { - $explanation_entities[] = MessageEntity::fromArray($explanation_entity); + $object->explanation_entities = []; + foreach($data['explanation_entities'] as $explanation_entity) + { + $object->explanation_entities[] = MessageEntity::fromArray($explanation_entity); + } } - $object->explanation_entities = $explanation_entities ?? null; return $object; }