| Conditions | 1 |
| Paths | 1 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | 1 | protected function build($builder) |
|
| 21 | { |
||
| 22 | return $builder |
||
| 23 | 1 | ->add('message', 'textarea', array( |
|
| 24 | 1 | 'constraints' => new NotBlank( |
|
| 25 | 1 | array("message" => "You can't send an empty message!" |
|
| 26 | )) |
||
| 27 | )) |
||
| 28 | 1 | ->add('Send', 'submit') |
|
| 29 | 1 | ->setAction($this->editing->getUrl()); |
|
|
|
|||
| 30 | } |
||
| 31 | } |
||
| 32 |
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: