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 |
||
| 23 | class WindowHelpFactory extends WindowFactory |
||
| 24 | { |
||
| 25 | /** @var GridBuilderFactory */ |
||
| 26 | protected $gridBuilderFactory; |
||
| 27 | |||
| 28 | /** @var DataCollectionFactory */ |
||
| 29 | protected $dataCollectionFactory; |
||
| 30 | |||
| 31 | /** @var ChatCommands */ |
||
| 32 | protected $chatCommands; |
||
| 33 | |||
| 34 | /** @var ChatCommandDataProvider */ |
||
| 35 | protected $chatCommandDataPovider; |
||
| 36 | |||
| 37 | /** @var WindowHelpDetailsFactory */ |
||
| 38 | protected $windowHelpDetailsFactory; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param GridBuilderFactory $gridBuilderFactory |
||
| 42 | */ |
||
| 43 | public function setGridBuilderFactory($gridBuilderFactory) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param DataCollectionFactory $dataCollectionFactory |
||
| 50 | */ |
||
| 51 | public function setDataCollectionFactory($dataCollectionFactory) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param ChatCommands $chatCommands |
||
| 58 | */ |
||
| 59 | public function setChatCommands($chatCommands) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param ChatCommandDataProvider $chatCommandDataPovider |
||
| 66 | */ |
||
| 67 | public function setChatCommandDataProvide($chatCommandDataPovider) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param WindowHelpDetailsFactory $windowHelpDetailsFactory |
||
| 74 | */ |
||
| 75 | public function setWindowDescriptionFactory(WindowHelpDetailsFactory $windowHelpDetailsFactory) |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @inheritdoc |
||
| 82 | */ |
||
| 83 | protected function createContent(ManialinkInterface $manialink) |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @inheritdoc |
||
| 130 | */ |
||
| 131 | View Code Duplication | protected function updateContent(ManialinkInterface $manialink) |
|
| 144 | |||
| 145 | /** |
||
| 146 | * Get chat commands to display the admin. |
||
| 147 | * |
||
| 148 | * @param ManialinkInterface $manialink |
||
| 149 | * |
||
| 150 | * @return array |
||
| 151 | */ |
||
| 152 | protected function getChatCommands(ManialinkInterface $manialink) |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Callbacked called when help button is pressed. |
||
| 181 | * |
||
| 182 | * @param $login |
||
| 183 | * @param $params |
||
| 184 | * @param $arguments |
||
| 185 | */ |
||
| 186 | public function callbackHelp($login, $params, $arguments) |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Callbacked called when description button is pressed. |
||
| 193 | * |
||
| 194 | * @param $login |
||
| 195 | * @param $params |
||
| 196 | * @param $arguments |
||
| 197 | */ |
||
| 198 | public function callbackDescription($login, $params, $arguments) |
||
| 205 | } |
||
| 206 |
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: