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 |
||
| 12 | class MenuItemAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var Menu |
||
| 16 | */ |
||
| 17 | private $menu; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param EntityManager $em The entity manager |
||
| 21 | * @param AclHelper $aclHelper The acl helper |
||
|
|
|||
| 22 | * @param Menu $menu |
||
| 23 | */ |
||
| 24 | View Code Duplication | public function __construct(EntityManager $em, AclHelper $aclHelper = null, Menu $menu) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Configure the visible columns |
||
| 36 | */ |
||
| 37 | public function buildFields() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get bundle name |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getBundleName() |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Get entity name |
||
| 58 | * |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function getEntityName() |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param QueryBuilder $qb |
||
| 68 | */ |
||
| 69 | public function adaptQueryBuilder(QueryBuilder $qb) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param array|object $item The item |
||
| 78 | * @param string $columnName The column name |
||
| 79 | * |
||
| 80 | * @return mixed |
||
| 81 | */ |
||
| 82 | public function getValue($item, $columnName) |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Return extra parameters for use in list actions. |
||
| 109 | * |
||
| 110 | * @return array |
||
| 111 | */ |
||
| 112 | public function getExtraParameters() |
||
| 116 | |||
| 117 | /** |
||
| 118 | * You can override this method to do some custom things you need to do when adding an entity |
||
| 119 | * |
||
| 120 | * @param object $entity |
||
| 121 | * |
||
| 122 | * @return mixed |
||
| 123 | */ |
||
| 124 | public function decorateNewEntity($entity) |
||
| 130 | |||
| 131 | public function getMenu() |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @return int |
||
| 138 | */ |
||
| 139 | public function getLimit() |
||
| 143 | } |
||
| 144 |
This check looks for
@paramannotations 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.