We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
| 24 | class BackendController extends PluginEngine |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * @var ArticleRepository |
||
| 28 | */ |
||
| 29 | private $articles; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var ArticleCategoryRepository |
||
| 33 | */ |
||
| 34 | private $categories; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * BackendController constructor. |
||
| 38 | * |
||
| 39 | * @param ArticleRepository $repository |
||
| 40 | */ |
||
| 41 | public function __construct(ArticleRepository $repository, ArticleCategoryRepository $categories) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Display a listing of the resource. |
||
| 50 | * |
||
| 51 | * @return \Illuminate\Contracts\View\View|\Illuminate\Http\Response |
||
| 52 | */ |
||
| 53 | public function index() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Show the form for creating a new resource. |
||
| 60 | * |
||
| 61 | * @return \Illuminate\Contracts\View\View|\Illuminate\Http\Response |
||
| 62 | */ |
||
| 63 | public function create() |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Generate a form for editing or creating a model. |
||
| 70 | * |
||
| 71 | * @param Article $article model to be used. |
||
| 72 | * @return void |
||
|
|
|||
| 73 | */ |
||
| 74 | public function form(Article $article) |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Store a newly created resource in storage. |
||
| 81 | * |
||
| 82 | * @param Article $article |
||
| 83 | * @param \Illuminate\Http\Request $request |
||
| 84 | * @return \Illuminate\Http\Response |
||
| 85 | */ |
||
| 86 | View Code Duplication | public function store(Article $article, Request $request) |
|
| 96 | |||
| 97 | /** |
||
| 98 | * Display the specified resource. |
||
| 99 | * |
||
| 100 | * @param int $id |
||
| 101 | * @return \Illuminate\Http\Response |
||
| 102 | */ |
||
| 103 | public function show($id) |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Show the form for editing the specified resource. |
||
| 110 | * |
||
| 111 | * @param $slug |
||
| 112 | * @return \Illuminate\Contracts\View\View |
||
| 113 | */ |
||
| 114 | public function edit($slug) |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Update the specified resource in storage. |
||
| 121 | * |
||
| 122 | * @param \Illuminate\Http\Request $request |
||
| 123 | * @param $slug |
||
| 124 | * @return \Illuminate\Http\Response |
||
| 125 | * @internal param int $id |
||
| 126 | */ |
||
| 127 | View Code Duplication | public function update(Request $request, $slug) |
|
| 137 | |||
| 138 | /** |
||
| 139 | * Remove the specified resource from storage. |
||
| 140 | * |
||
| 141 | * @param int $id |
||
| 142 | * @return \Illuminate\Http\Response |
||
| 143 | */ |
||
| 144 | View Code Duplication | public function destroy($slug) |
|
| 154 | |||
| 155 | /** |
||
| 156 | * Category Index. |
||
| 157 | * @param ArticleCategoryRepository $categoryRepository |
||
| 158 | * @return \Illuminate\Contracts\View\View |
||
| 159 | */ |
||
| 160 | public function categories(ArticleCategoryRepository $categoryRepository) |
||
| 164 | |||
| 165 | /** |
||
| 166 | * @param Request $request |
||
| 167 | * @return \Illuminate\Http\RedirectResponse |
||
| 168 | */ |
||
| 169 | View Code Duplication | public function categories_store(Request $request) |
|
| 181 | |||
| 182 | /** |
||
| 183 | * @param int $id |
||
| 184 | * @param ArticleCategoryRepository $categoryRepository |
||
| 185 | * @return \Illuminate\Http\RedirectResponse |
||
| 186 | */ |
||
| 187 | public function categories_destroy(int $id, ArticleCategoryRepository $categoryRepository) |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Save the data for the menu to the database. |
||
| 200 | * |
||
| 201 | * @param Request $request |
||
| 202 | * @param Article $article |
||
| 203 | * @return bool |
||
| 204 | * @internal param Article $menu |
||
| 205 | */ |
||
| 206 | public function save(Request $request, Article $article) |
||
| 235 | } |
||
| 236 |
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.