1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BestIt\KitchensinkBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
7
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
8
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Configuration for the bundle. |
12
|
|
|
* |
13
|
|
|
* @author blange <[email protected]> |
14
|
|
|
* @package BestIt\KitchensinkBundle |
15
|
|
|
*/ |
16
|
|
|
class Configuration implements ConfigurationInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Generates the configuration tree builder. |
20
|
|
|
* @return TreeBuilder The tree builder |
21
|
|
|
*/ |
22
|
2 |
|
public function getConfigTreeBuilder() |
23
|
|
|
{ |
24
|
2 |
|
$builder = new TreeBuilder('best_it_kitchensink'); |
|
|
|
|
25
|
|
|
|
26
|
2 |
|
$rootNode = $this->getRootNode($builder, 'best_it_kitchensink'); |
27
|
|
|
$rootNode |
28
|
2 |
|
->children() |
29
|
2 |
|
->scalarNode('template') |
30
|
2 |
|
->info('Which template should be used the render the kitchensink?') |
31
|
2 |
|
->defaultValue('kitchensink/index.html.twig') |
32
|
2 |
|
->end() |
33
|
2 |
|
->scalarNode('data_provider') |
34
|
2 |
|
->info('The data provider service implementing the matching interface.') |
35
|
2 |
|
->isRequired() |
36
|
2 |
|
->cannotBeEmpty() |
37
|
2 |
|
->end() |
38
|
2 |
|
->scalarNode('template_engine') |
39
|
2 |
|
->info('The template engine service id.') |
40
|
2 |
|
->defaultValue('twig') |
41
|
2 |
|
->cannotBeEmpty() |
42
|
2 |
|
->end() |
43
|
2 |
|
->end(); |
44
|
|
|
|
45
|
2 |
|
return $builder; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* BC layer for symfony/config 4.1 and older |
50
|
|
|
* |
51
|
|
|
* @param TreeBuilder $treeBuilder |
52
|
|
|
* @param $name |
53
|
|
|
* |
54
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
55
|
|
|
*/ |
56
|
2 |
|
private function getRootNode(TreeBuilder $treeBuilder, $name) |
57
|
|
|
{ |
58
|
2 |
|
if (!method_exists($treeBuilder, 'getRootNode')) { |
59
|
2 |
|
return $treeBuilder->root($name); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $treeBuilder->getRootNode(); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
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.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.