| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 67 | protected function assembleErrorString() |
||
| 68 | { |
||
| 69 | $string = 'Jobs: ' . PHP_EOL; |
||
| 70 | $i = 1; |
||
| 71 | foreach ($this->cron->getExecutor()->getRunningJobs() as $job) { |
||
|
|
|||
| 72 | $string .= $i . '. ' . $job->getProcess()->getCommandLine() . PHP_EOL; |
||
| 73 | $i++; |
||
| 74 | } |
||
| 75 | |||
| 76 | return $string . ' have taken over ' . $this->timeout . ' seconds to execute.'; |
||
| 77 | } |
||
| 78 | } |
||
| 79 |
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: