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 PopupAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator |
||
11 | { |
||
12 | /** |
||
13 | * @param EntityManager $em The entity manager |
||
14 | * @param AclHelper $aclHelper The acl helper |
||
|
|||
15 | */ |
||
16 | View Code Duplication | public function __construct(EntityManager $em, AclHelper $aclHelper = null) |
|
24 | |||
25 | /** |
||
26 | * Configure the visible columns |
||
27 | */ |
||
28 | public function buildFields() |
||
36 | |||
37 | /** |
||
38 | * Build filters for admin list |
||
39 | */ |
||
40 | public function buildFilters() |
||
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 object|array $item |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function canEdit($item) |
||
75 | |||
76 | /** |
||
77 | * Configure if it's possible to delete the given $item |
||
78 | * |
||
79 | * @param object|array $item |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | public function canDelete($item) |
||
87 | |||
88 | /** |
||
89 | * Configure if it's possible to add new items |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | public function canAdd() |
||
97 | } |
||
98 |
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.