Skip to content

Commit 9542eec

Browse files
committed
Symfony 8 Support
1 parent 7a06457 commit 9542eec

23 files changed

+86
-44
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- "8.2"
1919
- "8.3"
2020
- "8.4"
21+
- "8.5"
2122
deps:
2223
- latest
2324
- lowest

.php-cs-fixer.dist.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
'yoda_style' => false,
5555
'declare_strict_types' => false,
5656
'void_return' => false,
57-
'phpdoc_align' => [],
57+
'phpdoc_align' => [
58+
'align' => 'left',
59+
],
5860
'phpdoc_to_comment' => false,
5961
'single_line_comment_spacing' => false,
6062
'nullable_type_declaration_for_default_null_value' => true,

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
CHANGELOG
22
=========
33

4+
6.0.2 (YYYY-DD-MM)
5+
------------------
6+
7+
* Add Symfony 8 support
8+
* Add php 8.5 support
9+
10+
6.0.1 (2025-07-10)
11+
------------------
12+
13+
* Add php 8.4 support
14+
415
6.0.0 (2024-09-27)
516
------------------
617

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@
2727
"php": "^8.0",
2828
"ext-curl": "*",
2929
"ext-json": "*",
30-
"symfony/console": "^5.4 || ^6.0 || ^7.0",
31-
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
32-
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
30+
"symfony/console": "^5.4 || ^6.0 || ^7.0 || ^8.0",
31+
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0 || ^8.0",
32+
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0",
3333
"telegram-bot/api": "^2.3.14"
3434
},
3535
"require-dev": {
36-
"friendsofphp/php-cs-fixer": "~3.23.0",
37-
"symfony/phpunit-bridge": "^7.0.1",
38-
"symfony/security-http": "^5.4 || ^6.0 || ^7.0",
39-
"symfony/http-client": "^5.4 || ^6.0 || ^7.0",
40-
"symfony/messenger": "^5.4 || ^6.0 || ^7.0",
41-
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
42-
"vimeo/psalm": "~4.30.0",
43-
"psalm/plugin-symfony": "^4.0"
36+
"friendsofphp/php-cs-fixer": "~3.92.0",
37+
"symfony/phpunit-bridge": "^8.0.0",
38+
"symfony/security-http": "^5.4 || ^6.0 || ^7.0 || ^8.0",
39+
"symfony/http-client": "^5.4 || ^6.0 || ^7.0 || ^8.0",
40+
"symfony/messenger": "^5.4 || ^6.0 || ^7.0 || ^8.0",
41+
"symfony/yaml": "^5.4 || ^6.0 || ^7.0 || ^8.0",
42+
"vimeo/psalm": "~6.14.2",
43+
"psalm/plugin-symfony": "^5.2.7"
4444
},
4545
"suggest": {
4646
"symfony/security-guard": "Required to implement user authentication through Telegram",

psalm.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
</ignoreFiles>
1414
</projectFiles>
1515
<issueHandlers>
16-
<!-- Workaround for https://github.com/vimeo/psalm/issues/7026 -->
17-
<ReservedWord>
18-
<errorLevel type="suppress">
19-
<directory name="src"/>
20-
<directory name="tests"/>
21-
</errorLevel>
22-
</ReservedWord>
16+
<UnusedClass errorLevel="suppress" />
17+
<PossiblyUnusedMethod errorLevel="suppress" />
2318
</issueHandlers>
19+
2420
<plugins>
2521
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
2622
</plugins>

src/Authenticator/TelegramAuthenticator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ public function __construct(
3939
) {
4040
}
4141

42+
#[\Override]
4243
public function supports(Request $request): ?bool
4344
{
4445
$route = $request->attributes->get('_route');
4546

4647
return $route === $this->guardRoute;
4748
}
4849

50+
#[\Override]
4951
public function authenticate(Request $request): Passport
5052
{
5153
$credentials = $request->query->all();
@@ -66,6 +68,7 @@ public function authenticate(Request $request): Passport
6668
}));
6769
}
6870

71+
#[\Override]
6972
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
7073
{
7174
if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
@@ -75,6 +78,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
7578
return new RedirectResponse($this->urlGenerator->generate($this->defaultTargetRoute));
7679
}
7780

