From 3c692424f727aa49fd115b856a0268fcae0176f0 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 4 Dec 2024 13:31:53 -0500 Subject: [PATCH] Allow nullable type for MessageEntity type --- src/TgBotLib/Objects/MessageEntity.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TgBotLib/Objects/MessageEntity.php b/src/TgBotLib/Objects/MessageEntity.php index e99a6c3..ff330a2 100644 --- a/src/TgBotLib/Objects/MessageEntity.php +++ b/src/TgBotLib/Objects/MessageEntity.php @@ -7,7 +7,7 @@ class MessageEntity implements ObjectTypeInterface { - private MessageEntityType $type; + private ?MessageEntityType $type; private int $offset; private int $length; private ?string $url; @@ -23,9 +23,9 @@ * (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), * “custom_emoji” (for inline custom emoji stickers) * - * @return MessageEntityType + * @return ?MessageEntityType */ - public function getType(): MessageEntityType + public function getType(): ?MessageEntityType { return $this->type; } @@ -33,10 +33,10 @@ /** * Sets the type of the entity * - * @param MessageEntityType $type + * @param ?MessageEntityType $type * @return MessageEntity */ - public function setType(MessageEntityType $type): MessageEntity + public function setType(?MessageEntityType $type): MessageEntity { $this->type = $type; return $this; @@ -223,7 +223,7 @@ } $object = new self(); - $object->type = MessageEntityType::tryFrom($data['type']); + $object->type = is_null($data['type']) ? null : MessageEntityType::tryFrom($data['type']); $object->offset = $data['offset'] ?? null; $object->length = $data['length'] ?? null; $object->url = $data['url'] ?? null;