These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * (c) Christian Gripp <[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 | namespace Core23\SitemapBundle\DependencyInjection; |
||
13 | |||
14 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||
15 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||
16 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||
17 | |||
18 | final class Configuration implements ConfigurationInterface |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | public function getConfigTreeBuilder() |
||
24 | { |
||
25 | $treeBuilder = new TreeBuilder('core23_sitemap'); |
||
26 | |||
27 | // Keep compatibility with symfony/config < 4.2 |
||
28 | if (!\method_exists($treeBuilder, 'getRootNode')) { |
||
29 | $rootNode = $treeBuilder->root('core23_sitemap'); |
||
30 | } else { |
||
31 | $rootNode = $treeBuilder->getRootNode(); |
||
32 | } |
||
33 | |||
34 | $this->addStaticUrlsSection($rootNode); |
||
0 ignored issues
–
show
|
|||
35 | $this->addCacheSection($rootNode); |
||
0 ignored issues
–
show
$rootNode of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition> . It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.
Loading history...
|
|||
36 | |||
37 | return $treeBuilder; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param ArrayNodeDefinition $node |
||
42 | */ |
||
43 | private function addCacheSection(ArrayNodeDefinition $node): void |
||
44 | { |
||
45 | $node |
||
46 | ->children() |
||
47 | ->arrayNode('cache') |
||
48 | ->addDefaultsIfNotSet() |
||
49 | ->children() |
||
50 | ->scalarNode('service')->defaultNull()->end() |
||
51 | ->end() |
||
52 | ->end() |
||
53 | ->end() |
||
54 | ; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param ArrayNodeDefinition $node |
||
59 | */ |
||
60 | private function addStaticUrlsSection(ArrayNodeDefinition $node): void |
||
61 | { |
||
62 | $node |
||
63 | ->children() |
||
64 | ->arrayNode('static') |
||
65 | ->defaultValue([]) |
||
66 | ->prototype('array') |
||
67 | ->children() |
||
68 | ->scalarNode('url')->end() |
||
69 | ->integerNode('priority')->defaultNull()->end() |
||
70 | ->scalarNode('changefreq')->defaultNull()->end() |
||
71 | ->end() |
||
72 | ->end() |
||
73 | ->end() |
||
74 | ->end() |
||
75 | ; |
||
76 | } |
||
77 | } |
||
78 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.