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 |
||
26 | class Installer |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Does some routine installation tasks so people don't have to. |
||
31 | * |
||
32 | * @param \Composer\Script\Event $event The composer event object. |
||
33 | * |
||
34 | * @return void |
||
35 | */ |
||
36 | public static function postInstall(Event $event) |
||
77 | |||
78 | /** |
||
79 | * Create the config/app.php file if it does not exist. |
||
80 | * |
||
81 | * @param string $dir The application's root directory. |
||
82 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
83 | * |
||
84 | * @return void |
||
85 | */ |
||
86 | View Code Duplication | public static function createAppConfig($dir, $io) |
|
95 | |||
96 | /** |
||
97 | * Create the config/database.php file if it does not exist. |
||
98 | * |
||
99 | * @param string $dir The application's root directory. |
||
100 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | View Code Duplication | public static function createDatabaseConfig($dir, $io) |
|
105 | { |
||
106 | $databaseConfig = $dir . '/config/database.php'; |
||
107 | $defaultConfig = $dir . '/config/database.default.php'; |
||
108 | if (!file_exists($databaseConfig)) { |
||
109 | copy($defaultConfig, $databaseConfig); |
||
110 | $io->write('Created `config/database.php` file'); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Create the config/email.php file if it does not exist. |
||
116 | * |
||
117 | * @param string $dir The application's root directory. |
||
118 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
119 | * |
||
120 | * @return void |
||
121 | */ |
||
122 | View Code Duplication | public static function createEmailConfig($dir, $io) |
|
123 | { |
||
124 | $databaseConfig = $dir . '/config/email.php'; |
||
125 | $defaultConfig = $dir . '/config/email.default.php'; |
||
126 | if (!file_exists($databaseConfig)) { |
||
127 | copy($defaultConfig, $databaseConfig); |
||
128 | $io->write('Created `config/email.php` file'); |
||
129 | } |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Create the `logs` and `tmp` directories. |
||
134 | * |
||
135 | * @param string $dir The application's root directory. |
||
136 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
137 | * @return void |
||
138 | */ |
||
139 | public static function createWritableDirectories($dir, $io) |
||
160 | |||
161 | /** |
||
162 | * Create the config/recaptcha.php file if it does not exist. |
||
163 | * |
||
164 | * @param string $dir The application's root directory. |
||
165 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
166 | * |
||
167 | * @return void |
||
168 | */ |
||
169 | View Code Duplication | public static function createRecaptchaConfig($dir, $io) |
|
178 | |||
179 | /** |
||
180 | * Set globally writable permissions on the "tmp" and "logs" directory. |
||
181 | * |
||
182 | * This is not the most secure default, but it gets people up and running quickly. |
||
183 | * |
||
184 | * @param string $dir The application's root directory. |
||
185 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
186 | * @return void |
||
187 | */ |
||
188 | public static function setFolderPermissions($dir, $io) |
||
225 | |||
226 | /** |
||
227 | * Set the datasources.default.database value in the application's config file. |
||
228 | * |
||
229 | * @param string $dir The application's root directory. |
||
230 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
231 | * |
||
232 | * @return void |
||
233 | */ |
||
234 | View Code Duplication | public static function setDatabaseName($dir, $io) |
|
256 | |||
257 | /** |
||
258 | * Set the security.salt value in the application's config file. |
||
259 | * |
||
260 | * @param string $dir The application's root directory. |
||
261 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
262 | * @return void |
||
263 | */ |
||
264 | View Code Duplication | public static function setSecuritySalt($dir, $io) |
|
286 | |||
287 | /** |
||
288 | * Set up the admin and member password for the database. |
||
289 | * |
||
290 | * @param string $dir The application's root directory. |
||
291 | * @param \Composer\IO\IOInterface $io IO interface to write to console. |
||
292 | * @param string $newKey The new security.salt. |
||
293 | * |
||
294 | * @return void |
||
295 | */ |
||
296 | public static function setAccountPassword($dir, $io, $newKey = null) |
||
340 | } |
||
341 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.