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 |
||
| 42 | class Server implements ISettings { |
||
| 43 | /** @var IDBConnection|Connection */ |
||
| 44 | private $db; |
||
| 45 | /** @var IRequest */ |
||
| 46 | private $request; |
||
| 47 | /** @var IConfig */ |
||
| 48 | private $config; |
||
| 49 | /** @var ILockingProvider */ |
||
| 50 | private $lockingProvider; |
||
| 51 | /** @var IL10N */ |
||
| 52 | private $l; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param IDBConnection $db |
||
| 56 | * @param IRequest $request |
||
| 57 | * @param IConfig $config |
||
| 58 | * @param ILockingProvider $lockingProvider |
||
| 59 | * @param IL10N $l |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function __construct(IDBConnection $db, |
|
| 72 | |||
| 73 | /** |
||
| 74 | * @return TemplateResponse |
||
| 75 | */ |
||
| 76 | public function getForm() { |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return string the section ID, e.g. 'sharing' |
||
| 91 | */ |
||
| 92 | public function getSection() { |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return int whether the form should be rather on the top or bottom of |
||
| 98 | * the admin section. The forms are arranged in ascending order of the |
||
| 99 | * priority values. It is required to return a value between 0 and 100. |
||
| 100 | * |
||
| 101 | * E.g.: 70 |
||
| 102 | */ |
||
| 103 | public function getPriority() { |
||
| 106 | } |
||
| 107 |
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: