1 | <?php |
||
14 | class Configuration implements ConfigurationInterface |
||
15 | { |
||
16 | /** |
||
17 | * Config tree builder. |
||
18 | * |
||
19 | * Example config: |
||
20 | * |
||
21 | * anime_db_ani_db_browser: |
||
22 | * client: 'cache' |
||
23 | * app: |
||
24 | * version: 2 |
||
25 | * client: 'animedbplugin' |
||
26 | * code: 'api-team-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' |
||
27 | * |
||
28 | * @return TreeBuilder |
||
29 | */ |
||
30 | 11 | public function getConfigTreeBuilder() |
|
43 | |||
44 | /** |
||
45 | * @return TreeBuilder |
||
46 | */ |
||
47 | 11 | protected function getApp() |
|
66 | } |
||
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: