Skip to content

Commit dd05197

Browse files
committed
Ugrade Psalm version
1 parent 14cd82b commit dd05197

8 files changed

Lines changed: 34 additions & 10 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"roave/infection-static-analysis-plugin": "^1.16",
2727
"symfony/console": "^6.2",
2828
"symfony/http-client": "^7.0",
29-
"vimeo/psalm": "^5.4",
29+
"vimeo/psalm": "^6.8",
3030
"yiisoft/definitions": "^3.3",
3131
"yiisoft/test-support": "^3.0"
3232
},

psalm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<directory name="vendor"/>
1515
</ignoreFiles>
1616
</projectFiles>
17+
<issueHandlers>
18+
<MissingOverrideAttribute errorLevel="suppress" />
19+
</issueHandlers>
1720
</psalm>

src/Console/GetUpdatesCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Botasis\Client\Telegram\Client\ClientInterface;
88
use Botasis\Client\Telegram\Request\TelegramRequest;
99
use Botasis\Runtime\Application;
10+
use Botasis\Runtime\Update\Update;
1011
use Botasis\Runtime\Update\UpdateFactory;
1112
use Psr\Log\LoggerInterface;
1213
use Psr\Log\NullLogger;
@@ -48,6 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4849
$data = ['allowed_updates' => $input->getOption('allowed-updates')];
4950
$request = new TelegramRequest('getUpdates', $data);
5051

52+
/** @var array $update */
5153
foreach ($this->client->send($request)['result'] ?? [] as $update) {
5254
try {
5355
$update = $this->updateFactory->create($update);
@@ -58,6 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5860
}
5961
}
6062

63+
/** @var Update|null $update */
6164
if ($update !== null) {
6265
$data['offset'] = $update->id->value + 1;
6366
$this->client->send(new TelegramRequest('getUpdates', $data));

src/Console/SetTelegramWebhookCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ protected function configure(): void
7373

7474
public function execute(InputInterface $input, OutputInterface $output): int
7575
{
76+
/** @var string $url */
7677
$url = $input->getOption('url');
7778

7879
if ($url === '') {
80+
/** @var bool $answer */
7981
$answer = $this->questionHelper->ask(
8082
$input,
8183
$output,
@@ -108,16 +110,19 @@ public function execute(InputInterface $input, OutputInterface $output): int
108110
'drop_pending_updates' => $input->getOption('drop_pending_updates'),
109111
];
110112

113+
/** @var string|null $ip */
111114
$ip = $input->getOption('ip_address');
112115
if ($ip !== null && $ip !== '') {
113116
$fields['ip_address'] = $ip;
114117
}
115118

119+
/** @var int|null $connections */
116120
$connections = $input->getOption('max_connections');
117121
if ($connections !== null && $connections > 0) {
118122
$fields['max_connections'] = $connections;
119123
}
120124

125+
/** @var string|null $token */
121126
$token = $input->getOption('secret_token');
122127
if ($token !== null && $token !== '') {
123128
$fields['secret_token'] = $token;

src/Entity/User/UserFactory.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44

55
namespace Botasis\Runtime\Entity\User;
66

7+
/**
8+
* Factory for creating User objects from Telegram API data.
9+
*/
710
final readonly class UserFactory
811
{
912
public function __construct()
1013
{
1114
}
1215

16+
/**
17+
* Converts array, received from Telegram API, into User object
18+
*/
1319
public function create(array $userData): User
1420
{
21+
/**
22+
* @psalm-suppress MixedArgument
23+
*/
1524
return new User(
1625
(string)$userData['id'],
1726
(bool) $userData['is_bot'],

src/Event/IgnoredErrorHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public function __construct(string ...$ignoredErrors)
2525

2626
public function handle(RequestErrorEvent $event): RequestErrorEvent
2727
{
28-
if (isset($this->ignoredErrors[$event->exception->responseDecoded['description'] ?? ''])) {
28+
/** @var string $description */
29+
$description = $event->exception->responseDecoded['description'] ?? '';
30+
31+
if (isset($this->ignoredErrors[$description])) {
2932
$event->suppressException = true;
3033
}
3134

src/Event/RequestTagsHandler.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,29 @@ final class RequestTagsHandler
2020
private array $tagsError;
2121

2222
/**
23-
* @param array<string, list<mixed>> $tagsSuccess
24-
* @param array<string, list<mixed>> $tagsError
23+
* @param array<string, list<string|array>> $tagsSuccess
24+
* @param array<string, list<string|array>> $tagsError
2525
*/
2626
public function __construct(
2727
CallableFactory $factory,
2828
private Injector $injector,
2929
array $tagsSuccess = [],
3030
array $tagsError = [],
3131
) {
32+
$listenersSuccess = $listenersError = [];
3233
foreach ($tagsSuccess as $tag => $definitions) {
3334
foreach ($definitions as $index => $definition) {
34-
$tagsSuccess[$tag][$index] = $factory->create($definition);
35+
$listenersSuccess[$tag][$index] = $factory->create($definition);
3536
}
3637
}
3738
foreach ($tagsError as $tag => $definitions) {
3839
foreach ($definitions as $index => $definition) {
39-
$tagsError[$tag][$index] = $factory->create($definition);
40+
$listenersError[$tag][$index] = $factory->create($definition);
4041
}
4142
}
4243

43-
$this->tagsSuccess = $tagsSuccess;
44-
$this->tagsError = $tagsError;
44+
$this->tagsSuccess = $listenersSuccess;
45+
$this->tagsError = $listenersError;
4546
}
4647

4748
public function handleSuccess(RequestSuccessEvent $event): void

src/InvalidCallableConfigurationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use InvalidArgumentException;
88
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
99

10-
class InvalidCallableConfigurationException extends InvalidArgumentException implements FriendlyExceptionInterface
10+
final class InvalidCallableConfigurationException extends InvalidArgumentException implements FriendlyExceptionInterface
1111
{
1212
public function getName(): string
1313
{
14-
return 'Invalid event listener configuration.';
14+
return 'Invalid callable configuration.';
1515
}
1616

1717
public function getSolution(): ?string

0 commit comments

Comments
 (0)