Skip to content

Commit 9ed74e6

Browse files
Jean85cleptric
andauthored
Drop kernel.build_dir param below Symfony 5.2 (#711)
Co-authored-by: Michi Hoffmann <[email protected]>
1 parent e0c8f9e commit 9ed74e6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/DependencyInjection/Configuration.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1616
use Symfony\Component\Config\Definition\ConfigurationInterface;
1717
use Symfony\Component\HttpClient\HttpClient;
18+
use Symfony\Component\HttpKernel\Kernel;
1819
use Symfony\Component\Messenger\MessageBusInterface;
1920

2021
final class Configuration implements ConfigurationInterface
@@ -31,6 +32,15 @@ public function getConfigTreeBuilder(): TreeBuilder
3132
? $treeBuilder->getRootNode()
3233
: $treeBuilder->root('sentry');
3334

35+
$inAppExcludes = [
36+
'%kernel.cache_dir%',
37+
'%kernel.project_dir%/vendor',
38+
];
39+
40+
if (Kernel::VERSION_ID >= 50200) {
41+
$inAppExcludes[] = '%kernel.build_dir%';
42+
}
43+
3444
$rootNode
3545
->children()
3646
->scalarNode('dsn')
@@ -116,11 +126,7 @@ public function getConfigTreeBuilder(): TreeBuilder
116126
->arrayNode('in_app_exclude')
117127
->scalarPrototype()->end()
118128
->beforeNormalization()->castToArray()->end()
119-
->defaultValue([
120-
'%kernel.cache_dir%',
121-
'%kernel.build_dir%',
122-
'%kernel.project_dir%/vendor',
123-
])
129+
->defaultValue($inAppExcludes)
124130
->end()
125131
->arrayNode('in_app_include')
126132
->scalarPrototype()->end()

tests/DependencyInjection/ConfigurationTest.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1414
use Symfony\Component\Config\Definition\Processor;
1515
use Symfony\Component\HttpClient\HttpClient;
16+
use Symfony\Component\HttpKernel\Kernel;
1617
use Symfony\Component\Messenger\MessageBusInterface;
1718

1819
final class ConfigurationTest extends TestCase
@@ -33,8 +34,8 @@ public function testProcessConfigurationWithDefaultConfiguration(): void
3334
'tags' => [],
3435
'in_app_exclude' => [
3536
'%kernel.cache_dir%',
36-
'%kernel.build_dir%',
3737
'%kernel.project_dir%/vendor',
38+
'%kernel.build_dir%',
3839
],
3940
'in_app_include' => [],
4041
'class_serializers' => [],
@@ -64,6 +65,11 @@ public function testProcessConfigurationWithDefaultConfiguration(): void
6465
],
6566
];
6667

68+
if (Kernel::VERSION_ID < 50200) {
69+
array_pop($expectedBundleDefaultConfig['options']['in_app_exclude']);
70+
$this->assertNotContains('%kernel.build_dir%', $expectedBundleDefaultConfig['options']['in_app_exclude'], 'Precondition failed, wrong default removed');
71+
}
72+
6773
$this->assertSame($expectedBundleDefaultConfig, $this->processConfiguration([]));
6874
}
6975

0 commit comments

Comments
 (0)