Skip to content

Commit 375d41f

Browse files
committed
Fixed psalm issues
1 parent 3ddc5ca commit 375d41f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Issues/GitHub/CachedLabelsApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CachedLabelsApi
1616
private $labelsApi;
1717

1818
/**
19-
* @var string[][]
19+
* @var array<array-key, array<array-key, bool>>
2020
*/
2121
private $labelCache = [];
2222

src/Issues/GitHubRequestHandler.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Psr\Log\LoggerInterface;
88
use Symfony\Component\DependencyInjection\ContainerInterface;
99
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
10+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1011
use Symfony\Component\HttpFoundation\Request;
1112
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1213
use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException;
@@ -39,7 +40,7 @@ public function __construct(EventDispatcherInterface $dispatcher, RepositoryProv
3940
*/
4041
public function handle(Request $request)
4142
{
42-
$data = json_decode($request->getContent(), true);
43+
$data = json_decode((string) $request->getContent(), true);
4344
if (null === $data) {
4445
throw new BadRequestHttpException('Invalid JSON body!');
4546
}
@@ -67,7 +68,12 @@ public function handle(Request $request)
6768
}
6869

6970
foreach ($repository->getSubscribers() as $subscriberId) {
70-
$this->dispatcher->addSubscriber($this->container->get($subscriberId));
71+
$subscriber = $this->container->get($subscriberId);
72+
if (!$subscriber instanceof EventSubscriberInterface) {
73+
throw new \LogicException(sprintf('Service "%s" is not an instance of "%s"', $subscriberId, EventSubscriberInterface::class));
74+
}
75+
76+
$this->dispatcher->addSubscriber($subscriber);
7177
}
7278

7379
$event = new GitHubEvent($data, $repository);
@@ -76,7 +82,7 @@ public function handle(Request $request)
7682
try {
7783
$this->dispatcher->dispatch($event, 'github.'.$eventName);
7884
} catch (\Exception $e) {
79-
throw new \RuntimeException(sprintf('Failed dispatching "%s" event for "%s" repository.', $eventName, $repository->getFullName()), 0, $e);
85+
throw new \RuntimeException(sprintf('Failed dispatching "%s" event for "%s" repository.', (string) $eventName, $repository->getFullName()), 0, $e);
8086
}
8187

8288
$responseData = $event->getResponseData();

src/Repository/Provider/RepositoryProviderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface RepositoryProviderInterface
1212
/**
1313
* @param string $repositoryName e.g. symfony/symfony-docs
1414
*
15-
* @return Repository
15+
* @return Repository|null
1616
*/
1717
public function getRepository($repositoryName);
1818

0 commit comments

Comments
 (0)