We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 2 |
Paths | 1 |
Total Lines | 30 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Tests | 23 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
18 | 15 | public function getDefinition() |
|
19 | { |
||
20 | 15 | $builder = new TreeBuilder(); |
|
21 | 15 | $node = $builder->root('_enum_config'); |
|
22 | |||
23 | $node |
||
|
|||
24 | 15 | ->children() |
|
25 | 15 | ->append($this->nameSection()) |
|
26 | 15 | ->arrayNode('values') |
|
27 | 15 | ->useAttributeAsKey('name') |
|
28 | 15 | ->prototype('array') |
|
29 | 15 | ->beforeNormalization() |
|
30 | ->ifTrue(function ($v) { return !is_null($v) && !is_array($v); }) |
||
31 | ->then(function ($v) { return ['value' => $v]; }) |
||
32 | 15 | ->end() |
|
33 | 15 | ->isRequired() |
|
34 | 15 | ->children() |
|
35 | 15 | ->scalarNode('value')->end() |
|
36 | 15 | ->append($this->descriptionSection()) |
|
37 | 15 | ->append($this->deprecationReasonSelection()) |
|
38 | 15 | ->end() |
|
39 | 15 | ->end() |
|
40 | 15 | ->isRequired() |
|
41 | 15 | ->requiresAtLeastOneElement() |
|
42 | 15 | ->end() |
|
43 | 15 | ->append($this->descriptionSection()) |
|
44 | 15 | ->end(); |
|
45 | |||
46 | 15 | return $node; |
|
47 | } |
||
48 | } |
||
49 |
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: