|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the ModularBundle project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Anthonius Munthi <https://itstoni.com> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Doyo\Bundle\Modular\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
17
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
18
|
|
|
|
|
19
|
|
|
class Configuration implements ConfigurationInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @psalm-suppress TooFew |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
|
25
|
|
|
{ |
|
26
|
|
|
// @codeCoverageIgnoreStart |
|
27
|
|
|
if (method_exists(TreeBuilder::class, 'getRootNode')) { |
|
28
|
|
|
$treeBuilder = new TreeBuilder('doyo_modular_extension'); |
|
29
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
|
30
|
|
|
} else { |
|
31
|
|
|
$treeBuilder = new TreeBuilder(); |
|
|
|
|
|
|
32
|
|
|
$rootNode = $treeBuilder->root('doyo_modular_extension'); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
// @codeCoverageIgnoreEnd |
|
35
|
|
|
|
|
36
|
|
|
$rootNode |
|
37
|
|
|
->children() |
|
38
|
|
|
->booleanNode('use_annotation')->defaultTrue()->end() |
|
39
|
|
|
->scalarNode('module_root_dir')->defaultValue('src')->end() |
|
40
|
|
|
->arrayNode('doctrine') |
|
41
|
|
|
->addDefaultsIfNotSet() |
|
42
|
|
|
->children() |
|
43
|
|
|
->booleanNode('use_orm')->defaultTrue()->end() |
|
44
|
|
|
->booleanNode('use_mongodb')->defaultFalse()->end() |
|
45
|
|
|
->scalarNode('entity_dir')->defaultValue('Entity')->end() |
|
46
|
|
|
->scalarNode('document_dir')->defaultValue('Document')->end() |
|
47
|
|
|
->scalarNode('mapping_dir')->defaultValue('Resources/doctrine')->end() |
|
48
|
|
|
->end() |
|
49
|
|
|
->end() |
|
50
|
|
|
->arrayNode('config_paths') |
|
51
|
|
|
->addDefaultsIfNotSet() |
|
52
|
|
|
->children() |
|
53
|
|
|
->scalarNode('api_platform')->defaultValue('Resources/api')->end() |
|
54
|
|
|
->scalarNode('validation')->defaultValue('Resources/validation')->end() |
|
55
|
|
|
->scalarNode('serialization')->defaultValue('Resources/serialization')->end() |
|
56
|
|
|
->end() |
|
57
|
|
|
->end() |
|
58
|
|
|
->end(); |
|
59
|
|
|
|
|
60
|
|
|
return $treeBuilder; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less 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.