1 | <?php |
||
30 | trait User |
||
31 | { |
||
32 | /** @} */ |
||
33 | |||
34 | abstract public function getChat($chat_id); |
||
35 | |||
36 | abstract public function setChatID($chat_id); |
||
37 | |||
38 | abstract protected function sanitizeUserTable(); |
||
39 | |||
40 | /** PDO connection to the database. */ |
||
41 | public $pdo; |
||
42 | |||
43 | /** |
||
44 | * \addtogroup Bot Bot |
||
45 | * @{ |
||
46 | */ |
||
47 | |||
48 | /** |
||
49 | * \addtogroup Users-handle Users handling |
||
50 | * \brief Handle bot users on the database. |
||
51 | * @{ |
||
52 | */ |
||
53 | |||
54 | /** \brief Table contaning bot users data in the SQL database. */ |
||
55 | public $user_table = 'User'; |
||
56 | |||
57 | /** \brief Name of the column that represents the user id in the sql database */ |
||
58 | public $id_column = 'chat_id'; |
||
59 | |||
60 | /** \brief Add a user to the database. |
||
61 | * \details Add a user to the database in Bot::$user_table table and Bot::$id_column column using Bot::$pdo connection. |
||
62 | * @param string|int $chat_id chat ID of the user to add. |
||
63 | * @return bool True on success. |
||
64 | */ |
||
65 | public function addUser($chat_id) : bool |
||
91 | |||
92 | /** |
||
93 | * \brief Send a message to every user available on the database. |
||
94 | * \details Send a message to all subscribed users, change Bot::$user_table and Bot::$id_column to match your database structure. |
||
95 | * This method requires Bot::$pdo connection set. |
||
96 | * All parameters are the same as CoreBot::sendMessage. |
||
97 | * Because a limitation of Telegram Bot API the bot will have a delay after 20 messages sent in different chats. |
||
98 | * @return int How many messages were sent. |
||
99 | * @see CoreBot::sendMessage |
||
100 | */ |
||
101 | public function broadcastMessage( |
||
135 | |||
136 | /** @} */ |
||
137 | |||
138 | /** @} */ |
||
139 | } |
||
140 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.