| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 51 | public function addConfiguration(NodeDefinition $node) |
||
| 52 | { |
||
| 53 | $node |
||
|
1 ignored issue
–
show
|
|||
| 54 | ->children() |
||
| 55 | ->scalarNode('path')->isRequired()->end() |
||
| 56 | ->scalarNode('password')->defaultNull()->end() |
||
| 57 | ->arrayNode('additional_values') |
||
| 58 | ->defaultValue([]) |
||
| 59 | ->useAttributeAsKey('key') |
||
| 60 | ->prototype('variable')->end() |
||
| 61 | ->end() |
||
| 62 | ->end(); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
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: