Skip to content

Commit b77ca25

Browse files
committed
Update SF
1 parent e1f5bc4 commit b77ca25

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<projectFiles>
1818
<directory name="src"/>
1919
<ignoreFiles>
20-
<directory name="src/Symfony/DependencyInjection"/>
2120
</ignoreFiles>
2221
</projectFiles>
2322

src/Symfony/DependencyInjection/Compiler/ExceptionContextPass.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
declare(strict_types=1);
23

34
namespace Gotphoto\Logging\Symfony\DependencyInjection\Compiler;
45

5-
use Gotphoto\Logging\Formatter;
6+
use Gotphoto\Logging\LogstashFormatter;
67
use Gotphoto\Logging\OtelFormatter;
78
use ReflectionClass;
89
use 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
}

src/Symfony/DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
class Configuration implements ConfigurationInterface
1010
{
11-
public function getConfigTreeBuilder()
11+
public function getConfigTreeBuilder(): TreeBuilder
1212
{
1313
$treeBuilder = new TreeBuilder('symfony_logging');
1414

1515
$rootNode = $treeBuilder->getRootNode();
16+
/** @psalm-suppress MixedMethodCall, UndefinedMethod */
1617
$rootNode
1718
->children()
1819
->scalarNode('app_name')

src/Symfony/DependencyInjection/SymfonyLoggingExtension.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Gotphoto\Logging\Symfony\DependencyInjection;
66

77
use Gotphoto\Logging\ExceptionContext\ExceptionContext;
8-
use Gotphoto\Logging\Formatter;
8+
use Gotphoto\Logging\LogstashFormatter;
99
use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
1010
use Symfony\Component\Config\FileLocator;
1111
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -21,18 +21,21 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
2121
{
2222
$loader = new PhpFileLoader(
2323
$container,
24-
new FileLocator(__DIR__.'/../config')
24+
new FileLocator(__DIR__ . '/../config'),
2525
);
2626
$loader->load('services.php');
2727
$env = $container->getParameter('kernel.environment');
2828
try {
29+
/** @psalm-suppress PossiblyInvalidCast */
2930
$loader->load("services_{$env}.php");
3031
} catch (FileLocatorFileNotFoundException $e) {
3132
//ignore if no file for env
3233
}
3334

34-
$container->getDefinition(Formatter::class)
35-
->setArgument('$applicationName', $configs['app_name'])
35+
/** @psalm-suppress PossiblyUndefinedStringArrayOffset */
36+
$container
37+
->getDefinition(LogstashFormatter::class)
38+
->setArgument('$applicationName', $mergedConfig['app_name'])
3639
->setArgument('$environment', $env);
3740

3841
$container

0 commit comments

Comments
 (0)