| Conditions | 2 |
| Paths | 2 |
| Total Lines | 9 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function __construct(Scope $scope, MethodData $method) |
||
| 13 | { |
||
| 14 | parent::__construct($scope); |
||
| 15 | $this->addVar($this->getParent()->getVar('this')); |
||
| 16 | $this->method = $method; |
||
| 17 | foreach ($method->arguments as $param) { |
||
| 18 | $this->addVar($param); |
||
| 19 | } |
||
| 20 | } |
||
| 21 | public function getFQCN() |
||
| 30 |
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: