Passed
Push — master ( efda04...cab2bf )
by Ivan
02:55
created

src/DependencyInjection/Configuration.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\AjaxcomBundle\DependencyInjection;
6
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
/**
11
 * Class Configuration.
12
 *
13
 * @author Ivan Barlog <[email protected]>
14
 */
15
class Configuration implements ConfigurationInterface
16
{
17
    const FLASH_TEMPLATE = 'flash_template';
18
    const FLASH_BLOCK_ID = 'flash_block_id';
19
    const PERSISTENT_CLASS = 'persistent_class';
20
    const BLOCKS_TO_RENDER = 'blocks_to_render';
21
    const ID = 'id';
22
    const REFRESH = 'refresh';
23
24
    public function getConfigTreeBuilder()
25
    {
26
        $treeBuilder = new TreeBuilder('everlution_ajaxcom');
0 ignored issues
show
The call to Symfony\Component\Config...eBuilder::__construct() has too many arguments starting with 'everlution_ajaxcom'. ( Ignorable by Annotation )

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

26
        $treeBuilder = /** @scrutinizer ignore-call */ new TreeBuilder('everlution_ajaxcom');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
27
28
        if (method_exists($treeBuilder, 'getRootNode')) {
29
            $rootNode = $treeBuilder->getRootNode();
30
        } else {
31
            // for symfony/config 4.1 and older
32
            $rootNode = $treeBuilder->root('everlution_ajaxcom');
33
        }
34
35
        $rootNode
36
            ->children()
37
                ->scalarNode(self::FLASH_TEMPLATE)->defaultValue('@EverlutionAjaxcom/flash_message.html.twig')->end()
38
                ->scalarNode(self::FLASH_BLOCK_ID)->defaultValue('flash_message')->end()
39
                ->scalarNode(self::PERSISTENT_CLASS)->defaultValue('ajaxcom-persistent')->end()
40
                ->arrayNode(self::BLOCKS_TO_RENDER)
41
                    ->arrayPrototype()
42
                        ->children()
43
                            ->scalarNode(self::ID)->end()
44
                            ->scalarNode(self::REFRESH)->defaultFalse()->end()
45
                        ->end()
46
                    ->end()
47
                ->end()
48
            ->end();
49
50
        return $treeBuilder;
51
    }
52
}
53