diff --git a/src/TelegramBot/Command/ButtonSetCommandsCommand.php b/src/TelegramBot/Command/ButtonSetCommandsCommand.php index 5d44ad2..80da79b 100644 --- a/src/TelegramBot/Command/ButtonSetCommandsCommand.php +++ b/src/TelegramBot/Command/ButtonSetCommandsCommand.php @@ -49,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if ($commands === []) { - $io->warning('Could not find publish commands'); + $io->warning('Could not find any commands to publish'); return Command::SUCCESS; } @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::FAILURE; } - $io->success('Bot\'s menu button set'); + $io->success('Bot\'s menu button has been set'); return Command::SUCCESS; } diff --git a/src/TelegramBot/CommandMetadataProvider.php b/src/TelegramBot/CommandMetadataProvider.php index c3193a5..f681d61 100644 --- a/src/TelegramBot/CommandMetadataProvider.php +++ b/src/TelegramBot/CommandMetadataProvider.php @@ -14,19 +14,16 @@ public function __construct( } /** - * @return list + * @return \Generator */ - public function gelMetadataList(): array + public function gelMetadataList(): \Generator { - $list = []; foreach ($this->controllersMap as ['controller' => $controller]) { $command = $this->instantiateAttribute($controller); if ($command !== null) { - $list[] = $command; + yield $command; } } - - return $list; } /** diff --git a/src/TelegramBot/LongPollingService.php b/src/TelegramBot/LongPollingService.php index b29f829..170116d 100644 --- a/src/TelegramBot/LongPollingService.php +++ b/src/TelegramBot/LongPollingService.php @@ -12,6 +12,7 @@ final class LongPollingService { private const LIMIT = 50; + private int $timeout = 15; private int $offset = 0; diff --git a/tests/CommandMetadataProviderTest.php b/tests/CommandMetadataProviderTest.php index ce143b9..4277ebe 100644 --- a/tests/CommandMetadataProviderTest.php +++ b/tests/CommandMetadataProviderTest.php @@ -27,8 +27,9 @@ final class CommandMetadataProviderTest extends KernelTestCase { public function testCommandsMetadata(): void { + /** @var CommandMetadataProvider $commandMetadataProvider */ $commandMetadataProvider = self::getContainer()->get('telegram_bot.command_metadata_provider'); - $list = $commandMetadataProvider->gelMetadataList(); + $list = iterator_to_array($commandMetadataProvider->gelMetadataList()); $this->assertCount(4, $list); $this->assertObjectInArray(new OnCommand('/start', '', false, 0), $list); @@ -37,8 +38,8 @@ public function testCommandsMetadata(): void $this->assertObjectInArray(new OnCommand('/test3', 'test3 command description', false, 0), $list); } - private function assertObjectInArray(object $obj, array $arra): void + private function assertObjectInArray(object $obj, array $array): void { - $this->assertContains(json_encode($obj), array_map(fn ($a) => json_encode($a), $arra)); + $this->assertContains(json_encode($obj), array_map(fn ($a) => json_encode($a), $array)); } }