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 | /** |
||
| 38 | * @param GridBuilderFactory $gridBuilderFactory |
||
| 39 | */ |
||
| 40 | public function setGridBuilderFactory($gridBuilderFactory) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param DataCollectionFactory $dataCollectionFactory |
||
| 47 | */ |
||
| 48 | public function setDataCollectionFactory($dataCollectionFactory) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param ChatCommands $chatCommands |
||
| 55 | */ |
||
| 56 | public function setChatCommands($chatCommands) |
||
| 60 | |||
| 61 | public function setChatCommandDataProvide($chatCommandDataPovider) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @inheritdoc |
||
| 68 | */ |
||
| 69 | protected function createContent(ManialinkInterface $manialink) |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @inheritdoc |
||
| 103 | */ |
||
| 104 | View Code Duplication | protected function updateContent(ManialinkInterface $manialink) |
|
| 117 | |||
| 118 | /** |
||
| 119 | * Get chat commands to display the admin. |
||
| 120 | * |
||
| 121 | * @param ManialinkInterface $manialink |
||
| 122 | * |
||
| 123 | * @return array |
||
| 124 | */ |
||
| 125 | protected function getChatCommands(ManialinkInterface $manialink) |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Callbacked called when help button is pressed. |
||
| 154 | * |
||
| 155 | * @param $login |
||
| 156 | * @param $params |
||
| 157 | * @param $arguments |
||
| 158 | */ |
||
| 159 | public function callbackHelp($login, $params, $arguments) |
||
| 163 | } |
||
| 164 |
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: