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 |
||
32 | class IssueController extends Controller |
||
33 | { |
||
34 | /** |
||
35 | * Project issue index page (List project issues). |
||
36 | * |
||
37 | * @param Project $project |
||
38 | * @param Issue $issue |
||
39 | * @param CommentForm $form |
||
40 | * |
||
41 | * @return \Illuminate\View\View |
||
42 | */ |
||
43 | 16 | public function getIndex(Project $project, Issue $issue, CommentForm $form) |
|
69 | |||
70 | 1 | /** |
|
71 | 1 | * Ajax: Assign new user to an issue. |
|
72 | 1 | * |
|
73 | * @param Issue $issue |
||
74 | * @param Request $request |
||
75 | 1 | * |
|
76 | * @return \Symfony\Component\HttpFoundation\Response |
||
77 | */ |
||
78 | View Code Duplication | public function postAssign(Issue $issue, Request $request) |
|
87 | |||
88 | 1 | /** |
|
89 | 1 | * Ajax: save comment. |
|
90 | 1 | * |
|
91 | 1 | * @param Comment $comment |
|
92 | * @param Request $request |
||
93 | * |
||
94 | 1 | * @return \Symfony\Component\HttpFoundation\Response |
|
95 | */ |
||
96 | public function postEditComment(Comment $comment, Request $request) |
||
106 | |||
107 | 4 | /** |
|
108 | * To add new comment to an issue. |
||
109 | 4 | * |
|
110 | 4 | * @param Project $project |
|
111 | 4 | * @param Issue $issue |
|
112 | 4 | * @param Comment $comment |
|
113 | * @param FormRequest\Comment $request |
||
114 | 4 | * |
|
115 | 4 | * @return \Illuminate\Http\RedirectResponse |
|
116 | */ |
||
117 | public function getAddComment(Project $project, Issue $issue, Comment $comment, FormRequest\Comment $request) |
||
127 | 1 | ||
128 | /** |
||
129 | 1 | * Ajax: to delete a comment. |
|
130 | * |
||
131 | * @param Comment $comment |
||
132 | * |
||
133 | * @return \Symfony\Component\HttpFoundation\Response |
||
134 | */ |
||
135 | public function getDeleteComment(Comment $comment) |
||
141 | |||
142 | 5 | /** |
|
143 | 5 | * New issue form. |
|
144 | 5 | * |
|
145 | 5 | * @param Project $project |
|
146 | * @param IssueForm $form |
||
147 | * |
||
148 | * @return \Illuminate\View\View |
||
149 | */ |
||
150 | public function getNew(Project $project, IssueForm $form) |
||
158 | 2 | ||
159 | /** |
||
160 | 2 | * To create a new issue. |
|
161 | 2 | * |
|
162 | 2 | * @param Project $project |
|
163 | * @param Issue $issue |
||
164 | 2 | * @param FormRequest\Issue $request |
|
165 | 2 | * |
|
166 | * @return \Illuminate\Http\RedirectResponse |
||
167 | */ |
||
168 | View Code Duplication | public function postNew(Project $project, Issue $issue, FormRequest\Issue $request) |
|
177 | 2 | ||
178 | /** |
||
179 | * Edit an existing issue form. |
||
180 | 2 | * |
|
181 | 1 | * @param Project $project |
|
182 | 1 | * @param Issue $issue |
|
183 | * @param IssueForm $form |
||
184 | * |
||
185 | 2 | * @return \Illuminate\View\View |
|
186 | 2 | */ |
|
187 | 2 | public function getEdit(Project $project, Issue $issue, IssueForm $form) |
|
202 | 1 | ||
203 | /** |
||
204 | 1 | * To update an existing issue details. |
|
205 | 1 | * |
|
206 | 1 | * @param Project $project |
|
207 | * @param Issue $issue |
||
208 | 1 | * @param FormRequest\Issue $request |
|
209 | 1 | * |
|
210 | * @return \Illuminate\Http\RedirectResponse |
||
211 | */ |
||
212 | View Code Duplication | public function postEdit(Project $project, Issue $issue, FormRequest\Issue $request) |
|
221 | 2 | ||
222 | /** |
||
223 | 2 | * To close or reopen an issue. |
|
224 | 2 | * |
|
225 | * @param Project $project |
||
226 | 1 | * @param Issue $issue |
|
227 | * @param int $status |
||
228 | * |
||
229 | 2 | * @return \Illuminate\Http\RedirectResponse |
|
230 | 2 | */ |
|
231 | public function getClose(Project $project, Issue $issue, $status = 0) |
||
245 | 3 | ||
246 | /** |
||
247 | * To upload an attachment file. |
||
248 | 3 | * |
|
249 | * @param Project $project |
||
250 | * @param Attachment $attachment |
||
251 | * @param Request $request |
||
252 | 3 | * |
|
253 | * @return \Symfony\Component\HttpFoundation\Response |
||
254 | */ |
||
255 | public function postUploadAttachment(Project $project, Attachment $attachment, Request $request) |
||
286 | 1 | ||
287 | /** |
||
288 | 1 | * Ajax: to remove an attachment file. |
|
289 | * |
||
290 | 1 | * @param Project $project |
|
291 | * @param Attachment $attachment |
||
292 | * @param Request $request |
||
293 | * |
||
294 | * @return \Symfony\Component\HttpFoundation\Response |
||
295 | */ |
||
296 | public function postRemoveAttachment(Project $project, Attachment $attachment, Request $request) |
||
302 | |||
303 | 2 | /** |
|
304 | * Display an attachment file such as image. |
||
305 | 2 | * |
|
306 | 2 | * @param Project $project |
|
307 | * @param Issue $issue |
||
308 | 2 | * @param Attachment $attachment |
|
309 | 2 | * @param Request $request |
|
310 | 2 | * |
|
311 | 2 | * @return Response |
|
312 | 2 | */ |
|
313 | public function getDisplayAttachment(Project $project, Issue $issue, Attachment $attachment, Request $request) |
||
346 | 1 | ||
347 | /** |
||
348 | 1 | * Download an attachment file. |
|
349 | 1 | * |
|
350 | * @param Project $project |
||
351 | 1 | * @param Issue $issue |
|
352 | * @param Attachment $attachment |
||
353 | 1 | * |
|
354 | * @return \Symfony\Component\HttpFoundation\BinaryFileResponse |
||
355 | */ |
||
356 | public function getDownloadAttachment(Project $project, Issue $issue, Attachment $attachment) |
||
365 | |||
366 | 1 | /** |
|
367 | * Ajax: move an issue to another project. |
||
368 | 1 | * |
|
369 | * @param Issue $issue |
||
370 | * @param Request $request |
||
371 | * |
||
372 | * @return \Symfony\Component\HttpFoundation\Response |
||
373 | */ |
||
374 | public function postChangeProject(Issue $issue, Request $request) |
||
380 | |||
381 | /** |
||
382 | * Ajax: change status of an issue. |
||
383 | * |
||
384 | * @param Issue $issue |
||
385 | * @param Request $request |
||
386 | * |
||
387 | * @return \Symfony\Component\HttpFoundation\Response |
||
388 | */ |
||
389 | public function postChangeKanbanTag(Issue $issue, Request $request) |
||
398 | } |
||
399 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.