Added null-check statement for \TgBotLib\Objects\Telegram > Poll

https://git.n64.cc/nosial/libs/tgbot/-/issues/1
This commit is contained in:
Netkas 2023-02-23 12:52:23 -05:00
parent 0a7eeaa8ec
commit 63b15f4931
2 changed files with 10 additions and 4 deletions

3
.idea/php.xml generated
View file

@ -17,6 +17,9 @@
<path value="/var/ncc/packages/net.nosial.loglib=1.0.0" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.0">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>

View file

@ -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;
}