From 231ab481aca892c7192161cd2213bb09565a2e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Fri, 24 May 2024 22:41:19 +0200 Subject: [PATCH] Fix some missing "user" to "users" changes --- src/DB.php | 22 +++++++++++----------- tests/Unit/Entities/KeyboardButtonTest.php | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/DB.php b/src/DB.php index 25e5713a..cae89be1 100644 --- a/src/DB.php +++ b/src/DB.php @@ -78,7 +78,7 @@ public static function initialize( array $credentials, Telegram $telegram, $table_prefix = '', - $encoding = 'utf8mb4' + $encoding = 'utf8mb4', ): PDO { if (empty($credentials)) { throw new TelegramException('MySQL credentials not provided!'); @@ -127,7 +127,7 @@ public static function initialize( public static function externalInitialize( PDO $external_pdo_connection, Telegram $telegram, - string $table_prefix = '' + string $table_prefix = '', ): PDO { if ($external_pdo_connection === null) { throw new TelegramException('MySQL external connection not provided!'); @@ -300,12 +300,12 @@ protected static function getTimestamp(?int $unixtime = null): string /** * Convert array of Entity items to a JSON array * - * @todo Find a better way, as json_* functions are very heavy - * * @param array $entities * @param mixed $default * * @return mixed + * @todo Find a better way, as json_* functions are very heavy + * */ public static function entitiesArrayToJson(array $entities, $default = null) { @@ -346,7 +346,7 @@ protected static function insertTelegramUpdate( ?string $chat_member_updated_id = null, ?string $chat_join_request_id = null, ?string $chat_boost_updated_id = null, - ?string $chat_boost_removed_id = null + ?string $chat_boost_removed_id = null, ): ?bool { if ($message_id === null && $edited_message_id === null && $channel_post_id === null && $edited_channel_post_id === null && $message_reaction_id === null && $message_reaction_count_id === null && $inline_query_id === null && $chosen_inline_result_id === null && $callback_query_id === null && $shipping_query_id === null && $pre_checkout_query_id === null && $poll_id === null && $poll_answer_poll_id === null && $my_chat_member_updated_id === null && $chat_member_updated_id === null && $chat_join_request_id === null && $chat_boost_updated_id === null && $chat_boost_removed_id === null) { throw new TelegramException('message_id, edited_message_id, channel_post_id, edited_channel_post_id, message_reaction_id, message_reaction_count_id, inline_query_id, chosen_inline_result_id, callback_query_id, shipping_query_id, pre_checkout_query_id, poll_id, poll_answer_poll_id, my_chat_member_updated_id, chat_member_updated_id, chat_join_request_id, chat_boost_updated_id, chat_boost_removed_id are all null'); @@ -539,12 +539,12 @@ public static function insertChat(Chat $chat, ?string $date = null, ?int $migrat /** * Insert request into database * - * @todo self::$pdo->lastInsertId() - unsafe usage if expected previous insert fails? - * * @param Update $update * * @return bool * @throws TelegramException + * @todo self::$pdo->lastInsertId() - unsafe usage if expected previous insert fails? + * */ public static function insertRequest(Update $update): bool { @@ -640,7 +640,7 @@ public static function insertRequest(Update $update): bool $chat_member_updated_id, $chat_join_request_id, $chat_boost_updated_id, - $chat_boost_removed_id + $chat_boost_removed_id, ); } @@ -1322,7 +1322,7 @@ public static function insertMessageRequest(Message $message): bool `location`, `venue`, `poll`, `dice`, `new_chat_members`, `left_chat_member`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`, `supergroup_chat_created`, `channel_chat_created`, `message_auto_delete_timer_changed`, `migrate_to_chat_id`, `migrate_from_chat_id`, - `pinned_message`, `invoice`, `successful_payment`, `user_shared`, `chat_shared`, `connected_website`, `write_access_allowed`, `passport_data`, `proximity_alert_triggered`, + `pinned_message`, `invoice`, `successful_payment`, `users_shared`, `chat_shared`, `connected_website`, `write_access_allowed`, `passport_data`, `proximity_alert_triggered`, `forum_topic_created`, `forum_topic_edited`, `forum_topic_closed`, `forum_topic_reopened`, `general_forum_topic_hidden`, `general_forum_topic_unhidden`, `video_chat_scheduled`, `video_chat_started`, `video_chat_ended`, `video_chat_participants_invited`, `web_app_data`, `reply_markup` ) VALUES ( @@ -1333,7 +1333,7 @@ public static function insertMessageRequest(Message $message): bool :location, :venue, :poll, :dice, :new_chat_members, :left_chat_member, :new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created, :supergroup_chat_created, :channel_chat_created, :message_auto_delete_timer_changed, :migrate_to_chat_id, :migrate_from_chat_id, - :pinned_message, :invoice, :successful_payment, :user_shared, :chat_shared, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered, + :pinned_message, :invoice, :successful_payment, :users_shared, :chat_shared, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered, :forum_topic_created, :forum_topic_edited, :forum_topic_closed, :forum_topic_reopened, :general_forum_topic_hidden, :general_forum_topic_unhidden, :video_chat_scheduled, :video_chat_started, :video_chat_ended, :video_chat_participants_invited, :web_app_data, :reply_markup ) @@ -1411,7 +1411,7 @@ public static function insertMessageRequest(Message $message): bool $sth->bindValue(':pinned_message', $message->getPinnedMessage()); $sth->bindValue(':invoice', $message->getInvoice()); $sth->bindValue(':successful_payment', $message->getSuccessfulPayment()); - $sth->bindValue(':user_shared', $message->getUserShared()); + $sth->bindValue(':users_shared', $message->getUsersShared()); $sth->bindValue(':chat_shared', $message->getChatShared()); $sth->bindValue(':connected_website', $message->getConnectedWebsite()); $sth->bindValue(':write_access_allowed', $message->getWriteAccessAllowed()); diff --git a/tests/Unit/Entities/KeyboardButtonTest.php b/tests/Unit/Entities/KeyboardButtonTest.php index d8fc7840..e7cd907b 100644 --- a/tests/Unit/Entities/KeyboardButtonTest.php +++ b/tests/Unit/Entities/KeyboardButtonTest.php @@ -14,7 +14,7 @@ use Longman\TelegramBot\Entities\KeyboardButton; use Longman\TelegramBot\Entities\KeyboardButtonPollType; use Longman\TelegramBot\Entities\KeyboardButtonRequestChat; -use Longman\TelegramBot\Entities\KeyboardButtonRequestUser; +use Longman\TelegramBot\Entities\KeyboardButtonRequestUsers; use Longman\TelegramBot\Entities\WebAppInfo; use Longman\TelegramBot\Exception\TelegramException; use Longman\TelegramBot\Tests\Unit\TestCase; @@ -31,7 +31,7 @@ class KeyboardButtonTest extends TestCase public function testKeyboardButtonSuccess(): void { new KeyboardButton(['text' => 'message']); - new KeyboardButton(['text' => 'message', 'request_user' => new KeyboardButtonRequestUser([])]); + new KeyboardButton(['text' => 'message', 'request_users' => new KeyboardButtonRequestUsers([])]); new KeyboardButton(['text' => 'message', 'request_chat' => new KeyboardButtonRequestChat([])]); new KeyboardButton(['text' => 'message', 'request_contact' => true]); new KeyboardButton(['text' => 'message', 'request_location' => true]); @@ -49,8 +49,8 @@ public function testInlineKeyboardButtonCouldBe(): void public function testReturnsSubentitiesOnArray() { $button = new KeyboardButton('message'); - $button->request_user = []; - $this->assertInstanceOf(KeyboardButtonRequestUser::class, $button->getRequestUser()); + $button->request_users = []; + $this->assertInstanceOf(KeyboardButtonRequestUsers::class, $button->getRequestUsers()); $button = new KeyboardButton('message'); $button->request_chat = [];