| 1 | <?php declare(strict_types=1);  | 
            ||
| 10 | final class Echoer implements Dumper  | 
            ||
| 11 | { | 
            ||
| 12 | // 1 - key  | 
            ||
| 13 | // 2 - value  | 
            ||
| 14 | private const TEMPLATE = "\033[36m| \033[1m%s : \033[0;36m%s\033[0m\n";  | 
            ||
| 15 | |||
| 16 | public function dump(MessageInterface $message, array $headers): void  | 
            ||
| 38 | |||
| 39 | public function supports(MessageInterface $message): bool  | 
            ||
| 43 | }  | 
            ||
| 44 | 
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 implementation 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 interface: