@@ -391,14 +391,15 @@ public function getLastCommandResponse(): ServerResponse
391391 /**
392392 * Handle getUpdates method
393393 *
394- * @param int|null $limit
395- * @param int|null $timeout
396- * @param array|null $allowed_updates
394+ * @todo Remove backwards compatibility for old signature and force $data to be an array.
395+ *
396+ * @param array|int|null $data
397+ * @param int|null $timeout
397398 *
398399 * @return ServerResponse
399400 * @throws TelegramException
400401 */
401- public function handleGetUpdates (? int $ limit = null , ?int $ timeout = null , ? array $ allowed_updates = null ): ServerResponse
402+ public function handleGetUpdates ($ data = null , ?int $ timeout = null ): ServerResponse
402403 {
403404 if (empty ($ this ->bot_username )) {
404405 throw new TelegramException ('Bot Username is not defined! ' );
@@ -414,13 +415,31 @@ public function handleGetUpdates(?int $limit = null, ?int $timeout = null, ?arra
414415 );
415416 }
416417
418+ $ offset = 0 ;
419+ $ limit = null ;
420+ $ allowed_updates = null ;
421+
422+ // @todo Backwards compatibility for old signature, remove in next version.
423+ if (!is_array ($ data )) {
424+ $ limit = $ data ;
425+
426+ @trigger_error (
427+ sprintf ('Use of $limit and $timeout parameters in %s is deprecated. Use $data array instead. ' , __METHOD__ ),
428+ E_USER_DEPRECATED
429+ );
430+ } else {
431+ $ offset = $ data ['offset ' ] ?? $ offset ;
432+ $ limit = $ data ['limit ' ] ?? $ limit ;
433+ $ timeout = $ data ['timeout ' ] ?? $ timeout ;
434+ $ allowed_updates = $ data ['allowed_updates ' ] ?? $ allowed_updates ;
435+ }
436+
417437 // By default, allow ALL known update types.
418438 if ($ allowed_updates === null ) {
419439 $ allowed_updates = Update::getUpdateTypes ();
420440 }
421- $ offset = 0 ;
422441
423- //Take custom input into account.
442+ // Take custom input into account.
424443 if ($ custom_input = $ this ->getCustomInput ()) {
425444 try {
426445 $ input = json_decode ($ this ->input , true , 512 , JSON_THROW_ON_ERROR );
0 commit comments