| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 2 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 45 | protected function getScriptSource() |
||
| 46 | { |
||
| 47 | return parent::getScriptSource() . ' |
||
| 48 | jQuery(\'tr[data-row-with-details="1"]\').click(function() { |
||
| 49 | var $detailsRow = jQuery(this).next(); |
||
| 50 | var $detailsContainer; |
||
| 51 | if (!$detailsRow.data(\'loaded\')) { |
||
| 52 | $detailsRow.data(\'loaded\', 1); |
||
| 53 | $detailsContainer = $detailsRow.find(\'[data-details-container="1"]\'); |
||
| 54 | $detailsContainer.load($detailsContainer.data("details-url")); |
||
| 55 | } |
||
| 56 | }); |
||
| 57 | '; |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
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: