From edd902d6b40d3cb2d7d3265669733f4b383bcb1c Mon Sep 17 00:00:00 2001 From: MBoretto Date: Wed, 29 Jun 2016 23:53:17 +0200 Subject: [PATCH] various --- src/BotanDB.php | 9 ++- .../AdminCommands/SendtochannelCommand.php | 9 ++- src/Commands/Command.php | 20 +++--- src/Commands/UserCommands/CancelCommand.php | 2 +- src/Commands/UserCommands/DateCommand.php | 2 +- src/Commands/UserCommands/SurveyCommand.php | 3 +- src/ConversationDB.php | 2 - src/DB.php | 31 +++++---- src/Entities/Audio.php | 5 ++ src/Entities/CallbackQuery.php | 5 ++ src/Entities/Chat.php | 5 ++ src/Entities/ChatMember.php | 5 ++ src/Entities/ChosenInlineResult.php | 5 ++ src/Entities/Contact.php | 5 ++ src/Entities/Document.php | 5 ++ src/Entities/File.php | 5 ++ src/Entities/ForceReply.php | 5 ++ src/Entities/InlineKeyboardButton.php | 5 ++ src/Entities/InlineKeyboardMarkup.php | 5 ++ src/Entities/InlineQuery.php | 5 ++ src/Entities/InlineQueryResult.php | 5 ++ src/Entities/InlineQueryResultArticle.php | 5 ++ src/Entities/InlineQueryResultAudio.php | 5 ++ src/Entities/InlineQueryResultCachedAudio.php | 5 ++ .../InlineQueryResultCachedDocument.php | 5 ++ src/Entities/InlineQueryResultCachedGif.php | 5 ++ .../InlineQueryResultCachedMpeg4Gif.php | 5 ++ src/Entities/InlineQueryResultCachedPhoto.php | 5 ++ .../InlineQueryResultCachedSticker.php | 5 ++ src/Entities/InlineQueryResultCachedVideo.php | 5 ++ src/Entities/InlineQueryResultCachedVoice.php | 5 ++ src/Entities/InlineQueryResultContact.php | 5 ++ src/Entities/InlineQueryResultDocument.php | 5 ++ src/Entities/InlineQueryResultGif.php | 5 ++ src/Entities/InlineQueryResultLocation.php | 5 ++ src/Entities/InlineQueryResultMpeg4Gif.php | 5 ++ src/Entities/InlineQueryResultPhoto.php | 5 ++ src/Entities/InlineQueryResultVenue.php | 5 ++ src/Entities/InlineQueryResultVideo.php | 5 ++ src/Entities/InlineQueryResultVoice.php | 5 ++ src/Entities/InputContactMessageContent.php | 5 ++ src/Entities/InputLocationMessageContent.php | 5 ++ src/Entities/InputTextMessageContent.php | 5 ++ src/Entities/InputVenueMessageContent.php | 5 ++ src/Entities/KeyboardButton.php | 5 ++ src/Entities/Location.php | 5 ++ src/Entities/Message.php | 63 ++++++++++++++++++- src/Entities/MessageEntity.php | 6 ++ src/Entities/PhotoSize.php | 8 ++- src/Entities/ReplyKeyboardHide.php | 7 ++- src/Entities/ReplyKeyboardMarkup.php | 5 ++ src/Entities/ReplyToMessage.php | 8 ++- src/Entities/ServerResponse.php | 8 ++- src/Entities/Sticker.php | 5 ++ src/Entities/Update.php | 6 ++ src/Entities/User.php | 5 ++ src/Entities/UserProfilePhotos.php | 5 ++ src/Entities/Venue.php | 5 ++ src/Entities/Video.php | 5 ++ src/Entities/Voice.php | 8 ++- src/Request.php | 4 +- src/Telegram.php | 11 +++- 62 files changed, 367 insertions(+), 60 deletions(-) diff --git a/src/BotanDB.php b/src/BotanDB.php index 274deff0c..fa769cea3 100644 --- a/src/BotanDB.php +++ b/src/BotanDB.php @@ -10,7 +10,6 @@ namespace Longman\TelegramBot; -use Longman\TelegramBot\DB; use Longman\TelegramBot\Exception\TelegramException; /** @@ -33,8 +32,10 @@ public static function initializeBotanDb() * * @param $user_id * @param $url - * @return bool|string + * * @throws TelegramException + * + * @return bool|string */ public static function selectShortUrl($user_id, $url) { @@ -65,8 +66,10 @@ public static function selectShortUrl($user_id, $url) * @param $user_id * @param $url * @param $short_url - * @return bool + * * @throws TelegramException + * + * @return bool */ public static function insertShortUrl($user_id, $url, $short_url) { diff --git a/src/Commands/AdminCommands/SendtochannelCommand.php b/src/Commands/AdminCommands/SendtochannelCommand.php index 44ad75e9a..609f5d5ce 100644 --- a/src/Commands/AdminCommands/SendtochannelCommand.php +++ b/src/Commands/AdminCommands/SendtochannelCommand.php @@ -33,7 +33,7 @@ class SendtochannelCommand extends AdminCommand /** * Conversation Object * - * @var Longman\TelegramBot\Conversation + * @var \Longman\TelegramBot\Conversation */ protected $conversation; @@ -128,7 +128,6 @@ public function execute() $this->conversation->notes['last_message_id'] = $message->getMessageId(); $this->conversation->notes['message'] = $message->reflect(); $this->conversation->notes['message_type'] = $type; - // no break case 2: if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) { @@ -258,7 +257,7 @@ public function executeNoDb() /** * Publish a message to a channel and return success or failure message * - * @param Entities\Message $message + * @param \Longman\TelegramBot\Entities\Message $message * @param int $channel * @param string|null $caption * @@ -292,10 +291,10 @@ protected function publish(Message $message, $channel, $caption = null) * @todo This method will be moved at an higher level maybe in AdminCommand or Command * @todo Looking for a more significative name * - * @param Entities\Message $message + * @param \Longman\TelegramBot\Entities\Message $message * @param array $data * - * @return Entities\ServerResponse + * @return \Longman\TelegramBot\Entities\ServerResponse */ protected function sendBack(Message $message, array $data) { diff --git a/src/Commands/Command.php b/src/Commands/Command.php index 3781eff64..4b768cdc7 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -13,9 +13,7 @@ use Longman\TelegramBot\DB; use Longman\TelegramBot\Request; use Longman\TelegramBot\Telegram; -use Longman\TelegramBot\Entities\Chat; use Longman\TelegramBot\Entities\Update; -use Longman\TelegramBot\Entities\User; /** * Abstract Command Class @@ -32,14 +30,14 @@ abstract class Command /** * Update object * - * @var Entities\Update + * @var \Longman\TelegramBot\Entities\Update */ protected $update; /** * Message object * - * @var Entities\Message + * @var \Longman\TelegramBot\Entities\Message */ protected $message; @@ -96,7 +94,7 @@ abstract class Command * Constructor * * @param Telegram $telegram - * @param Entities\Update $update + * @param \Longman\TelegramBot\Entities\Update $update */ public function __construct(Telegram $telegram, Update $update = null) { @@ -108,7 +106,7 @@ public function __construct(Telegram $telegram, Update $update = null) /** * Set update object * - * @param Entities\Update $update + * @param \Longman\TelegramBot\Entities\Update $update * @return Command */ public function setUpdate(Update $update = null) @@ -123,7 +121,7 @@ public function setUpdate(Update $update = null) /** * Pre-execute command * - * @return Entities\ServerResponse + * @return \Longman\TelegramBot\Entities\ServerResponse */ public function preExecute() { @@ -136,14 +134,14 @@ public function preExecute() /** * Execute command * - * @return Entities\ServerResponse + * @return \Longman\TelegramBot\Entities\ServerResponse */ abstract public function execute(); /** * Execution if MySQL is required but not available * - * @return Entities\ServerResponse + * @return \Longman\TelegramBot\Entities\ServerResponse */ public function executeNoDb() { @@ -162,7 +160,7 @@ public function executeNoDb() /** * Get update object * - * @return Entities\Update + * @return \Longman\TelegramBot\Entities\Update */ public function getUpdate() { @@ -172,7 +170,7 @@ public function getUpdate() /** * Get message object * - * @return Entities\Message + * @return \Longman\TelegramBot\Entities\Message */ public function getMessage() { diff --git a/src/Commands/UserCommands/CancelCommand.php b/src/Commands/UserCommands/CancelCommand.php index 19072dd95..65b70cc28 100644 --- a/src/Commands/UserCommands/CancelCommand.php +++ b/src/Commands/UserCommands/CancelCommand.php @@ -68,7 +68,7 @@ public function executeNoDb() * * @param string $text * - * @return Entities\ServerResponse + * @return \Longman\TelegramBot\Entities\ServerResponse */ private function hideKeyboard($text) { diff --git a/src/Commands/UserCommands/DateCommand.php b/src/Commands/UserCommands/DateCommand.php index 39a354495..653f5c198 100644 --- a/src/Commands/UserCommands/DateCommand.php +++ b/src/Commands/UserCommands/DateCommand.php @@ -202,7 +202,7 @@ public function execute() if (empty($location)) { $text = 'You must specify location in format: /date '; } else { - $text = $this->getformattedDate($location); + $text = $this->getFormattedDate($location); } $data = [ diff --git a/src/Commands/UserCommands/SurveyCommand.php b/src/Commands/UserCommands/SurveyCommand.php index b4b2f5bfa..728775157 100644 --- a/src/Commands/UserCommands/SurveyCommand.php +++ b/src/Commands/UserCommands/SurveyCommand.php @@ -35,7 +35,7 @@ class SurveyCommand extends UserCommand /** * Conversation Object * - * @var Longman\TelegramBot\Conversation + * @var \Longman\TelegramBot\Conversation */ protected $conversation; @@ -57,7 +57,6 @@ public function execute() $data = []; if ($chat->isGroupChat() || $chat->isSuperGroup()) { //reply to message id is applied by default - $data['reply_to_message_id'] = $message_id; //Force reply is applied by default to so can work with privacy on $data['reply_markup'] = new ForceReply([ 'selective' => true]); } diff --git a/src/ConversationDB.php b/src/ConversationDB.php index 1a071ac14..bd37866bb 100644 --- a/src/ConversationDB.php +++ b/src/ConversationDB.php @@ -10,7 +10,6 @@ namespace Longman\TelegramBot; -use Longman\TelegramBot\DB; use Longman\TelegramBot\Exception\TelegramException; /** @@ -49,7 +48,6 @@ public static function selectConversation($user_id, $chat_id, $limit = null) $query .= 'AND `chat_id` = :chat_id '; $query .= 'AND `user_id` = :user_id '; - $tokens = [':chat_id' => $chat_id, ':user_id' => $user_id]; if (!is_null($limit)) { $query .= ' LIMIT :limit'; } diff --git a/src/DB.php b/src/DB.php index a7b5ab8fb..811240311 100644 --- a/src/DB.php +++ b/src/DB.php @@ -199,7 +199,7 @@ public static function selectTelegramUpdate($limit = null) $sth_select_telegram_update->bindParam(':limit', $limit, \PDO::PARAM_INT); $sth_select_telegram_update->execute(); $results = $sth_select_telegram_update->fetchAll(\PDO::FETCH_ASSOC); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } @@ -234,7 +234,7 @@ public static function selectMessages($limit = null) $sth->bindParam(':limit', $limit, \PDO::PARAM_INT); $sth->execute(); $results = $sth->fetchAll(\PDO::FETCH_ASSOC); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } @@ -299,7 +299,7 @@ public static function insertTelegramUpdate($id, $chat_id, $message_id, $inline_ $sth_insert_telegram_update->bindParam(':edited_message_id', $edited_message_id, \PDO::PARAM_INT); return $sth_insert_telegram_update->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -344,7 +344,7 @@ public static function insertUser(User $user, $date, Chat $chat = null) $sth1->bindParam(':date', $date, \PDO::PARAM_STR); $status = $sth1->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } @@ -364,7 +364,7 @@ public static function insertUser(User $user, $date, Chat $chat = null) $sth3->bindParam(':chat_id', $chat_id, \PDO::PARAM_INT); $status = $sth3->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -418,7 +418,7 @@ public static function insertChat(Chat $chat, $date, $migrate_to_chat_id = null) $sth2->bindParam(':date', $date, \PDO::PARAM_STR); return $sth2->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -523,7 +523,7 @@ public static function insertInlineQueryRequest(InlineQuery &$inline_query) $sth_insert_inline_query->bindParam(':created_at', $date, \PDO::PARAM_STR); return $sth_insert_inline_query->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -574,7 +574,7 @@ public static function insertChosenInlineResultRequest(ChosenInlineResult &$chos $sth_insert_chosen_inline_result->bindParam(':created_at', $date, \PDO::PARAM_STR); return $sth_insert_chosen_inline_result->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -626,7 +626,7 @@ public static function insertCallbackQueryRequest(CallbackQuery &$callback_query $sth_insert_callback_query->bindParam(':created_at', $date, \PDO::PARAM_STR); return $sth_insert_callback_query->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -666,18 +666,15 @@ public static function insertMessageRequest(Message &$message) //Insert user and the relation with the chat self::insertUser($from, $date, $chat); - //Forwarded object - if ($forward_from || $forward_from_chat) { - $forward_date = self::getTimestamp($message->getForwardDate()); - } - //Insert the forwarded message user in users table if (is_object($forward_from)) { + $forward_date = self::getTimestamp($message->getForwardDate()); self::insertUser($forward_from, $forward_date); $forward_from = $forward_from->getId(); } if (is_object($forward_from_chat)) { + $forward_date = self::getTimestamp($message->getForwardDate()); self::insertChat($forward_from_chat, $forward_date); $forward_from_chat = $forward_from_chat->getId(); } @@ -821,7 +818,7 @@ public static function insertMessageRequest(Message &$message) $sth->bindParam(':pinned_message', $pinned_message, \PDO::PARAM_INT); return $sth->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -885,7 +882,7 @@ public static function insertEditedMessageRequest(Message &$edited_message) $sth->bindParam(':caption', $caption, \PDO::PARAM_STR); return $sth->execute(); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } } @@ -1001,7 +998,7 @@ public static function selectChats( $sth->execute($tokens); $result = $sth->fetchAll(\PDO::FETCH_ASSOC); - } catch (PDOException $e) { + } catch (\PDOException $e) { throw new TelegramException($e->getMessage()); } diff --git a/src/Entities/Audio.php b/src/Entities/Audio.php index 2727bc6b6..f9a54766f 100644 --- a/src/Entities/Audio.php +++ b/src/Entities/Audio.php @@ -21,6 +21,11 @@ class Audio extends Entity protected $mime_type; protected $file_size; + /** + * Audio constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->file_id = isset($data['file_id']) ? $data['file_id'] : null; diff --git a/src/Entities/CallbackQuery.php b/src/Entities/CallbackQuery.php index 3b3adf2fa..0a52d84b8 100644 --- a/src/Entities/CallbackQuery.php +++ b/src/Entities/CallbackQuery.php @@ -20,6 +20,11 @@ class CallbackQuery extends Entity protected $inline_message_id; protected $data; + /** + * CallbackQuery constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->id = isset($data['id']) ? $data['id'] : null; diff --git a/src/Entities/Chat.php b/src/Entities/Chat.php index 028e4bd0a..64ba64208 100644 --- a/src/Entities/Chat.php +++ b/src/Entities/Chat.php @@ -21,6 +21,11 @@ class Chat extends Entity protected $first_name; protected $last_name; + /** + * Chat constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->id = isset($data['id']) ? $data['id'] : null; diff --git a/src/Entities/ChatMember.php b/src/Entities/ChatMember.php index b88833013..4d95ac2ad 100644 --- a/src/Entities/ChatMember.php +++ b/src/Entities/ChatMember.php @@ -15,6 +15,11 @@ class ChatMember extends Entity protected $user; protected $status; + /** + * ChatMember constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->user = isset($data['user']) ? $data['user'] : null; diff --git a/src/Entities/ChosenInlineResult.php b/src/Entities/ChosenInlineResult.php index d492dc78c..dcef38d33 100644 --- a/src/Entities/ChosenInlineResult.php +++ b/src/Entities/ChosenInlineResult.php @@ -20,6 +20,11 @@ class ChosenInlineResult extends Entity protected $inline_message_id; protected $query; + /** + * ChosenInlineResult constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->result_id = isset($data['result_id']) ? $data['result_id'] : null; diff --git a/src/Entities/Contact.php b/src/Entities/Contact.php index ade6c01b6..fb12b995f 100644 --- a/src/Entities/Contact.php +++ b/src/Entities/Contact.php @@ -19,6 +19,11 @@ class Contact extends Entity protected $last_name; protected $user_id; + /** + * Contact constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null; diff --git a/src/Entities/Document.php b/src/Entities/Document.php index 20ef94aa5..7374f008b 100644 --- a/src/Entities/Document.php +++ b/src/Entities/Document.php @@ -20,6 +20,11 @@ class Document extends Entity protected $mime_type; protected $file_size; + /** + * Document constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->file_id = isset($data['file_id']) ? $data['file_id'] : null; diff --git a/src/Entities/File.php b/src/Entities/File.php index a71eb9891..13f826650 100644 --- a/src/Entities/File.php +++ b/src/Entities/File.php @@ -18,6 +18,11 @@ class File extends Entity protected $file_size; protected $file_path; + /** + * File constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->file_id = isset($data['file_id']) ? $data['file_id'] : null; diff --git a/src/Entities/ForceReply.php b/src/Entities/ForceReply.php index 591bf4e79..48361b2ac 100644 --- a/src/Entities/ForceReply.php +++ b/src/Entities/ForceReply.php @@ -19,6 +19,11 @@ class ForceReply extends Entity protected $force_reply; protected $selective; + /** + * ForceReply constructor. + * + * @param array|null $data + */ public function __construct(array $data = null) { $this->force_reply = true; diff --git a/src/Entities/InlineKeyboardButton.php b/src/Entities/InlineKeyboardButton.php index b96496389..0b8a7b101 100644 --- a/src/Entities/InlineKeyboardButton.php +++ b/src/Entities/InlineKeyboardButton.php @@ -19,8 +19,13 @@ class InlineKeyboardButton extends Entity protected $callback_data; protected $switch_inline_query; + /** + * InlineKeyboardButton constructor. + * * @todo check if only one of 'url, callback_data, switch_inline_query' fields is set, documentation states that only one of these can be used + * + * @param array $data */ public function __construct($data = array()) { diff --git a/src/Entities/InlineKeyboardMarkup.php b/src/Entities/InlineKeyboardMarkup.php index 3908f7fed..c944593ce 100644 --- a/src/Entities/InlineKeyboardMarkup.php +++ b/src/Entities/InlineKeyboardMarkup.php @@ -16,6 +16,11 @@ class InlineKeyboardMarkup extends Entity { protected $inline_keyboard; + /** + * InlineKeyboardMarkup constructor. + * + * @param array $data + */ public function __construct($data = array()) { if (isset($data['inline_keyboard'])) { diff --git a/src/Entities/InlineQuery.php b/src/Entities/InlineQuery.php index 882f12316..6cc090d01 100644 --- a/src/Entities/InlineQuery.php +++ b/src/Entities/InlineQuery.php @@ -20,6 +20,11 @@ class InlineQuery extends Entity protected $query; protected $offset; + /** + * InlineQuery constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->id = isset($data['id']) ? $data['id'] : null; diff --git a/src/Entities/InlineQueryResult.php b/src/Entities/InlineQueryResult.php index 67759257c..4008da63e 100644 --- a/src/Entities/InlineQueryResult.php +++ b/src/Entities/InlineQueryResult.php @@ -19,6 +19,11 @@ class InlineQueryResult extends Entity protected $input_message_content; protected $reply_markup; + /** + * InlineQueryResult constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->type = null; diff --git a/src/Entities/InlineQueryResultArticle.php b/src/Entities/InlineQueryResultArticle.php index 64f3d6050..be6ed9f69 100644 --- a/src/Entities/InlineQueryResultArticle.php +++ b/src/Entities/InlineQueryResultArticle.php @@ -23,6 +23,11 @@ class InlineQueryResultArticle extends InlineQueryResult protected $thumb_width; protected $thumb_height; + /** + * InlineQueryResultArticle constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultAudio.php b/src/Entities/InlineQueryResultAudio.php index 10932a03d..256e11bc8 100644 --- a/src/Entities/InlineQueryResultAudio.php +++ b/src/Entities/InlineQueryResultAudio.php @@ -19,6 +19,11 @@ class InlineQueryResultAudio extends InlineQueryResult protected $performer; protected $audio_duration; + /** + * InlineQueryResultAudio constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedAudio.php b/src/Entities/InlineQueryResultCachedAudio.php index 4b645d561..c013b7d33 100644 --- a/src/Entities/InlineQueryResultCachedAudio.php +++ b/src/Entities/InlineQueryResultCachedAudio.php @@ -16,6 +16,11 @@ class InlineQueryResultCachedAudio extends InlineQueryResult { protected $audio_file_id; + /** + * InlineQueryResultCachedAudio constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedDocument.php b/src/Entities/InlineQueryResultCachedDocument.php index 272df8307..f366cf20d 100644 --- a/src/Entities/InlineQueryResultCachedDocument.php +++ b/src/Entities/InlineQueryResultCachedDocument.php @@ -19,6 +19,11 @@ class InlineQueryResultCachedDocument extends InlineQueryResult protected $description; protected $caption; + /** + * InlineQueryResultCachedDocument constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedGif.php b/src/Entities/InlineQueryResultCachedGif.php index a185212b7..1dde899bd 100644 --- a/src/Entities/InlineQueryResultCachedGif.php +++ b/src/Entities/InlineQueryResultCachedGif.php @@ -19,6 +19,11 @@ class InlineQueryResultCachedGif extends InlineQueryResult protected $description; protected $caption; + /** + * InlineQueryResultCachedGif constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedMpeg4Gif.php b/src/Entities/InlineQueryResultCachedMpeg4Gif.php index 783c2bad3..cb12f0c4f 100644 --- a/src/Entities/InlineQueryResultCachedMpeg4Gif.php +++ b/src/Entities/InlineQueryResultCachedMpeg4Gif.php @@ -18,6 +18,11 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult protected $title; protected $caption; + /** + * InlineQueryResultCachedMpeg4Gif constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedPhoto.php b/src/Entities/InlineQueryResultCachedPhoto.php index b28818631..d88a310fa 100644 --- a/src/Entities/InlineQueryResultCachedPhoto.php +++ b/src/Entities/InlineQueryResultCachedPhoto.php @@ -19,6 +19,11 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult protected $description; protected $caption; + /** + * InlineQueryResultCachedPhoto constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedSticker.php b/src/Entities/InlineQueryResultCachedSticker.php index 5c75fc382..b2ff0b804 100644 --- a/src/Entities/InlineQueryResultCachedSticker.php +++ b/src/Entities/InlineQueryResultCachedSticker.php @@ -16,6 +16,11 @@ class InlineQueryResultCachedSticker extends InlineQueryResult { protected $sticker_file_id; + /** + * InlineQueryResultCachedSticker constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedVideo.php b/src/Entities/InlineQueryResultCachedVideo.php index d18989dcb..51d01d4bd 100644 --- a/src/Entities/InlineQueryResultCachedVideo.php +++ b/src/Entities/InlineQueryResultCachedVideo.php @@ -19,6 +19,11 @@ class InlineQueryResultCachedVideo extends InlineQueryResult protected $description; protected $caption; + /** + * InlineQueryResultCachedVideo constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultCachedVoice.php b/src/Entities/InlineQueryResultCachedVoice.php index 823677a7d..b976dcd22 100644 --- a/src/Entities/InlineQueryResultCachedVoice.php +++ b/src/Entities/InlineQueryResultCachedVoice.php @@ -19,6 +19,11 @@ class InlineQueryResultCachedVoice extends InlineQueryResult protected $description; protected $caption; + /** + * InlineQueryResultCachedVoice constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultContact.php b/src/Entities/InlineQueryResultContact.php index f974a6685..5e766506c 100644 --- a/src/Entities/InlineQueryResultContact.php +++ b/src/Entities/InlineQueryResultContact.php @@ -21,6 +21,11 @@ class InlineQueryResultContact extends InlineQueryResult protected $thumb_width; protected $thumb_height; + /** + * InlineQueryResultContact constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultDocument.php b/src/Entities/InlineQueryResultDocument.php index 76b64c453..b8894db94 100644 --- a/src/Entities/InlineQueryResultDocument.php +++ b/src/Entities/InlineQueryResultDocument.php @@ -23,6 +23,11 @@ class InlineQueryResultDocument extends InlineQueryResult protected $thumb_width; protected $thumb_height; + /** + * InlineQueryResultDocument constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultGif.php b/src/Entities/InlineQueryResultGif.php index 6c09ca3ce..7157ff2e6 100644 --- a/src/Entities/InlineQueryResultGif.php +++ b/src/Entities/InlineQueryResultGif.php @@ -21,6 +21,11 @@ class InlineQueryResultGif extends InlineQueryResult protected $title; protected $caption; + /** + * InlineQueryResultGif constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultLocation.php b/src/Entities/InlineQueryResultLocation.php index 9216cec4a..186042c13 100644 --- a/src/Entities/InlineQueryResultLocation.php +++ b/src/Entities/InlineQueryResultLocation.php @@ -21,6 +21,11 @@ class InlineQueryResultLocation extends InlineQueryResult protected $thumb_width; protected $thumb_height; + /** + * InlineQueryResultLocation constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultMpeg4Gif.php b/src/Entities/InlineQueryResultMpeg4Gif.php index 93ac3a60a..cbde694f1 100644 --- a/src/Entities/InlineQueryResultMpeg4Gif.php +++ b/src/Entities/InlineQueryResultMpeg4Gif.php @@ -21,6 +21,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult protected $title; protected $caption; + /** + * InlineQueryResultMpeg4Gif constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultPhoto.php b/src/Entities/InlineQueryResultPhoto.php index d4ac79ff5..644e3a2d8 100644 --- a/src/Entities/InlineQueryResultPhoto.php +++ b/src/Entities/InlineQueryResultPhoto.php @@ -22,6 +22,11 @@ class InlineQueryResultPhoto extends InlineQueryResult protected $description; protected $caption; + /** + * InlineQueryResultPhoto constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultVenue.php b/src/Entities/InlineQueryResultVenue.php index 1d9999d67..2c2caa150 100644 --- a/src/Entities/InlineQueryResultVenue.php +++ b/src/Entities/InlineQueryResultVenue.php @@ -23,6 +23,11 @@ class InlineQueryResultVenue extends InlineQueryResult protected $thumb_width; protected $thumb_height; + /** + * InlineQueryResultVenue constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultVideo.php b/src/Entities/InlineQueryResultVideo.php index d4d5b5386..aa3274dd7 100644 --- a/src/Entities/InlineQueryResultVideo.php +++ b/src/Entities/InlineQueryResultVideo.php @@ -24,6 +24,11 @@ class InlineQueryResultVideo extends InlineQueryResult protected $video_duration; protected $description; + /** + * InlineQueryResultVideo constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InlineQueryResultVoice.php b/src/Entities/InlineQueryResultVoice.php index e9f9fe49c..84e8f31b0 100644 --- a/src/Entities/InlineQueryResultVoice.php +++ b/src/Entities/InlineQueryResultVoice.php @@ -18,6 +18,11 @@ class InlineQueryResultVoice extends InlineQueryResult protected $title; protected $voice_duration; + /** + * InlineQueryResultVoice constructor. + * + * @param array $data + */ public function __construct(array $data) { parent::__construct($data); diff --git a/src/Entities/InputContactMessageContent.php b/src/Entities/InputContactMessageContent.php index ced179099..da0e20a57 100644 --- a/src/Entities/InputContactMessageContent.php +++ b/src/Entities/InputContactMessageContent.php @@ -18,6 +18,11 @@ class InputContactMessageContent extends InputMessageContent protected $first_name; protected $last_name; + /** + * InputContactMessageContent constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null; diff --git a/src/Entities/InputLocationMessageContent.php b/src/Entities/InputLocationMessageContent.php index 4219c12f7..7ef07a14f 100644 --- a/src/Entities/InputLocationMessageContent.php +++ b/src/Entities/InputLocationMessageContent.php @@ -17,6 +17,11 @@ class InputLocationMessageContent extends InputMessageContent protected $latitude; protected $longitude; + /** + * InputLocationMessageContent constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->latitude = isset($data['latitude']) ? $data['latitude'] : null; diff --git a/src/Entities/InputTextMessageContent.php b/src/Entities/InputTextMessageContent.php index 645c6cb68..e4279d65c 100644 --- a/src/Entities/InputTextMessageContent.php +++ b/src/Entities/InputTextMessageContent.php @@ -18,6 +18,11 @@ class InputTextMessageContent extends InputMessageContent protected $parse_mode; protected $disable_web_page_preview; + /** + * InputTextMessageContent constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->message_text = isset($data['message_text']) ? $data['message_text'] : null; diff --git a/src/Entities/InputVenueMessageContent.php b/src/Entities/InputVenueMessageContent.php index 7d7fe47f3..da79fffe8 100644 --- a/src/Entities/InputVenueMessageContent.php +++ b/src/Entities/InputVenueMessageContent.php @@ -20,6 +20,11 @@ class InputVenueMessageContent extends InputMessageContent protected $address; protected $foursquare_id; + /** + * InputVenueMessageContent constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->latitude = isset($data['latitude']) ? $data['latitude'] : null; diff --git a/src/Entities/KeyboardButton.php b/src/Entities/KeyboardButton.php index cdb072cc8..faf4919ce 100644 --- a/src/Entities/KeyboardButton.php +++ b/src/Entities/KeyboardButton.php @@ -18,6 +18,11 @@ class KeyboardButton extends Entity protected $request_contact; protected $request_location; + /** + * KeyboardButton constructor. + * + * @param array $data + */ public function __construct($data = array()) { $this->text = isset($data['text']) ? $data['text'] : null; diff --git a/src/Entities/Location.php b/src/Entities/Location.php index 83bbb798a..b32d26ea6 100644 --- a/src/Entities/Location.php +++ b/src/Entities/Location.php @@ -18,6 +18,11 @@ class Location extends Entity protected $longitude; protected $latitude; + /** + * Location constructor. + * + * @param array $data + */ public function __construct(array $data) { diff --git a/src/Entities/Message.php b/src/Entities/Message.php index 2773f2745..a340ea8cc 100644 --- a/src/Entities/Message.php +++ b/src/Entities/Message.php @@ -82,6 +82,12 @@ class Message extends Entity private $type; + /** + * Message constructor. + * + * @param array $data + * @param $bot_name + */ public function __construct(array $data, $bot_name) { @@ -334,6 +340,11 @@ public function getMessageId() return $this->message_id; } + /** + * Get User object related to the message + * + * @return \Longman\TelegramBot\Entities\User + */ public function getFrom() { return $this->from; @@ -344,16 +355,31 @@ public function getDate() return $this->date; } + /** + * Get User object related to the message + * + * @return \Longman\TelegramBot\Entities\Chat + */ public function getChat() { return $this->chat; } + /** + * Get User object related to the forwarded message + * + * @return \Longman\TelegramBot\Entities\User + */ public function getForwardFrom() { return $this->forward_from; } + /** + * Get User object related to the message + * + * @return \Longman\TelegramBot\Entities\Chat + */ public function getForwardFromChat() { return $this->forward_from_chat; @@ -388,30 +414,48 @@ public function getText($without_cmd = false) return $text; } + /** + * @return \Longman\TelegramBot\Entities\Audio + */ public function getAudio() { return $this->audio; } + + /** + * @return \Longman\TelegramBot\Entities\Document + */ public function getDocument() { return $this->document; } + /** + * @return array + */ public function getPhoto() { return $this->photo; } + /** + * @return \Longman\TelegramBot\Entities\Sticker + */ public function getSticker() { return $this->sticker; } + /** + * @return \Longman\TelegramBot\Entities\Video + */ public function getVideo() { return $this->video; } - + /** + * @return \Longman\TelegramBot\Entities\Voice + */ public function getVoice() { return $this->voice; @@ -422,11 +466,17 @@ public function getCaption() return $this->caption; } + /** + * @return \Longman\TelegramBot\Entities\Contact + */ public function getContact() { return $this->contact; } + /** + * @return \Longman\TelegramBot\Entities\Location + */ public function getLocation() { return $this->location; @@ -446,12 +496,21 @@ public function getLeftChatParticipant() { return $this->left_chat_member; } - + /** + * Get User object related to the new member + * + * @return \Longman\TelegramBot\Entities\User + */ public function getNewChatMember() { return $this->new_chat_member; } + /** + * Get User object related to the left member + * + * @return \Longman\TelegramBot\Entities\User + */ public function getLeftChatMember() { return $this->left_chat_member; diff --git a/src/Entities/MessageEntity.php b/src/Entities/MessageEntity.php index 549089904..7406495a9 100644 --- a/src/Entities/MessageEntity.php +++ b/src/Entities/MessageEntity.php @@ -10,6 +10,8 @@ namespace Longman\TelegramBot\Entities; +use Longman\TelegramBot\Exception\TelegramException; + class MessageEntity extends Entity { protected $type; @@ -19,7 +21,11 @@ class MessageEntity extends Entity protected $user; /** + * MessageEntity constructor. + * * @todo check for type value from this list: https://core.telegram.org/bots/api#messageentity + * + * @param array $data */ public function __construct(array $data) { diff --git a/src/Entities/PhotoSize.php b/src/Entities/PhotoSize.php index b1950baf1..18b3155e4 100644 --- a/src/Entities/PhotoSize.php +++ b/src/Entities/PhotoSize.php @@ -18,8 +18,12 @@ class PhotoSize extends Entity protected $width; protected $height; protected $file_size; - - + + /** + * PhotoSize constructor. + * + * @param array $data + */ public function __construct(array $data) { diff --git a/src/Entities/ReplyKeyboardHide.php b/src/Entities/ReplyKeyboardHide.php index 300c8c3f9..64bde7f54 100644 --- a/src/Entities/ReplyKeyboardHide.php +++ b/src/Entities/ReplyKeyboardHide.php @@ -12,13 +12,16 @@ namespace Longman\TelegramBot\Entities; -use Longman\TelegramBot\Exception\TelegramException; - class ReplyKeyboardHide extends Entity { protected $hide_keyboard; protected $selective; + /** + * ReplyKeyboardHide constructor. + * + * @param array|null $data + */ public function __construct(array $data = null) { $this->hide_keyboard = true; diff --git a/src/Entities/ReplyKeyboardMarkup.php b/src/Entities/ReplyKeyboardMarkup.php index f9fcdf232..b2dc40582 100644 --- a/src/Entities/ReplyKeyboardMarkup.php +++ b/src/Entities/ReplyKeyboardMarkup.php @@ -21,6 +21,11 @@ class ReplyKeyboardMarkup extends Entity protected $one_time_keyboard; protected $selective; + /** + * ReplyKeyboardMarkup constructor. + * + * @param array $data + */ public function __construct($data = array()) { if (isset($data['keyboard'])) { diff --git a/src/Entities/ReplyToMessage.php b/src/Entities/ReplyToMessage.php index 37285acf6..3a85597a3 100644 --- a/src/Entities/ReplyToMessage.php +++ b/src/Entities/ReplyToMessage.php @@ -10,11 +10,15 @@ namespace Longman\TelegramBot\Entities; -use Longman\TelegramBot\Exception\TelegramException; - class ReplyToMessage extends Message { + /** + * ReplyToMessage constructor. + * + * @param array $data + * @param $bot_name + */ public function __construct(array $data, $bot_name) { diff --git a/src/Entities/ServerResponse.php b/src/Entities/ServerResponse.php index e58cef589..5378c1e25 100644 --- a/src/Entities/ServerResponse.php +++ b/src/Entities/ServerResponse.php @@ -10,8 +10,6 @@ namespace Longman\TelegramBot\Entities; -use Longman\TelegramBot\Exception\TelegramException; - class ServerResponse extends Entity { protected $ok; @@ -19,6 +17,12 @@ class ServerResponse extends Entity protected $error_code; protected $description; + /** + * ServerResponse constructor. + * + * @param array $data + * @param $bot_name + */ public function __construct(array $data, $bot_name) { if (isset($data['ok']) & isset($data['result'])) { diff --git a/src/Entities/Sticker.php b/src/Entities/Sticker.php index d346caf8d..482a2b472 100644 --- a/src/Entities/Sticker.php +++ b/src/Entities/Sticker.php @@ -21,6 +21,11 @@ class Sticker extends Entity protected $emoji; protected $file_size; + /** + * Sticker constructor. + * + * @param array $data + */ public function __construct(array $data) { diff --git a/src/Entities/Update.php b/src/Entities/Update.php index 12cd38440..581d1eefb 100644 --- a/src/Entities/Update.php +++ b/src/Entities/Update.php @@ -24,6 +24,12 @@ class Update extends Entity private $update_type; + /** + * Update constructor. + * + * @param array $data + * @param $bot_name + */ public function __construct(array $data, $bot_name) { diff --git a/src/Entities/User.php b/src/Entities/User.php index d28f94e09..273b15623 100644 --- a/src/Entities/User.php +++ b/src/Entities/User.php @@ -20,6 +20,11 @@ class User extends Entity protected $last_name; protected $username; + /** + * User constructor. + * + * @param array $data + */ public function __construct(array $data) { diff --git a/src/Entities/UserProfilePhotos.php b/src/Entities/UserProfilePhotos.php index 3dd1c6b25..558edf879 100644 --- a/src/Entities/UserProfilePhotos.php +++ b/src/Entities/UserProfilePhotos.php @@ -18,6 +18,11 @@ class UserProfilePhotos extends Entity protected $total_count; protected $photos; + /** + * UserProfilePhotos constructor. + * + * @param array $data + */ public function __construct(array $data) { diff --git a/src/Entities/Venue.php b/src/Entities/Venue.php index 4b25ae390..f960be2c4 100644 --- a/src/Entities/Venue.php +++ b/src/Entities/Venue.php @@ -21,6 +21,11 @@ class Venue extends Entity protected $address; protected $foursquare_id; + /** + * Venue constructor. + * + * @param array $data + */ public function __construct(array $data) { $this->location = isset($data['location']) ? $data['location'] : null; diff --git a/src/Entities/Video.php b/src/Entities/Video.php index 6c0e6f0a9..012a72e08 100644 --- a/src/Entities/Video.php +++ b/src/Entities/Video.php @@ -22,6 +22,11 @@ class Video extends Entity protected $mime_type; protected $file_size; + /** + * Video constructor. + * + * @param array $data + */ public function __construct(array $data) { diff --git a/src/Entities/Voice.php b/src/Entities/Voice.php index 93d1b898c..9a67e858e 100644 --- a/src/Entities/Voice.php +++ b/src/Entities/Voice.php @@ -19,10 +19,13 @@ class Voice extends Entity protected $mime_type; protected $file_size; - + /** + * Voice constructor. + * + * @param array $data + */ public function __construct(array $data) { - $this->file_id = isset($data['file_id']) ? $data['file_id'] : null; if (empty($this->file_id)) { throw new TelegramException('file_id is empty!'); @@ -35,7 +38,6 @@ public function __construct(array $data) $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null; $this->file_size = isset($data['file_size']) ? $data['file_size'] : null; - } public function getFileId() diff --git a/src/Request.php b/src/Request.php index 7d73ec426..0316cca46 100644 --- a/src/Request.php +++ b/src/Request.php @@ -239,7 +239,7 @@ public static function downloadFile(File $file) * * @param string $file * - * @return CURLFile + * @return \CURLFile */ protected static function encodeFile($file) { @@ -308,7 +308,7 @@ public static function sendMessage(array $data) $string_len_utf8 = mb_strlen($text, 'UTF-8'); if ($string_len_utf8 > 4096) { $data['text'] = mb_substr($text, 0, 4096); - $result = self::send('sendMessage', $data); + self::send('sendMessage', $data); $data['text'] = mb_substr($text, 4096, $string_len_utf8); return self::sendMessage($data); } diff --git a/src/Telegram.php b/src/Telegram.php index 6c04a9e41..1c8165260 100644 --- a/src/Telegram.php +++ b/src/Telegram.php @@ -171,7 +171,7 @@ public function enableMySql(array $credential, $table_prefix = null, $encoding = /** * Initialize Database external connection * - * @param PDO $external_pdo_connection PDO database object + * @param /PDO $external_pdo_connection PDO database object * @param string $table_prefix */ public function enableExternalMysql($external_pdo_connection, $table_prefix = null) @@ -230,7 +230,7 @@ public function getCommandsList() * * @param string $command * - * @return Entities\Command|null + * @return \Longman\TelegramBot\Commands\Command|null */ public function getCommandObject($command) { @@ -445,8 +445,13 @@ public function executeCommand($command) return $this->last_command_response; } + /** - * @todo Complete DocBlock + * Sanitize Command + * + * @param string $command + * + * @return string */ protected function sanitizeCommand($command) {