Issues (3)

DependencyInjection/Configuration.php (1 issue)

Severity
1
<?php
2
declare(strict_types=1);
3
4
namespace FH\Bundle\UserAgentBundle\DependencyInjection;
5
6
use FH\Bundle\UserAgentBundle\EventListener\ResponseListener;
7
use FH\Bundle\UserAgentBundle\Repository\UserAgentRepository;
8
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
9
use Symfony\Component\Config\Definition\ConfigurationInterface;
10
11
/**
12
 * @author Evert Harmeling <[email protected]>
13
 */
14
final class Configuration implements ConfigurationInterface
15
{
16
    private const ROOT_NAME = 'fh_user_agent';
17
18
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder(self::ROOT_NAME);
21
22
        if (method_exists($treeBuilder, 'getRootNode')) {
23
            $rootNode = $treeBuilder->getRootNode();
24
        } else {
25
            // BC layer for symfony/config 4.1 and older
26
            $rootNode = $treeBuilder->root(self::ROOT_NAME);
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

26
            $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root(self::ROOT_NAME);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
27
        }
28
29
        $rootNode
30
            ->children()
31
                ->scalarNode('repository')
32
                    ->defaultValue(UserAgentRepository::class)
33
                    ->cannotBeEmpty()
34
                ->end()
35
                ->arrayNode('response_listener')
36
                    ->addDefaultsIfNotSet()
37
                    ->children()
38
                        ->scalarNode('class')
39
                            ->defaultValue(ResponseListener::class)
40
                        ->end()
41
                        ->arrayNode('criteria')
42
                            ->useAttributeAsKey('name')
43
                            ->prototype('scalar')->end()
44
                        ->end()
45
                    ->end()
46
                ->end()
47
            ->end();
48
49
        return $treeBuilder;
50
    }
51
}
52