Conditions | 1 |
Paths | 1 |
Total Lines | 13 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
25 | public function addRestRootResourcesSection($rootNode) |
||
26 | { |
||
27 | $systemNode = $this->generateScopeBaseNode($rootNode); |
||
28 | $systemNode |
||
|
|||
29 | ->arrayNode('rest_root_resources') |
||
30 | ->prototype('array') |
||
31 | ->children() |
||
32 | ->scalarNode('mediaType')->isRequired()->end() |
||
33 | ->scalarNode('href')->isRequired()->end() |
||
34 | ->end() |
||
35 | ->end() |
||
36 | ->end(); |
||
37 | } |
||
38 | } |
||
39 |
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: