1 | <?php |
||
19 | class Conversation |
||
20 | { |
||
21 | /** |
||
22 | * All information fetched from the database |
||
23 | * |
||
24 | * @var array|null |
||
25 | */ |
||
26 | protected $conversation; |
||
27 | |||
28 | /** |
||
29 | * Notes stored inside the conversation |
||
30 | * |
||
31 | * @var mixed |
||
32 | */ |
||
33 | protected $protected_notes; |
||
34 | |||
35 | /** |
||
36 | * Notes to be stored |
||
37 | * |
||
38 | * @var mixed |
||
39 | */ |
||
40 | public $notes; |
||
41 | |||
42 | /** |
||
43 | * Telegram user id |
||
44 | * |
||
45 | * @var int |
||
46 | */ |
||
47 | protected $user_id; |
||
48 | |||
49 | /** |
||
50 | * Telegram chat id |
||
51 | * |
||
52 | * @var int |
||
53 | */ |
||
54 | protected $chat_id; |
||
55 | |||
56 | /** |
||
57 | * Command to be executed if the conversation is active |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $command; |
||
62 | |||
63 | /** |
||
64 | * Conversation contructor to initialize a new conversation |
||
65 | * |
||
66 | * @param int $user_id |
||
67 | * @param int $chat_id |
||
68 | * @param string $command |
||
69 | * |
||
70 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
71 | */ |
||
72 | 9 | public function __construct($user_id, $chat_id, $command = null) |
|
84 | |||
85 | /** |
||
86 | * Clear all conversation variables. |
||
87 | * |
||
88 | * @return bool Always return true, to allow this method in an if statement. |
||
89 | */ |
||
90 | 2 | protected function clear() |
|
98 | |||
99 | /** |
||
100 | * Load the conversation from the database |
||
101 | * |
||
102 | * @return bool |
||
103 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
104 | */ |
||
105 | 9 | protected function load() |
|
128 | |||
129 | /** |
||
130 | * Check if the conversation already exists |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | 9 | public function exists() |
|
138 | |||
139 | /** |
||
140 | * Start a new conversation if the current command doesn't have one yet |
||
141 | * |
||
142 | * @return bool |
||
143 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
144 | */ |
||
145 | 6 | protected function start() |
|
160 | |||
161 | /** |
||
162 | * Delete the current conversation |
||
163 | * |
||
164 | * Currently the Conversation is not deleted but just set to 'stopped' |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | 1 | public function stop() |
|
172 | |||
173 | /** |
||
174 | * Cancel the current conversation |
||
175 | * |
||
176 | * @return bool |
||
177 | */ |
||
178 | 1 | public function cancel() |
|
182 | |||
183 | /** |
||
184 | * Update the status of the current conversation |
||
185 | * |
||
186 | * @param string $status |
||
187 | * |
||
188 | * @return bool |
||
189 | */ |
||
190 | 2 | protected function updateStatus($status) |
|
207 | |||
208 | /** |
||
209 | * Store the array/variable in the database with json_encode() function |
||
210 | * |
||
211 | * @return bool |
||
212 | */ |
||
213 | 1 | public function update() |
|
226 | |||
227 | /** |
||
228 | * Retrieve the command to execute from the conversation |
||
229 | * |
||
230 | * @return string|null |
||
231 | */ |
||
232 | 3 | public function getCommand() |
|
236 | } |
||
237 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: