Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function getConfigTreeBuilder() |
||
30 | { |
||
31 | $treeBuilder = new TreeBuilder(); |
||
32 | |||
33 | $rootNode = $treeBuilder->root('surfnet_stepup_gateway_second_factor_only'); |
||
34 | |||
35 | $rootNode |
||
|
|||
36 | ->children() |
||
37 | ->arrayNode('loa_aliases') |
||
38 | ->isRequired() |
||
39 | ->children() |
||
40 | ->prototype('array') |
||
41 | ->children() |
||
42 | ->scalarNode('loa')->isRequired()->end() |
||
43 | ->scalarNode('alias')->isRequired()->end() |
||
44 | ->end() |
||
45 | ->end() |
||
46 | ->end() |
||
47 | ->end() |
||
48 | ->end(); |
||
49 | |||
50 | return $treeBuilder; |
||
51 | } |
||
52 | } |
||
53 |
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: