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 |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $title; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Identifier for the vault adapter to use. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $adapter; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Identifier for the lock adapter to use. |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | protected $lockAdapter = 'storage'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Identifier for the index merger to be used. |
||
| 34 | * |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | protected $indexMerger = 'standard'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Identifier for the conflict handler to use. |
||
| 41 | * |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | protected $conflictHandler = 'panicking'; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Identifier for the operation list builder to use. |
||
| 48 | * |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | protected $operationListBuilder = 'standard'; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Map with additional storageAdapter- or lockAdapter-specific settings. |
||
| 55 | * |
||
| 56 | * @var array |
||
| 57 | */ |
||
| 58 | protected $settings = []; |
||
| 59 | |||
| 60 | public function __construct(string $storageAdapter = 'unknown') |
||
| 65 | |||
| 66 | public function getTitle(): string |
||
| 70 | |||
| 71 | public function setTitle(string $title): VaultConfiguration |
||
| 77 | |||
| 78 | public function getAdapter(): string |
||
| 82 | |||
| 83 | public function setAdapter(string $adapter): VaultConfiguration |
||
| 89 | |||
| 90 | public function getLockAdapter(): string |
||
| 94 | |||
| 95 | public function setLockAdapter(string $lockAdapter): VaultConfiguration |
||
| 101 | |||
| 102 | public function getIndexMerger(): string |
||
| 106 | |||
| 107 | public function setIndexMerger(string $indexMerger): VaultConfiguration |
||
| 113 | |||
| 114 | public function getConflictHandler(): string |
||
| 118 | |||
| 119 | public function setConflictHandler(string $conflictHandler): VaultConfiguration |
||
| 125 | |||
| 126 | public function getOperationListBuilder(): string |
||
| 130 | |||
| 131 | public function setOperationListBuilder(string $operationListBuilder): VaultConfiguration |
||
| 137 | |||
| 138 | public function getSettings(): array |
||
| 142 | |||
| 143 | public function getSetting(string $name) |
||
| 147 | |||
| 148 | public function setSettings(array $settings): VaultConfiguration |
||
| 154 | |||
| 155 | public function setSetting(string $name, $value): VaultConfiguration |
||
| 161 | |||
| 162 | /** |
||
| 163 | * {@inheritdoc} |
||
| 164 | */ |
||
| 165 | public function exchangeArray(array $array) |
||
| 178 | |||
| 179 | /** |
||
| 180 | * {@inheritdoc} |
||
| 181 | */ |
||
| 182 | public function getArrayCopy() |
||
| 186 | |||
| 187 | public static function loadValidatorMetadata(ClassMetadata $metadata) |
||
| 196 | } |
||
| 197 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.