We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
18 | 15 | public function getDefinition() |
|
19 | { |
||
20 | 15 | $builder = new TreeBuilder(); |
|
21 | 15 | $node = $builder->root('_input_object_config'); |
|
22 | |||
23 | $node |
||
|
|||
24 | 15 | ->children() |
|
25 | 15 | ->append($this->nameSection()) |
|
26 | 15 | ->arrayNode('fields') |
|
27 | 15 | ->useAttributeAsKey('name', false) |
|
28 | 15 | ->prototype('array') |
|
29 | 15 | ->append($this->typeSelection(true)) |
|
30 | 15 | ->append($this->descriptionSection()) |
|
31 | 15 | ->append($this->defaultValueSection()) |
|
32 | 15 | ->end() |
|
33 | 15 | ->isRequired() |
|
34 | 15 | ->requiresAtLeastOneElement() |
|
35 | 15 | ->end() |
|
36 | 15 | ->append($this->descriptionSection()) |
|
37 | 15 | ->end(); |
|
38 | |||
39 | 15 | return $node; |
|
40 | } |
||
41 | } |
||
42 |
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: