@@ -391,14 +391,15 @@ public function getLastCommandResponse(): ServerResponse
391
391
/**
392
392
* Handle getUpdates method
393
393
*
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
397
398
*
398
399
* @return ServerResponse
399
400
* @throws TelegramException
400
401
*/
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
402
403
{
403
404
if (empty ($ this ->bot_username )) {
404
405
throw new TelegramException ('Bot Username is not defined! ' );
@@ -414,13 +415,31 @@ public function handleGetUpdates(?int $limit = null, ?int $timeout = null, ?arra
414
415
);
415
416
}
416
417
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
+
417
437
// By default, allow ALL known update types.
418
438
if ($ allowed_updates === null ) {
419
439
$ allowed_updates = Update::getUpdateTypes ();
420
440
}
421
- $ offset = 0 ;
422
441
423
- //Take custom input into account.
442
+ // Take custom input into account.
424
443
if ($ custom_input = $ this ->getCustomInput ()) {
425
444
try {
426
445
$ input = json_decode ($ this ->input , true , 512 , JSON_THROW_ON_ERROR );
0 commit comments