| 1 | <?php |
||
| 21 | class DirectiveInvocationBuilder extends DefinitionBuilder |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @param Readable $file |
||
| 25 | * @param RuleInterface|DirectiveValueNode $ast |
||
| 26 | * @return \Generator|mixed|void |
||
| 27 | */ |
||
| 28 | public function build(Readable $file, RuleInterface $ast) |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param DirectiveValueNode $ast |
||
| 39 | * @param TypeInvocation $directive |
||
| 40 | * @return \Generator |
||
| 41 | */ |
||
| 42 | private function loadArguments(DirectiveValueNode $ast, TypeInvocation $directive): \Generator |
||
| 50 | } |
||
| 51 |
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: