fractalzombie /
frzb-metrics-power
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | /** |
||||
| 6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
| 7 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
| 8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
| 9 | * |
||||
| 10 | * Copyright (c) 2024 Mykhailo Shtanko [email protected] |
||||
| 11 | * |
||||
| 12 | * For the full copyright and license information, please view the LICENSE.MD |
||||
| 13 | * file that was distributed with this source code. |
||||
| 14 | */ |
||||
| 15 | |||||
| 16 | namespace FRZB\Component\MetricsPower\OptionsResolver\Resolver; |
||||
| 17 | |||||
| 18 | use FRZB\Component\DependencyInjection\Attribute\AsService; |
||||
| 19 | use FRZB\Component\DependencyInjection\Attribute\AsTagged; |
||||
| 20 | use FRZB\Component\MetricsPower\Attribute\SentryOptions; |
||||
|
0 ignored issues
–
show
|
|||||
| 21 | use Sentry\State\HubInterface; |
||||
| 22 | use Symfony\Component\Messenger\Event\AbstractWorkerMessageEvent; |
||||
| 23 | use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent; |
||||
| 24 | use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent; |
||||
| 25 | use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent; |
||||
| 26 | |||||
| 27 | #[AsService, AsTagged(OptionsResolverInterface::class)] |
||||
| 28 | class SentryOptionsResolver implements OptionsResolverInterface |
||||
| 29 | { |
||||
| 30 | public function __construct( |
||||
| 31 | private readonly HubInterface $hub |
||||
| 32 | ) {} |
||||
| 33 | |||||
| 34 | public function resolve(AbstractWorkerMessageEvent|SendMessageToTransportsEvent $event, SentryOptions $options): void |
||||
| 35 | { |
||||
| 36 | match ($event::class) { |
||||
| 37 | WorkerMessageFailedEvent::class => $this->onWorkerMessageFailedEvent($event, $options), |
||||
|
0 ignored issues
–
show
It seems like
$event can also be of type Symfony\Component\Messen...essageToTransportsEvent; however, parameter $event of FRZB\Component\MetricsPo...kerMessageFailedEvent() does only seem to accept Symfony\Component\Messen...orkerMessageFailedEvent, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
Are you sure the usage of
$this->onWorkerMessageFa...Event($event, $options) targeting FRZB\Component\MetricsPo...kerMessageFailedEvent() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||||
| 38 | WorkerMessageHandledEvent::class => $this->onWorkerMessageHandledEvent($event, $options), |
||||
|
0 ignored issues
–
show
It seems like
$event can also be of type Symfony\Component\Messen...essageToTransportsEvent; however, parameter $event of FRZB\Component\MetricsPo...erMessageHandledEvent() does only seem to accept Symfony\Component\Messen...rkerMessageHandledEvent, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
Are you sure the usage of
$this->onWorkerMessageHa...Event($event, $options) targeting FRZB\Component\MetricsPo...erMessageHandledEvent() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||||
| 39 | default => null, |
||||
| 40 | }; |
||||
| 41 | } |
||||
| 42 | |||||
| 43 | public static function getType(): string |
||||
| 44 | { |
||||
| 45 | return SentryOptions::class; |
||||
| 46 | } |
||||
| 47 | |||||
| 48 | private function onWorkerMessageFailedEvent(WorkerMessageFailedEvent $event, SentryOptions $options): void |
||||
| 49 | { |
||||
| 50 | if ($event->willRetry() && $options->waitRetry) { |
||||
| 51 | return; |
||||
| 52 | } |
||||
| 53 | |||||
| 54 | $this->hub->captureException($event->getThrowable()); |
||||
| 55 | } |
||||
| 56 | |||||
| 57 | private function onWorkerMessageHandledEvent(WorkerMessageHandledEvent $event, SentryOptions $options): void |
||||
|
0 ignored issues
–
show
The parameter
$event is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 58 | { |
||||
| 59 | $options->onHandleFlush && $this->hub->getClient()?->flush(); |
||||
| 60 | } |
||||
| 61 | } |
||||
| 62 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths