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 m6_hide_for_group extends \phpbb\db\migration\migration |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * {@inheritDoc} |
||
| 17 | */ |
||
| 18 | public function effectively_installed() |
||
| 22 | |||
| 23 | /** |
||
| 24 | * {@inheritDoc} |
||
| 25 | */ |
||
| 26 | static public function depends_on() |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Add the ACP settings module |
||
| 33 | * |
||
| 34 | * @return array Array of data update instructions |
||
| 35 | */ |
||
| 36 | View Code Duplication | public function update_data() |
|
| 51 | } |
||
| 52 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.