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 |
||
| 31 | class IssueController extends Controller |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * Project issue index page (List project issues) |
||
| 35 | * |
||
| 36 | * @param Project $project |
||
| 37 | * @param Issue $issue |
||
| 38 | * @param CommentForm $form |
||
| 39 | * |
||
| 40 | * @return \Illuminate\View\View |
||
| 41 | */ |
||
| 42 | 17 | public function getIndex(Project $project, Issue $issue, CommentForm $form) |
|
| 68 | |||
| 69 | /** |
||
| 70 | * Ajax: Assign new user to an issue |
||
| 71 | * |
||
| 72 | * @param Issue $issue |
||
| 73 | * @param Request $request |
||
| 74 | * |
||
| 75 | * @return \Symfony\Component\HttpFoundation\Response |
||
| 76 | */ |
||
| 77 | 1 | View Code Duplication | public function postAssign(Issue $issue, Request $request) |
| 86 | |||
| 87 | /** |
||
| 88 | * Ajax: save comment |
||
| 89 | * |
||
| 90 | * @param Comment $comment |
||
| 91 | * @param Request $request |
||
| 92 | * |
||
| 93 | * @return \Symfony\Component\HttpFoundation\Response |
||
| 94 | */ |
||
| 95 | 1 | public function postEditComment(Comment $comment, Request $request) |
|
| 105 | |||
| 106 | /** |
||
| 107 | * To add new comment to an issue |
||
| 108 | * |
||
| 109 | * @param Project $project |
||
| 110 | * @param Issue $issue |
||
| 111 | * @param Comment $comment |
||
| 112 | * @param FormRequest\Comment $request |
||
| 113 | * |
||
| 114 | * @return \Illuminate\Http\RedirectResponse |
||
| 115 | */ |
||
| 116 | 4 | public function getAddComment(Project $project, Issue $issue, Comment $comment, FormRequest\Comment $request) |
|
| 126 | |||
| 127 | /** |
||
| 128 | * Ajax: to delete a comment |
||
| 129 | * |
||
| 130 | * @param Comment $comment |
||
| 131 | * |
||
| 132 | * @return \Symfony\Component\HttpFoundation\Response |
||
| 133 | */ |
||
| 134 | 1 | public function getDeleteComment(Comment $comment) |
|
| 140 | |||
| 141 | /** |
||
| 142 | * New issue form |
||
| 143 | * |
||
| 144 | * @param Project $project |
||
| 145 | * @param IssueForm $form |
||
| 146 | * |
||
| 147 | * @return \Illuminate\View\View |
||
| 148 | */ |
||
| 149 | 5 | public function getNew(Project $project, IssueForm $form) |
|
| 157 | |||
| 158 | /** |
||
| 159 | * To create a new issue |
||
| 160 | * |
||
| 161 | * @param Project $project |
||
| 162 | * @param Issue $issue |
||
| 163 | * @param FormRequest\Issue $request |
||
| 164 | * |
||
| 165 | * @return \Illuminate\Http\RedirectResponse |
||
| 166 | */ |
||
| 167 | 2 | View Code Duplication | public function postNew(Project $project, Issue $issue, FormRequest\Issue $request) |
| 176 | |||
| 177 | /** |
||
| 178 | * Edit an existing issue form |
||
| 179 | * |
||
| 180 | * @param Project $project |
||
| 181 | * @param Issue $issue |
||
| 182 | * @param IssueForm $form |
||
| 183 | * |
||
| 184 | * @return \Illuminate\View\View |
||
| 185 | */ |
||
| 186 | 2 | public function getEdit(Project $project, Issue $issue, IssueForm $form) |
|
| 201 | |||
| 202 | /** |
||
| 203 | * To update an existing issue details |
||
| 204 | * |
||
| 205 | * @param Project $project |
||
| 206 | * @param Issue $issue |
||
| 207 | * @param FormRequest\Issue $request |
||
| 208 | * |
||
| 209 | * @return \Illuminate\Http\RedirectResponse |
||
| 210 | */ |
||
| 211 | 1 | View Code Duplication | public function postEdit(Project $project, Issue $issue, FormRequest\Issue $request) |
| 220 | |||
| 221 | /** |
||
| 222 | * To close or reopen an issue |
||
| 223 | * |
||
| 224 | * @param Project $project |
||
| 225 | * @param Issue $issue |
||
| 226 | * @param int $status |
||
| 227 | * |
||
| 228 | * @return \Illuminate\Http\RedirectResponse |
||
| 229 | */ |
||
| 230 | 2 | public function getClose(Project $project, Issue $issue, $status = 0) |
|
| 244 | |||
| 245 | /** |
||
| 246 | * To upload an attachment file |
||
| 247 | * |
||
| 248 | * @param Project $project |
||
| 249 | * @param Attachment $attachment |
||
| 250 | * @param Request $request |
||
| 251 | * |
||
| 252 | * @return \Symfony\Component\HttpFoundation\Response |
||
| 253 | */ |
||
| 254 | 3 | public function postUploadAttachment(Project $project, Attachment $attachment, Request $request) |
|
| 285 | |||
| 286 | /** |
||
| 287 | * Ajax: to remove an attachment file |
||
| 288 | * |
||
| 289 | * @param Project $project |
||
| 290 | * @param Attachment $attachment |
||
| 291 | * @param Request $request |
||
| 292 | * |
||
| 293 | * @return \Symfony\Component\HttpFoundation\Response |
||
| 294 | */ |
||
| 295 | 1 | public function postRemoveAttachment(Project $project, Attachment $attachment, Request $request) |
|
| 301 | |||
| 302 | /** |
||
| 303 | * Display an attachment file such as image |
||
| 304 | * |
||
| 305 | * @param Project $project |
||
| 306 | * @param Issue $issue |
||
| 307 | * @param Attachment $attachment |
||
| 308 | * @param Request $request |
||
| 309 | * |
||
| 310 | * @return Response |
||
| 311 | */ |
||
| 312 | 2 | public function getDisplayAttachment(Project $project, Issue $issue, Attachment $attachment, Request $request) |
|
| 345 | |||
| 346 | /** |
||
| 347 | * Download an attachment file |
||
| 348 | * |
||
| 349 | * @param Project $project |
||
| 350 | * @param Issue $issue |
||
| 351 | * @param Attachment $attachment |
||
| 352 | * |
||
| 353 | * @return \Symfony\Component\HttpFoundation\BinaryFileResponse |
||
| 354 | */ |
||
| 355 | 1 | public function getDownloadAttachment(Project $project, Issue $issue, Attachment $attachment) |
|
| 364 | |||
| 365 | /** |
||
| 366 | * Ajax: move an issue to another project |
||
| 367 | * |
||
| 368 | * @param Issue $issue |
||
| 369 | * @param Request $request |
||
| 370 | * |
||
| 371 | * @return \Symfony\Component\HttpFoundation\Response |
||
| 372 | */ |
||
| 373 | 1 | public function postChangeProject(Issue $issue, Request $request) |
|
| 379 | } |
||
| 380 |
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@propertyannotation 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.