Bug
The documentation says:
If second closure will return true (or if you are passed null instead of closure), first one will be executed.
|
/** |
|
* Use this method to add an event. |
|
* If second closure will return true (or if you are passed null instead of closure), first one will be executed. |
|
* |
|
* @param \Closure $event |
|
* @param \Closure|null $checker |
|
* |
|
* @return \TelegramBot\Api\Client |
|
*/ |
|
public function on(Closure $event, ?Closure $checker = null) |
|
{ |
|
$this->events->add($event, $checker); |
|
|
|
return $this; |
|
} |
I passed null as the second parameter.
$bot = new \TelegramBot\Api\Client("token");
$bot->on(function($update) {
// expected to be executed, but it's not
var_dump(1);
});
$offset = 0;
while (true) {
$updates = $bot->getUpdates($offset);
$bot->handle($updates);
if (count($updates) > 0) {
$offset = end($updates)->getUpdateId() + 1;
}
sleep(5);
}
The $event is never executed.
Expected
The $event expected to be executed when the second parameter is null or absent.
Bug
The documentation says:
I passed
nullas the second parameter.The
$eventis never executed.Expected
The
$eventexpected to be executed when the second parameter isnullor absent.