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 |
||
10 | class TranslatorMenuAdaptor implements MenuAdaptorInterface |
||
11 | { |
||
12 | /** |
||
13 | * In this method you can add children for a specific parent, but also remove and change the already created children |
||
14 | * |
||
15 | * @param MenuBuilder $menu The MenuBuilder |
||
16 | * @param MenuItem[] &$children The current children |
||
17 | * @param MenuItem $parent The parent Menu item |
||
|
|||
18 | * @param Request $request The Request |
||
19 | */ |
||
20 | public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null) |
||
64 | } |
||
65 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.