| 1 | <?php |
||
| 9 | trait MemberParserPart { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * |
||
| 13 | * @param AbstractPhpMember|PhpConstant $member |
||
| 14 | * @param Doc $doc |
||
| 15 | */ |
||
| 16 | 9 | private function parseMemberDocblock(&$member, Doc $doc = null) { |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Returns the visibility from a node |
||
| 33 | * |
||
| 34 | * @param Node $node |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | 8 | private function getVisibility(Node $node) { |
|
| 48 | } |
||
| 49 |
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: