1 | <?php |
||
14 | class WebHookController extends AbstractController |
||
15 | { |
||
16 | /** @var string */ |
||
17 | private $telegramToken; |
||
18 | |||
19 | /** @var bool */ |
||
20 | private $debug; |
||
21 | |||
22 | public function __construct(string $telegramToken, bool $debug) |
||
27 | |||
28 | public function receiveUpdateAction(Request $request, string $token, IncomingUpdateDispatcher $updateDispatcher, LoggerInterface $logger): Response |
||
60 | } |
||
61 |
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: