Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php | ||
| 14 | trait ManagesIocTrait | ||
| 15 | { | ||
| 16 | use DependsOnManagesItemsTrait; | ||
| 17 | |||
| 18 | /** @var string Name of the ioc manifest */ | ||
| 19 | protected $nameOfIocManifest = '_diManifest'; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Initializes IoC Container | ||
| 23 | * @param array $components | ||
| 24 | * @return void | ||
| 25 | */ | ||
| 26 | public function initDi(array $components = []) | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Returns the entire IoC Manifest | ||
| 34 | * @return array | ||
| 35 | */ | ||
| 36 | public function getIocManifest() | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Returns the request object with all dependencies | ||
| 45 | * | ||
| 46 | * string Full class name for a new object each time | ||
| 47 | * callable Factory to create new object (passed manager) | ||
| 48 | * object The exact object to be returned | ||
| 49 | * | ||
| 50 | * @param string $alias | ||
| 51 | * @param string|mixed $fallback | ||
| 52 | * @return object | ||
| 53 | * @throws \Exception | ||
| 54 | */ | ||
| 55 | public function fetch($alias, $fallback = '_michaels_no_fallback') | ||
| 75 | |||
| 76 | /** | ||
| 77 | * Adds a dependency to the manager | ||
| 78 | * | ||
| 79 | * $factory can be a: | ||
| 80 | * string Full class name for a new object each time | ||
| 81 | * callable Factory to create new object (passed manager) | ||
| 82 | * object The exact object to be returned | ||
| 83 | * | ||
| 84 | * @param string $alias | ||
| 85 | * @param callable|string|object $factory | ||
| 86 | * @param array $declared | ||
| 87 | * @return void | ||
| 88 | */ | ||
| 89 | public function di($alias, $factory, array $declared = null) | ||
| 98 | |||
| 99 | /** | ||
| 100 | * Turns a dependency into a singleton. | ||
| 101 | * @param $alias | ||
| 102 | * @return mixed | ||
| 103 | */ | ||
| 104 | public function share($alias) | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Add a pipeline to to the que | ||
| 111 | * @param $alias | ||
| 112 | * @param $pipeline | ||
| 113 | */ | ||
| 114 | public function setup($alias, $pipeline) | ||
| 118 | |||
| 119 | /** | ||
| 120 | * Returns the name of the property that holds data items | ||
| 121 | * @return string | ||
| 122 | */ | ||
| 123 | public function getDiItemsName() | ||
| 127 | |||
| 128 | /** | ||
| 129 | * Sets the name of the property that holds data items | ||
| 130 | * @param $nameOfItemsRepository | ||
| 131 | * @return $this | ||
| 132 | */ | ||
| 133 | public function setDiItemsName($nameOfItemsRepository) | ||
| 138 | |||
| 139 | /** | ||
| 140 | * Produces the object from an alias | ||
| 141 | * @param string $alias | ||
| 142 | * @param mixed|string $fallback | ||
| 143 | * @return mixed | ||
| 144 | * @throws ItemNotFoundException | ||
| 145 | * @throws \Exception | ||
| 146 | */ | ||
| 147 | protected function produceDependency($alias, $fallback = '_michaels_no_fallback') | ||
| 209 | } | ||
| 210 | 
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: