Conditions | 1 |
Paths | 1 |
Total Lines | 13 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 1 |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | 11 | public function getConfigTreeBuilder() |
|
31 | { |
||
32 | 11 | return (new TreeBuilder()) |
|
33 | 11 | ->root('anime_db_ani_db_browser') |
|
34 | 11 | ->children() |
|
35 | 11 | ->scalarNode('client') |
|
36 | 11 | ->cannotBeEmpty() |
|
37 | 11 | ->defaultValue('cache') |
|
38 | 11 | ->end() |
|
39 | 11 | ->end() |
|
40 | 11 | ->append($this->getApp()) |
|
41 | 11 | ->end(); |
|
42 | } |
||
43 | |||
67 |
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: