| Conditions | 2 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | public function handle( |
||
| 35 | AbstractAnnotation $annotation, |
||
| 36 | ServiceMethodBuilder $serviceMethodBuilder, |
||
| 37 | ?Converter $converter, |
||
| 38 | ?int $index |
||
| 39 | ): void { |
||
| 40 | $uri = $annotation->getValue(); |
||
| 41 | |||
| 42 | $serviceMethodBuilder->setMethod($annotation->getType()); |
||
|
|
|||
| 43 | $serviceMethodBuilder->setPath($uri); |
||
| 44 | |||
| 45 | if (!$annotation->hasBody()) { |
||
| 46 | $serviceMethodBuilder->setHasBody($annotation->hasBody()); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
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: