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 Encore\Admin\Form\Field; |
||
4 | |||
5 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
||
6 | |||
7 | class MultipleImage extends MultipleFile |
||
8 | { |
||
9 | use ImageField; |
||
10 | |||
11 | /** |
||
12 | * {@inheritdoc} |
||
13 | */ |
||
14 | protected $view = 'admin::form.multiplefile'; |
||
15 | |||
16 | /** |
||
17 | * Validation rules. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $rules = 'image'; |
||
22 | |||
23 | /** |
||
24 | * Prepare for each file. |
||
25 | * |
||
26 | * @param UploadedFile $image |
||
27 | * |
||
28 | * @return mixed|string |
||
29 | */ |
||
30 | protected function prepareForeach(UploadedFile $image = null) |
||
31 | { |
||
32 | $this->name = $this->getStoreName($image); |
||
33 | |||
34 | $this->callInterventionMethods($image->getRealPath()); |
||
35 | |||
36 | /* return tap($this->upload($image), function () { |
||
37 | $this->name = null; |
||
38 | }); */ |
||
39 | |||
40 | /* Copied from single image prepare section and made necessary changes so the return |
||
41 | value is same as before, but now thumbnails are saved to the disk as well. */ |
||
42 | |||
43 | $path = $this->upload($image); |
||
0 ignored issues
–
show
|
|||
44 | $this->uploadAndDeleteOriginalThumbnail($image); |
||
0 ignored issues
–
show
It seems like
$image defined by parameter $image on line 30 can be null ; however, Encore\Admin\Form\Field\...leteOriginalThumbnail() does not accept null , maybe add an additional type check?
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null. We recommend to add an additional type check (or disallow null for the parameter): function notNullable(stdClass $x) { }
// Unsafe
function withoutCheck(stdClass $x = null) {
notNullable($x);
}
// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
if ($x instanceof stdClass) {
notNullable($x);
}
}
// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
notNullable($x);
}
Loading history...
|
|||
45 | $this->name = null; |
||
46 | |||
47 | return $path; |
||
48 | } |
||
49 | } |
||
50 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):