| Conditions | 1 |
| Paths | 1 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function getConfigTreeBuilder() |
||
| 19 | { |
||
| 20 | $treeBuilder = new TreeBuilder(); |
||
| 21 | $rootNode = $treeBuilder->root('victoire_twig'); |
||
| 22 | |||
| 23 | // Here you should define the parameters that are allowed to |
||
| 24 | // configure your bundle. See the documentation linked above for |
||
| 25 | // more information on that topic. |
||
| 26 | |||
| 27 | $rootNode |
||
|
|
|||
| 28 | ->addDefaultsIfNotSet() |
||
| 29 | ->children() |
||
| 30 | ->arrayNode('responsive') |
||
| 31 | ->useAttributeAsKey(true) |
||
| 32 | ->prototype('array') |
||
| 33 | ->children() |
||
| 34 | ->integerNode('min')->end() |
||
| 35 | ->integerNode('max')->end() |
||
| 36 | ->end() |
||
| 37 | ->end() |
||
| 38 | ->end(); |
||
| 39 | |||
| 40 | return $treeBuilder; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
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: