| Conditions | 5 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | * @param RecyclingLog $recyclingLog |
||
| 31 | */ |
||
| 32 | public function add(RecyclingLog $recyclingLog) |
||
| 33 | { |
||
| 34 | $this->entityManager->persist($recyclingLog); |
||
| 35 | $this->entityManager->flush($recyclingLog); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param int $baseId |
||
| 40 | * @return array |
||
| 41 | */ |
||
| 42 | public function getBaseActiveMissionsLogs($baseId) |
||
| 43 | { |
||
| 44 | return $this->entityManager->getRepository(RecyclingLog::class)->getBaseActiveMissionsLogs($baseId); |
||
|
|
|||
| 45 | } |
||
| 46 | } |
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 sub-classes 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 parent class: