From 6c2219f1ae8afb27ccdd733f141ace333fe6721b Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 12:14:32 -0400 Subject: [PATCH] Minor corrections --- src/TgBotLib/Objects/BotCommand.php | 7 ++++++- src/TgBotLib/Objects/BotDescription.php | 7 ++++++- src/TgBotLib/Objects/BotShortDescription.php | 8 ++++++-- src/TgBotLib/Objects/CallbackGame.php | 5 +++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/TgBotLib/Objects/BotCommand.php b/src/TgBotLib/Objects/BotCommand.php index 06a6c34..01b5bba 100644 --- a/src/TgBotLib/Objects/BotCommand.php +++ b/src/TgBotLib/Objects/BotCommand.php @@ -45,8 +45,13 @@ /** * @inheritDoc */ - public static function fromArray(?array $data): BotCommand + public static function fromArray(?array $data): ?BotCommand { + if($data === null) + { + return null; + } + $object = new self(); $object->command = $data['command'] ?? null; $object->description = $data['description'] ?? null; diff --git a/src/TgBotLib/Objects/BotDescription.php b/src/TgBotLib/Objects/BotDescription.php index 3009112..e45e00c 100644 --- a/src/TgBotLib/Objects/BotDescription.php +++ b/src/TgBotLib/Objects/BotDescription.php @@ -33,8 +33,13 @@ /** * @inheritDoc */ - public static function fromArray(?array $data): BotDescription + public static function fromArray(?array $data): ?BotDescription { + if($data === null) + { + return null; + } + $object = new self(); $object->description = $data['description']; diff --git a/src/TgBotLib/Objects/BotShortDescription.php b/src/TgBotLib/Objects/BotShortDescription.php index 8a43717..d8f7234 100644 --- a/src/TgBotLib/Objects/BotShortDescription.php +++ b/src/TgBotLib/Objects/BotShortDescription.php @@ -33,10 +33,14 @@ /** * @inheritDoc */ - public static function fromArray(?array $data): BotShortDescription + public static function fromArray(?array $data): ?BotShortDescription { - $object = new self(); + if($data === null) + { + return null; + } + $object = new self(); $object->short_description = $data['short_description']; return $object; diff --git a/src/TgBotLib/Objects/CallbackGame.php b/src/TgBotLib/Objects/CallbackGame.php index 3975eb3..ffc2174 100644 --- a/src/TgBotLib/Objects/CallbackGame.php +++ b/src/TgBotLib/Objects/CallbackGame.php @@ -21,6 +21,11 @@ */ public static function fromArray(?array $data): ?CallbackGame { + if($data === null) + { + return null; + } + return new self(); } } \ No newline at end of file