81+
#[\Override]
7882
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
7983
{
8084
if ($this->loginRoute) {

src/BoShurikTelegramBotBundle.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@
1919

2020
final class BoShurikTelegramBotBundle extends Bundle
2121
{
22+
#[\Override]
2223
public function build(ContainerBuilder $container): void
2324
{
2425
parent::build($container);
2526

2627
$container->addCompilerPass(new CommandCompilerPass());
2728
}
2829

30+
#[\Override]
2931
public function getContainerExtension(): ?ExtensionInterface
3032
{
3133
if (null === $this->extension) {
3234
$this->extension = new BoShurikTelegramBotExtension();
3335
}
3436

35-
return $this->extension;
37+
return $this->extension ?: null;
3638
}
3739
}

src/Command/UpdatesCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(private Telegram $telegram)
2424
parent::__construct();
2525
}
2626

27+
#[\Override]
2728
protected function configure(): void
2829
{
2930
$this
@@ -33,9 +34,9 @@ protected function configure(): void
3334
;
3435
}
3536

37+
#[\Override]
3638
protected function execute(InputInterface $input, OutputInterface $output): int
3739
{
38-
/** @var string|null $bot */
3940
$bot = $input->getArgument('bot');
4041
if ($bot) {
4142
$this->telegram->processUpdates($bot);

src/Command/Webhook/InfoCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(private BotLocator $botLocator)
2626
parent::__construct();
2727
}
2828

29+
#[\Override]
2930
protected function configure(): void
3031
{
3132
$this
@@ -35,11 +36,11 @@ protected function configure(): void
3536
;
3637
}
3738

39+
#[\Override]
3840
protected function execute(InputInterface $input, OutputInterface $output): int
3941
{
4042
$io = new SymfonyStyle($input, $output);
4143

42-
/** @var string|null $bot */
4344
$bot = $input->getArgument('bot');
4445
if ($bot) {
4546
$api = $this->botLocator->get($bot);
@@ -56,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5657

5758
private function printWebhookInfo(SymfonyStyle $io, string $name, BotApi $api): void
5859
{
59-
$io->block(sprintf('Bot "%s"', $name));
60+
$io->block(\sprintf('Bot "%s"', $name));
6061

6162
$info = $api->getWebhookInfo();
6263

src/Command/Webhook/SetCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(private BotLocator $botLocator, private UrlGenerator
3434
parent::__construct();
3535
}
3636

37+
#[\Override]
3738
protected function configure(): void
3839
{
3940
$this
@@ -51,22 +52,21 @@ protected function configure(): void
5152
;
5253
}
5354

55+
#[\Override]
5456
protected function execute(InputInterface $input, OutputInterface $output): int
5557
{
5658
$io = new SymfonyStyle($input, $output);
5759

5860
$certificateFile = null;
5961
if ($certificate = $input->getArgument('certificate')) {
6062
if (!is_file($certificate) || !is_readable($certificate)) {
61-
throw new \RuntimeException(sprintf('Can\'t read certificate file "%s"', $certificate));
63+
throw new \RuntimeException(\sprintf('Can\'t read certificate file "%s"', $certificate));
6264
}
6365

6466
$certificateFile = new \CURLFile($certificate);
6567
}
6668

67-
/** @var string|null $urlOrHostname */
6869
$urlOrHostname = $input->getArgument('urlOrHostname');
69-
/** @var string|null $bot */
7070
$bot = $input->getOption('bot');
7171

7272
$allowedUpdates = $input->getOption('allowedUpdateType');
@@ -108,7 +108,7 @@ private function setWebhook(
108108
?\CURLFile $certificateFile = null,
109109
?array $allowedUpdates = null
110110
): bool {
111-
$io->block(sprintf('Bot "%s"', $name));
111+
$io->block(\sprintf('Bot "%s"', $name));
112112

113113
if (!$urlOrHostname) {
114114
$url = $this->urlGenerator->generate('_telegram_bot_webhook', [
@@ -127,17 +127,17 @@ private function setWebhook(
127127
} catch (RouteNotFoundException $e) {
128128
$helpUrl = 'https://github.com/BoShurik/TelegramBotBundle#add-routing-for-webhook';
129129
$message = "We could not find the webhook route. Read on\n<options=bold>%s</>\nhow to add the route or use symfony/flex.";
130-
$io->block(messages: sprintf($message, $helpUrl), escape: false);
130+
$io->block(messages: \sprintf($message, $helpUrl), escape: false);
131131

132132
return false;
133133
}
134134
} else {
135135
$url = $urlOrHostname;
136136
}
137137

138-
$api->setWebhook($url, $certificateFile, null, self::MAX_CONNECTIONS, json_encode($allowedUpdates));
138+
$api->setWebhook($url, $certificateFile, null, self::MAX_CONNECTIONS, (string) json_encode($allowedUpdates));
139139

140-
$message = sprintf('Webhook URL has been set to <options=bold>%s</>', $url);
140+
$message = \sprintf('Webhook URL has been set to <options=bold>%s</>', $url);
141141
$io->block($message, 'OK', 'fg=black;bg=green', ' ', true, false);
142142

143143
return true;

0 commit comments

Comments
 (0)