Issues (32)

Listener/ExceptionListener.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Ekino New Relic bundle.
7
 *
8
 * (c) Ekino - Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\NewRelicBundle\Listener;
15
16
use Ekino\NewRelicBundle\NewRelic\NewRelicInteractorInterface;
17
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
18
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
19
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
0 ignored issues
show
The type Symfony\Component\HttpKe...sponseForExceptionEvent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
21
use Symfony\Component\HttpKernel\KernelEvents;
22
23
/**
24
 * Listen to exceptions dispatched by Symfony to log them to NewRelic.
25
 */
26
class ExceptionListener implements EventSubscriberInterface
27
{
28
    private $interactor;
29
30
    public function __construct(NewRelicInteractorInterface $interactor)
31
    {
32
        $this->interactor = $interactor;
33
    }
34
35
    public static function getSubscribedEvents(): array
36
    {
37
        return [
38
            KernelEvents::EXCEPTION => ['onKernelException', 0],
39
        ];
40
    }
41
42
    /**
43
     * @param GetResponseForExceptionEvent|ExceptionEvent $event
44
     */
45
    public function onKernelException(KernelExceptionEvent $event): void
0 ignored issues
show
The type Ekino\NewRelicBundle\Listener\KernelExceptionEvent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
    {
47
        $exception = \method_exists($event, 'getThrowable') ? $event->getThrowable() : $event->getException();
48
        if (!$exception instanceof HttpExceptionInterface) {
49
            $this->interactor->noticeThrowable($exception);
50
        }
51
    }
52
}
53
54
if (!\class_exists(KernelExceptionEvent::class)) {
55
    if (\class_exists(ExceptionEvent::class)) {
56
        \class_alias(ExceptionEvent::class, KernelExceptionEvent::class);
57
    } else {
58
        \class_alias(GetResponseForExceptionEvent::class, KernelExceptionEvent::class);
59
    }
60
}
61