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 |
||
| 11 | class CacheContextsCollector { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * {@inheritdoc} |
||
| 15 | */ |
||
| 16 | public function getVisitor(TypeInfo $info, array &$contexts) { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Collects the cache contexts from a type or field config. |
||
| 42 | * |
||
| 43 | * @param array|callable $contexts |
||
| 44 | * The cache contexts array or a callable to return cache contexts. |
||
| 45 | * |
||
| 46 | * @return array |
||
| 47 | * The collected cache contexts. |
||
| 48 | */ |
||
| 49 | protected function collectCacheContexts($contexts) { |
||
| 56 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.