| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Arcanedev\Composer\Entities\PackageTraits; |
||
| 30 | protected function mergeScripts(RootPackageInterface $root, PluginState $state) |
||
| 31 | { |
||
| 32 | $scripts = $this->getPackage()->getScripts(); |
||
| 33 | |||
| 34 | if ( ! $state->shouldMergeScripts() || empty($scripts)) |
||
| 35 | return; |
||
| 36 | |||
| 37 | $rootScripts = $root->getScripts(); |
||
| 38 | |||
| 39 | $scripts = $state->replaceDuplicateLinks() |
||
| 40 | ? array_merge($rootScripts, $scripts) |
||
| 41 | : array_merge($scripts, $rootScripts); |
||
| 42 | |||
| 43 | self::unwrapIfNeeded($root, 'setScripts') |
||
|
|
|||
| 44 | ->setScripts($scripts); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |
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: