Skip to content

Commit f6e757a

Browse files
committed
bug #93 Fixed psalm issues (Nyholm)
This PR was merged into the master branch. Discussion ---------- Fixed psalm issues Commits ------- 375d41f Fixed psalm issues
2 parents 112b91a + 375d41f commit f6e757a

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;
@@ -37,7 +38,7 @@ public function __construct(EventDispatcherInterface $dispatcher, RepositoryProv
3738
*/
3839
public function handle(Request $request)
3940
{
40-
$data = json_decode($request->getContent(), true);
41+
$data = json_decode((string) $request->getContent(), true);
4142
if (null === $data) {
4243
throw new BadRequestHttpException('Invalid JSON body!');
4344
}
@@ -65,7 +66,12 @@ public function handle(Request $request)
6566
}
6667

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

7177
$event = new GitHubEvent($data, $repository);
@@ -74,7 +80,7 @@ public function handle(Request $request)
7480
try {
7581
$this->dispatcher->dispatch($event, 'github.'.$eventName);
7682
} catch (\Exception $e) {
77-
throw new \RuntimeException(sprintf('Failed dispatching "%s" event for "%s" repository.', $eventName, $repository->getFullName()), 0, $e);
83+
throw new \RuntimeException(sprintf('Failed dispatching "%s" event for "%s" repository.', (string) $eventName, $repository->getFullName()), 0, $e);
7884
}
7985

8086
$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)