Skip to content

Commit

Permalink
Fix some missing "user" to "users" changes
Browse files Browse the repository at this point in the history
  • Loading branch information
noplanman committed May 24, 2024
1 parent 99c49ad commit 231ab48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
Expand Down Expand Up @@ -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!');
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
);
}

Expand Down Expand Up @@ -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 (
Expand All @@ -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
)
Expand Down Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Entities/KeyboardButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);
Expand All @@ -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 = [];
Expand Down

0 comments on commit 231ab48

Please sign in to comment.