| Conditions | 2 |
| Paths | 2 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function getConfigTreeBuilder() |
||
| 11 | { |
||
| 12 | $treeBuilder = new TreeBuilder('tactician_domain_event'); |
||
| 13 | $rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('tactician_domain_event'); |
||
| 14 | |||
| 15 | $rootNode |
||
|
|
|||
| 16 | ->children() |
||
| 17 | ->booleanNode('collect_from_all_managed_entities') |
||
| 18 | ->defaultFalse() |
||
| 19 | ->end() |
||
| 20 | ->end() |
||
| 21 | ; |
||
| 22 | |||
| 23 | return $treeBuilder; |
||
| 24 | } |
||
| 25 | } |
||
| 26 |
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: