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 |
||
| 16 | class CallController extends Controller |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * This action is used to render the list of calls associated with the given entity |
||
| 20 | * on the view page of this entity |
||
| 21 | * |
||
| 22 | * @Route("/activity/view/{entityClass}/{entityId}", name="orocrm_call_activity_view") |
||
| 23 | * @AclAncestor("orocrm_call_view") |
||
| 24 | * @Template |
||
| 25 | */ |
||
| 26 | public function activityAction($entityClass, $entityId) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @Route("/create", name="orocrm_call_create") |
||
| 35 | * @Template("OroCRMCallBundle:Call:update.html.twig") |
||
| 36 | * @Acl( |
||
| 37 | * id="orocrm_call_create", |
||
| 38 | * type="entity", |
||
| 39 | * permission="CREATE", |
||
| 40 | * class="OroCRMCallBundle:Call" |
||
| 41 | * ) |
||
| 42 | */ |
||
| 43 | public function createAction() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @Route("/update/{id}", name="orocrm_call_update", requirements={"id"="\d+"}) |
||
| 65 | * @Template |
||
| 66 | * @Acl( |
||
| 67 | * id="orocrm_call_update", |
||
| 68 | * type="entity", |
||
| 69 | * permission="EDIT", |
||
| 70 | * class="OroCRMCallBundle:Call" |
||
| 71 | * ) |
||
| 72 | */ |
||
| 73 | public function updateAction(Call $entity) |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @Route(name="orocrm_call_index") |
||
| 82 | * @Template |
||
| 83 | * @Acl( |
||
| 84 | * id="orocrm_call_view", |
||
| 85 | * type="entity", |
||
| 86 | * permission="VIEW", |
||
| 87 | * class="OroCRMCallBundle:Call" |
||
| 88 | * ) |
||
| 89 | */ |
||
| 90 | public function indexAction() |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @Route("/view/{id}", name="orocrm_call_view") |
||
| 99 | * @Template |
||
| 100 | */ |
||
| 101 | public function viewAction(Call $entity) |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @Route("/widget", name="orocrm_call_widget_calls") |
||
| 110 | * @Template |
||
| 111 | * @AclAncestor("orocrm_call_view") |
||
| 112 | * |
||
| 113 | * @param Request $request |
||
| 114 | * @return array |
||
| 115 | */ |
||
| 116 | public function callsAction(Request $request) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @Route("/base-widget", name="orocrm_call_base_widget_calls") |
||
| 125 | * @Template |
||
| 126 | * @AclAncestor("orocrm_call_view") |
||
| 127 | */ |
||
| 128 | public function baseCallsAction(Request $request) |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @Route( |
||
| 137 | * "/widget/info/{id}/{renderContexts}", |
||
| 138 | * name="orocrm_call_widget_info", |
||
| 139 | * requirements={"id"="\d+", "renderContexts"="\d+"}, |
||
| 140 | * defaults={"renderContexts"=true} |
||
| 141 | * ) |
||
| 142 | * @Template("OroCRMCallBundle:Call/widget:info.html.twig") |
||
| 143 | * @AclAncestor("orocrm_call_view") |
||
| 144 | */ |
||
| 145 | public function infoAction(Call $entity, $renderContexts) |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @param Call $entity |
||
| 156 | * @param string $formAction |
||
| 157 | * |
||
| 158 | * @return array |
||
| 159 | */ |
||
| 160 | View Code Duplication | protected function update(Call $entity, $formAction) |
|
| 183 | |||
| 184 | /** |
||
| 185 | * Get target entity |
||
| 186 | * |
||
| 187 | * @return object|null |
||
| 188 | */ |
||
| 189 | View Code Duplication | protected function getTargetEntity() |
|
| 200 | } |
||
| 201 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.