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 |
||
| 13 | class ConsoleInstaller |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var LoggerInterface |
||
| 17 | */ |
||
| 18 | protected $logger; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var Configuration |
||
| 22 | */ |
||
| 23 | protected $configuration; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var bool |
||
| 27 | */ |
||
| 28 | protected $overwrite = false; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param LoggerInterface $logger |
||
| 32 | * @param Configuration $configuration |
||
| 33 | */ |
||
| 34 | public function __construct(LoggerInterface $logger, Configuration $configuration) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Allow the Installer and it's steps to attempt to install Symphony at all costs, |
||
| 45 | * including removing and deleting existing data. Use with caution. |
||
| 46 | * |
||
| 47 | * @param bool $overwrite |
||
| 48 | * @return $this |
||
| 49 | */ |
||
| 50 | public function setOverride($overwrite = false) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Installs Symphony using the configuration information available. |
||
| 59 | * |
||
| 60 | * @param array $data |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | public function install(array $data) |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Bootstrap the environment to the bare minimum for Symphony to 'run'. |
||
| 103 | */ |
||
| 104 | private function bootstrap() |
||
| 124 | } |
||
| 125 |
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: