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