1- <?php declare (strict_types=1 );
1+ <?php
2+ declare (strict_types=1 );
23
34namespace Gotphoto \Logging \Symfony \DependencyInjection \Compiler ;
45
5- use Gotphoto \Logging \Formatter ;
6+ use Gotphoto \Logging \LogstashFormatter ;
67use Gotphoto \Logging \OtelFormatter ;
78use ReflectionClass ;
89use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
@@ -19,21 +20,35 @@ public function process(ContainerBuilder $container)
1920 foreach ($ container ->findTaggedServiceIds ('gotphoto_logging.exception_context ' ) as $ id => $ _tags ) {
2021 $ definition = $ container ->getDefinition ($ id );
2122 $ className = $ definition ->getClass ();
23+ /** @psalm-suppress ArgumentTypeCoercion, PossiblyNullArgument */
2224 $ reflectionClass = new ReflectionClass ($ className );
2325 if (!$ reflectionClass ->hasMethod ('__invoke ' )) {
26+ /** @psalm-suppress PossiblyNullOperand */
2427 throw new \Exception ($ definition ->getClass () . ' has to have __invoke method. ' );
2528 }
2629 $ reflectionMethod = $ reflectionClass ->getMethod ('__invoke ' );
27- $ typehintClassName = $ reflectionMethod ->getParameters ()[0 ]->getClass ()->getName ();
30+
31+ /** @psalm-suppress UndefinedMethod, PossiblyNullReference, PossiblyUndefinedIntArrayOffset */
32+ $ typehintClassName = $ reflectionMethod ->getParameters ()[0 ]->getType ()->getName ();
33+ /** @psalm-suppress MixedArgument */
2834 if (!is_subclass_of ($ typehintClassName , Throwable::class)) {
29- throw new \Exception ($ definition ->getClass () . ' has to have __invoke method with argument "is_subclass_of Throwable". ' );
35+ /** @psalm-suppress PossiblyNullOperand */
36+ throw new \Exception (
37+ $ definition ->getClass () . ' has to have __invoke method with argument "is_subclass_of Throwable". ' ,
38+ );
3039 }
3140
3241 $ exceptionContextMap [$ typehintClassName ][] = new Reference ($ id );
3342 }
3443
35- $ container ->getDefinition (Formatter::class)->setArgument ('$exceptionContextProviderMap ' , $ exceptionContextMap );
44+ $ container ->getDefinition (LogstashFormatter::class)->setArgument (
45+ '$exceptionContextProviderMap ' ,
46+ $ exceptionContextMap ,
47+ );
3648
37- $ container ->getDefinition (OtelFormatter::class)->setArgument ('$exceptionContextProviderMap ' , $ exceptionContextMap );
49+ $ container ->getDefinition (OtelFormatter::class)->setArgument (
50+ '$exceptionContextProviderMap ' ,
51+ $ exceptionContextMap ,
52+ );
3853 }
3954}
0 commit comments