1 | <?php namespace Arcanedev\Composer\Entities\PackageTraits; |
||
12 | trait ScriptsTrait |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Traits |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | use PackageTrait; |
||
19 | |||
20 | /* ------------------------------------------------------------------------------------------------ |
||
21 | | Main Functions |
||
22 | | ------------------------------------------------------------------------------------------------ |
||
23 | */ |
||
24 | /** |
||
25 | * Merge scripts config into a RootPackage. |
||
26 | * |
||
27 | * @param \Composer\Package\RootPackageInterface $root |
||
28 | * @param \Arcanedev\Composer\Entities\PluginState $state |
||
29 | */ |
||
30 | 99 | protected function mergeScripts(RootPackageInterface $root, PluginState $state) |
|
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: