Conditions | 1 |
Paths | 1 |
Total Lines | 21 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function getConfigTreeBuilder() |
||
19 | { |
||
20 | $treeBuilder = new TreeBuilder(); |
||
21 | $rootNode = $treeBuilder->root('victoire_seo'); |
||
22 | |||
23 | $rootNode |
||
|
|||
24 | ->addDefaultsIfNotSet() |
||
25 | ->children() |
||
26 | ->arrayNode('analytics') |
||
27 | ->useAttributeAsKey(true) |
||
28 | ->prototype('array') |
||
29 | ->children() |
||
30 | ->booleanNode('enabled')->defaultValue('false')->end() |
||
31 | ->scalarNode('key')->defaultNull()->end() |
||
32 | ->end() |
||
33 | ->end() |
||
34 | ->end() |
||
35 | ->end(); |
||
36 | |||
37 | return $treeBuilder; |
||
38 | } |
||
39 | } |
||
40 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: