1 | <?php |
||||
2 | |||||
3 | /* |
||||
4 | * This file is part of the doyo/code-coverage 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\Bridge\CodeCoverage; |
||||
15 | |||||
16 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||||
17 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||||
18 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||||
19 | |||||
20 | class Configuration implements ConfigurationInterface |
||||
21 | { |
||||
22 | /** |
||||
23 | * @var callable |
||||
24 | */ |
||||
25 | private $stringToArrayNormalizer; |
||||
26 | |||||
27 | 7 | public function __construct() |
|||
28 | { |
||||
29 | $this->stringToArrayNormalizer = function ($v) { |
||||
30 | return [ |
||||
31 | 7 | 'target' => $v, |
|||
32 | ]; |
||||
33 | }; |
||||
34 | } |
||||
35 | |||||
36 | /** |
||||
37 | * @return TreeBuilder |
||||
38 | */ |
||||
39 | 35 | public function getConfigTreeBuilder() |
|||
40 | { |
||||
41 | 35 | $treeBuilder = new TreeBuilder(); |
|||
42 | 35 | $this->configure($treeBuilder->root('config')); |
|||
0 ignored issues
–
show
|
|||||
43 | |||||
44 | 35 | return $treeBuilder; |
|||
45 | } |
||||
46 | |||||
47 | 35 | public function configure(ArrayNodeDefinition $node) |
|||
48 | { |
||||
49 | 35 | $this->configureCoverageSection($node); |
|||
50 | 35 | $this->configureSessionSection($node); |
|||
51 | 35 | $this->configureReportSection($node); |
|||
52 | 35 | $this->configureFilterSection($node); |
|||
53 | |||||
54 | 35 | return $node; |
|||
55 | } |
||||
56 | |||||
57 | 35 | private function configureCoverageSection(ArrayNodeDefinition $node) |
|||
58 | { |
||||
59 | $node |
||||
60 | 35 | ->children() |
|||
61 | 35 | ->arrayNode('imports') |
|||
62 | 35 | ->scalarPrototype()->end() |
|||
63 | 35 | ->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
![]() |
|||||
64 | 35 | ->booleanNode('xdebug_patch')->defaultTrue()->end() |
|||
65 | 35 | ->booleanNode('debug')->defaultFalse()->end() |
|||
66 | 35 | ->scalarNode('env')->defaultValue('prod')->end() |
|||
67 | 35 | ->arrayNode('coverage') |
|||
68 | 35 | ->addDefaultsIfNotSet() |
|||
69 | 35 | ->children() |
|||
70 | 35 | ->booleanNode('processUncoveredFilesFromWhitelist')->defaultFalse()->end() |
|||
71 | 35 | ->booleanNode('checkForUnintentionallyCoveredCode')->defaultFalse()->end() |
|||
72 | 35 | ->booleanNode('forceCoversAnnotation')->defaultFalse()->end() |
|||
73 | 35 | ->booleanNode('checkForMissingCoversAnnotation')->defaultFalse()->end() |
|||
74 | 35 | ->booleanNode('checkForUnexecutedCoveredCode')->defaultFalse()->end() |
|||
75 | 35 | ->booleanNode('addUncoveredFilesFromWhitelist')->defaultTrue()->end() |
|||
76 | 35 | ->booleanNode('disableIgnoredLines')->defaultFalse()->end() |
|||
77 | 35 | ->booleanNode('ignoreDeprecatedCode')->defaultFalse()->end() |
|||
78 | 35 | ->arrayNode('unintentionallyCoveredSubclassesWhitelist') |
|||
79 | 35 | ->scalarPrototype()->end() |
|||
80 | 35 | ->end() |
|||
81 | 35 | ->end() |
|||
82 | 35 | ->end() |
|||
83 | 35 | ->end(); |
|||
84 | } |
||||
85 | |||||
86 | /** |
||||
87 | * Configure remote section. |
||||
88 | * |
||||
89 | * @return ArrayNodeDefinition |
||||
90 | */ |
||||
91 | 35 | private function configureSessionSection(ArrayNodeDefinition $node) |
|||
92 | { |
||||
93 | $node |
||||
94 | 35 | ->addDefaultsIfNotSet() |
|||
95 | 35 | ->children() |
|||
96 | 35 | ->arrayNode('sessions') |
|||
97 | 35 | ->useAttributeAsKey('name', false) |
|||
98 | 35 | ->arrayPrototype() |
|||
99 | 35 | ->children() |
|||
100 | 35 | ->enumNode('driver') |
|||
101 | 35 | ->values(['local', 'remote']) |
|||
102 | 35 | ->defaultValue('local') |
|||
103 | 35 | ->end() |
|||
104 | 35 | ->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
![]() |
|||||
105 | 35 | ->end() |
|||
106 | 35 | ->end() |
|||
107 | 35 | ->end() |
|||
108 | 35 | ->end(); |
|||
109 | } |
||||
110 | |||||
111 | 35 | private function configureReportSection(ArrayNodeDefinition $builder) |
|||
112 | { |
||||
113 | $builder |
||||
114 | 35 | ->addDefaultsIfNotSet() |
|||
115 | 35 | ->children() |
|||
116 | 35 | ->arrayNode('reports') |
|||
117 | 35 | ->addDefaultsIfNotSet() |
|||
118 | 35 | ->children() |
|||
119 | 35 | ->append($this->addOptionsNode('clover')) |
|||
120 | 35 | ->append($this->addOptionsNode('crap4j')) |
|||
121 | 35 | ->append($this->addOptionsNode('html')) |
|||
122 | 35 | ->append($this->addOptionsNode('php')) |
|||
123 | 35 | ->arrayNode('text') |
|||
124 | 35 | ->beforeNormalization() |
|||
125 | 35 | ->ifString()->then($this->stringToArrayNormalizer) |
|||
126 | 35 | ->end() |
|||
127 | 35 | ->children() |
|||
128 | 35 | ->scalarNode('target')->defaultValue('console')->end() |
|||
129 | 35 | ->end() |
|||
130 | 35 | ->end() |
|||
131 | 35 | ->append($this->addOptionsNode('xml')) |
|||
132 | 35 | ->end() |
|||
133 | 35 | ->end() |
|||
134 | 35 | ->end(); |
|||
135 | } |
||||
136 | |||||
137 | /** |
||||
138 | * @param string $name |
||||
139 | * |
||||
140 | * @return ArrayNodeDefinition |
||||
141 | */ |
||||
142 | 35 | private function addOptionsNode($name) |
|||
143 | { |
||||
144 | 35 | $treeBuilder = new ArrayNodeDefinition($name); |
|||
145 | |||||
146 | return $treeBuilder |
||||
147 | 35 | ->beforeNormalization() |
|||
148 | 35 | ->ifString()->then($this->stringToArrayNormalizer) |
|||
149 | 35 | ->end() |
|||
150 | 35 | ->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
![]() |
|||||
151 | } |
||||
152 | |||||
153 | 35 | private function configureFilterSection(ArrayNodeDefinition $builder) |
|||
154 | { |
||||
155 | $stringNormalizer = function ($v) { |
||||
156 | 1 | return ['directory' => $v]; |
|||
157 | 35 | }; |
|||
158 | |||||
159 | $builder |
||||
160 | 35 | ->children() |
|||
161 | 35 | ->arrayNode('filter') |
|||
162 | 35 | ->arrayPrototype() |
|||
163 | 35 | ->beforeNormalization() |
|||
164 | 35 | ->ifString()->then($stringNormalizer) |
|||
165 | 35 | ->end() |
|||
166 | 35 | ->children() |
|||
167 | 35 | ->scalarNode('directory')->defaultNull()->end() |
|||
168 | 35 | ->scalarNode('file')->defaultNull()->end() |
|||
169 | 35 | ->scalarNode('suffix')->defaultValue('.php')->end() |
|||
170 | 35 | ->scalarNode('prefix')->defaultValue('')->end() |
|||
171 | 35 | ->arrayNode('exclude') |
|||
172 | 35 | ->arrayPrototype() |
|||
173 | 35 | ->beforeNormalization() |
|||
174 | 35 | ->ifString()->then($stringNormalizer) |
|||
175 | 35 | ->end() |
|||
176 | 35 | ->children() |
|||
177 | 35 | ->scalarNode('directory')->defaultNull()->end() |
|||
178 | 35 | ->scalarNode('file')->defaultNull()->end() |
|||
179 | 35 | ->scalarNode('suffix')->defaultNull()->end() |
|||
180 | 35 | ->scalarNode('prefix')->defaultNull()->end() |
|||
181 | 35 | ->end() |
|||
182 | 35 | ->end() |
|||
183 | 35 | ->end() |
|||
184 | 35 | ->end() |
|||
185 | 35 | ->end() |
|||
186 | 35 | ->end() |
|||
187 | 35 | ->end(); |
|||
188 | } |
||||
189 | } |
||||
190 |
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.