These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace App\Http\Controllers; |
||
4 | |||
5 | use App\Events\GuitarWasCreated; |
||
6 | use App\Events\WarehouseWasUpdated; |
||
7 | use App\Guitar; |
||
8 | use App\Purchase; |
||
9 | use App\Rack; |
||
10 | use Illuminate\Http\Request; |
||
11 | |||
12 | class GuitarController extends Controller |
||
13 | { |
||
14 | /** |
||
15 | * Save the guitar. |
||
16 | * |
||
17 | * @param $id |
||
18 | */ |
||
19 | public function store($id, Request $request) |
||
20 | { |
||
21 | $purchase = Purchase::findOrFail($id); |
||
22 | if ( ! $purchase->hasArrived() || ! $purchase->isPendingStorage()) { |
||
23 | return response(['purchase' => ['The purchase has not yet arrived or doesn\'t require addition of guitars.']], |
||
24 | 422); |
||
25 | } |
||
26 | |||
27 | $this->validate($request, [ |
||
28 | 'rack_id' => 'required|exists:racks,id,make_id,' . $purchase->make_id, |
||
29 | 'model_id' => 'required|exists:models,id,make_id,' . $purchase->make_id, |
||
30 | 'colour' => 'required|string|max:255', |
||
31 | 'damaged' => 'boolean', |
||
32 | 'condition' => 'required_if:damaged,true', |
||
33 | 'price' => 'required|numeric|min:1', |
||
34 | ]); |
||
35 | |||
36 | $rack = Rack::find($request->input('rack_id')); |
||
37 | if ($rack->used >= $rack->capacity) { |
||
38 | return response(['rack_id' => ['The selected rack is full.']], 422); |
||
39 | } |
||
40 | |||
41 | $guitar = Guitar::create($request->only(['rack_id', 'model_id', 'colour', 'price']) + [ |
||
42 | 'make_id' => $purchase->make_id, |
||
43 | 'purchase_id' => $purchase->id, |
||
44 | 'damaged' => $request->input('damaged'), |
||
45 | 'condition' => $request->input('damaged') ? $request->input('condition') : null |
||
46 | ]); |
||
47 | |||
48 | event(new GuitarWasCreated($guitar)); |
||
49 | event(new WarehouseWasUpdated($rack->warehouse)); |
||
0 ignored issues
–
show
|
|||
50 | } |
||
51 | } |
||
52 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.