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 |
||
12 | class MigrateLaravelCommand extends Command |
||
13 | { |
||
14 | protected $listFileMigrations = [ |
||
15 | 'country' => '_Acreate_table_country', |
||
16 | 'regions' => '_Bcreate_table_regions', |
||
17 | 'cities' => '_Ccreate_table_cities' |
||
18 | ]; |
||
19 | |||
20 | protected $listFilesSeeder = [ |
||
21 | 'CountryTableSeeder' => 'CountryTableSeeder.php', |
||
22 | 'RegionsTableSeeder' => 'RegionsTableSeeder.php', |
||
23 | 'CitiesTableSeeder' => 'CitiesTableSeeder.php' |
||
24 | ]; |
||
25 | |||
26 | protected $formatterStyle; |
||
27 | protected $progressBar; |
||
28 | |||
29 | 2 | public function __construct(OutputFormatterStyle $formatterStyle, ProgressBar $bar) |
|
36 | |||
37 | 2 | protected function configure() : void |
|
41 | |||
42 | protected function execute(InputInterface $input, OutputInterface $output) |
||
61 | |||
62 | View Code Duplication | protected function moveMigrate(ProgressBar $progress) |
|
76 | |||
77 | View Code Duplication | protected function moveSeeders(ProgressBar $progress) |
|
91 | |||
92 | protected function moveConfig(ProgressBar $progress) : void |
||
101 | |||
102 | /** |
||
103 | * Just create directory |
||
104 | * @param $dir |
||
105 | */ |
||
106 | protected function createDir(string $dir) : void |
||
113 | |||
114 | /** |
||
115 | * Data from stubs file |
||
116 | * @param $nameFile |
||
117 | * @return bool|string |
||
118 | */ |
||
119 | protected function getContent(string $nameFile) : string |
||
123 | |||
124 | /** |
||
125 | * Get date normalize mow |
||
126 | * @return mixed |
||
127 | */ |
||
128 | protected function getDateNormalize() : string |
||
136 | } |
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: