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  | 
            ||
| 15 | class ConversationController extends Controller  | 
            ||
| 16 | { | 
            ||
| 17 | /**  | 
            ||
| 18 | * Show the conversation by its id.  | 
            ||
| 19 | *  | 
            ||
| 20 | * @return \Illuminate\Http\Response  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 21 | */  | 
            ||
| 22 | public function show(Request $request, string $slug, int $id)  | 
            ||
| 45 | |||
| 46 | /**  | 
            ||
| 47 | * Show the create form.  | 
            ||
| 48 | *  | 
            ||
| 49 | * @return \Illuminate\View\View  | 
            ||
| 50 | */  | 
            ||
| 51 | public function showCreateForm(): View  | 
            ||
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * Handle a conversation create request for the application.  | 
            ||
| 62 | *  | 
            ||
| 63 | * @param \Illuminate\Http\Request $request  | 
            ||
| 64 | *  | 
            ||
| 65 | * @return \Illuminate\Http\RedirectResponse  | 
            ||
| 66 | */  | 
            ||
| 67 | public function create(Request $request)  | 
            ||
| 92 | |||
| 93 | /**  | 
            ||
| 94 | * Handle a conversation update request for the application.  | 
            ||
| 95 | *  | 
            ||
| 96 | * @param \Illuminate\Http\Request $request  | 
            ||
| 97 | * @param string $slug The slug of the conversation to update.  | 
            ||
| 98 | * @param int $id The id of the conversation to update.  | 
            ||
| 99 | *  | 
            ||
| 100 | * @return \Illuminate\Http\RedirectResponse  | 
            ||
| 101 | */  | 
            ||
| 102 | public function update(Request $request, string $slug, int $id)  | 
            ||
| 115 | |||
| 116 | /**  | 
            ||
| 117 | * Handle the delete request for a conversation.  | 
            ||
| 118 | *  | 
            ||
| 119 | * @param string $slug The slug of the conversation to delete.  | 
            ||
| 120 | * @param int $id The id of the conversation to delete.  | 
            ||
| 121 | *  | 
            ||
| 122 | * @return \Illuminate\Http\RedirectResponse  | 
            ||
| 123 | */  | 
            ||
| 124 | public function delete(string $slug, int $id) : RedirectResponse  | 
            ||
| 139 | |||
| 140 | /**  | 
            ||
| 141 | * Get the current page for the conversation.  | 
            ||
| 142 | *  | 
            ||
| 143 | * @param \Illuminate\Http\Request $request  | 
            ||
| 144 | *  | 
            ||
| 145 | * @return int  | 
            ||
| 146 | */  | 
            ||
| 147 | protected function getCurrentPage(Request $request): int  | 
            ||
| 151 | }  | 
            ||
| 152 | 
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.