1 | <?php |
||||
2 | |||||
3 | /* |
||||
4 | * This file is part of the doyo/behat-code-coverage project. |
||||
5 | * |
||||
6 | * (c) Anthonius Munthi <[email protected]> |
||||
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\Behat\Coverage; |
||||
15 | |||||
16 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||||
17 | |||||
18 | class Configuration |
||||
19 | { |
||||
20 | 4 | public function configure(ArrayNodeDefinition $node) |
|||
21 | { |
||||
22 | 4 | $this->configureCoverageSection($node); |
|||
23 | 4 | $this->configureSessionSection($node); |
|||
24 | 4 | $this->configureReportSection($node); |
|||
25 | 4 | $this->configureFilterSection($node); |
|||
26 | } |
||||
27 | |||||
28 | 4 | private function configureCoverageSection(ArrayNodeDefinition $node) |
|||
29 | { |
||||
30 | $node |
||||
31 | 4 | ->children() |
|||
32 | 4 | ->booleanNode('xdebug_patch')->defaultTrue()->end() |
|||
33 | 4 | ->arrayNode('coverage') |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
34 | 4 | ->addDefaultsIfNotSet() |
|||
35 | 4 | ->children() |
|||
36 | 4 | ->booleanNode('processUncoveredFilesFromWhitelist')->defaultFalse()->end() |
|||
37 | 4 | ->booleanNode('checkForUnintentionallyCoveredCode')->defaultFalse()->end() |
|||
38 | 4 | ->booleanNode('forceCoversAnnotation')->defaultFalse()->end() |
|||
39 | 4 | ->booleanNode('checkForMissingCoversAnnotation')->defaultFalse()->end() |
|||
40 | 4 | ->booleanNode('checkForUnexecutedCoveredCode')->defaultFalse()->end() |
|||
41 | 4 | ->booleanNode('addUncoveredFilesFromWhitelist')->defaultTrue()->end() |
|||
42 | 4 | ->booleanNode('disableIgnoredLines')->defaultFalse()->end() |
|||
43 | 4 | ->booleanNode('ignoreDeprecatedCode')->defaultFalse()->end() |
|||
44 | 4 | ->arrayNode('unintentionallyCoveredSubclassesWhitelist') |
|||
45 | 4 | ->scalarPrototype()->end() |
|||
46 | 4 | ->end() |
|||
47 | 4 | ->end() |
|||
48 | 4 | ->end() |
|||
49 | 4 | ->end(); |
|||
50 | } |
||||
51 | |||||
52 | /** |
||||
53 | * Configure remote section. |
||||
54 | * |
||||
55 | * @return ArrayNodeDefinition |
||||
56 | */ |
||||
57 | 4 | private function configureSessionSection(ArrayNodeDefinition $node) |
|||
58 | { |
||||
59 | $node |
||||
60 | 4 | ->addDefaultsIfNotSet() |
|||
61 | 4 | ->children() |
|||
62 | 4 | ->arrayNode('sessions') |
|||
63 | 4 | ->useAttributeAsKey('name', false) |
|||
64 | 4 | ->arrayPrototype() |
|||
65 | 4 | ->children() |
|||
66 | 4 | ->enumNode('driver') |
|||
67 | 4 | ->values(['local', 'remote']) |
|||
68 | 4 | ->defaultValue('local') |
|||
69 | 4 | ->end() |
|||
70 | 4 | ->scalarNode('remote_url')->end() |
|||
0 ignored issues
–
show
The method
scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
71 | 4 | ->end() |
|||
72 | 4 | ->end() |
|||
73 | 4 | ->end() |
|||
74 | 4 | ->end(); |
|||
75 | } |
||||
76 | |||||
77 | 4 | private function configureReportSection(ArrayNodeDefinition $builder) |
|||
78 | { |
||||
79 | $builder |
||||
80 | 4 | ->addDefaultsIfNotSet() |
|||
81 | 4 | ->children() |
|||
82 | 4 | ->arrayNode('report') |
|||
83 | 4 | ->addDefaultsIfNotSet() |
|||
84 | 4 | ->children() |
|||
85 | 4 | ->append($this->addOptionsNode('clover')) |
|||
86 | 4 | ->append($this->addOptionsNode('crap4j')) |
|||
87 | 4 | ->append($this->addOptionsNode('html')) |
|||
88 | 4 | ->append($this->addOptionsNode('php')) |
|||
89 | 4 | ->append($this->addOptionsNode('text')) |
|||
90 | 4 | ->append($this->addOptionsNode('xml')) |
|||
91 | 4 | ->end() |
|||
92 | 4 | ->end() |
|||
93 | 4 | ->end(); |
|||
0 ignored issues
–
show
The method
end() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
94 | } |
||||
95 | |||||
96 | /** |
||||
97 | * @param string $name |
||||
98 | * |
||||
99 | * @return ArrayNodeDefinition |
||||
100 | */ |
||||
101 | 4 | private function addOptionsNode($name) |
|||
102 | { |
||||
103 | 4 | $treeBuilder = new ArrayNodeDefinition($name); |
|||
104 | $normalizer = function ($v) { |
||||
105 | return [ |
||||
106 | 4 | 'target' => $v, |
|||
107 | ]; |
||||
108 | 4 | }; |
|||
109 | |||||
110 | return $treeBuilder |
||||
111 | 4 | ->beforeNormalization() |
|||
112 | 4 | ->ifString()->then($normalizer) |
|||
113 | 4 | ->end() |
|||
114 | 4 | ->scalarPrototype()->end(); |
|||
0 ignored issues
–
show
The method
scalarPrototype() does not exist on Symfony\Component\Config...\Builder\NodeDefinition . It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
115 | } |
||||
116 | |||||
117 | 4 | private function configureFilterSection(ArrayNodeDefinition $builder) |
|||
118 | { |
||||
119 | $stringNormalizer = function ($v) { |
||||
120 | 4 | return ['directory' => $v]; |
|||
121 | 4 | }; |
|||
122 | |||||
123 | $builder |
||||
124 | 4 | ->children() |
|||
125 | 4 | ->arrayNode('filter') |
|||
126 | 4 | ->arrayPrototype() |
|||
127 | 4 | ->beforeNormalization() |
|||
128 | 4 | ->ifString()->then($stringNormalizer) |
|||
129 | 4 | ->end() |
|||
130 | 4 | ->children() |
|||
131 | 4 | ->scalarNode('directory')->defaultNull()->end() |
|||
132 | 4 | ->scalarNode('file')->defaultNull()->end() |
|||
133 | 4 | ->scalarNode('suffix')->defaultValue('.php')->end() |
|||
134 | 4 | ->scalarNode('prefix')->defaultValue('')->end() |
|||
135 | 4 | ->arrayNode('exclude') |
|||
136 | 4 | ->arrayPrototype() |
|||
137 | 4 | ->beforeNormalization() |
|||
138 | 4 | ->ifString()->then($stringNormalizer) |
|||
139 | 4 | ->end() |
|||
140 | 4 | ->children() |
|||
141 | 4 | ->scalarNode('directory')->defaultNull()->end() |
|||
142 | 4 | ->scalarNode('file')->defaultNull()->end() |
|||
143 | 4 | ->scalarNode('suffix')->defaultNull()->end() |
|||
144 | 4 | ->scalarNode('prefix')->defaultNull()->end() |
|||
145 | 4 | ->end() |
|||
146 | 4 | ->end() |
|||
147 | 4 | ->end() |
|||
148 | 4 | ->end() |
|||
149 | 4 | ->end() |
|||
150 | 4 | ->end() |
|||
151 | 4 | ->end(); |
|||
152 | } |
||||
153 | } |
||||
154 |