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 TestCommand extends Command |
||
13 | { |
||
14 | /** |
||
15 | * The name and signature of the console command. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $signature = 'test {--without-tty : Disable output to TTY}'; |
||
20 | |||
21 | /** |
||
22 | * The console command description. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $description = 'Run the application tests'; |
||
27 | |||
28 | /** |
||
29 | * The arguments to be used while calling phpunit. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $arguments = [ |
||
34 | '--printer', |
||
35 | 'NunoMaduro\Collision\Adapters\Phpunit\Printer', |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * Create a new command instance. |
||
40 | * |
||
41 | * @return void |
||
|
|||
42 | */ |
||
43 | public function __construct() |
||
49 | |||
50 | /** |
||
51 | * Execute the console command. |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | public function handle() |
||
85 | |||
86 | /** |
||
87 | * Get the PHP binary to execute. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function binary() |
||
99 | |||
100 | /** |
||
101 | * Get the array of arguments for running PHPUnit. |
||
102 | * |
||
103 | * @param array $options |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | protected function phpunitArguments($options) |
||
119 | |||
120 | /** |
||
121 | * Gets an array with phpunit envs detected on the phpunit.xml file. |
||
122 | * |
||
123 | * @return array |
||
124 | */ |
||
125 | protected function phpunitEnvs() |
||
162 | |||
163 | /** |
||
164 | * Loads the environment file if it exists otherwise returns empty array |
||
165 | * |
||
166 | * @param $environment |
||
167 | * @return array |
||
168 | */ |
||
169 | protected function fromEnvFile($environment) |
||
176 | } |
||
177 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.