These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class DMSUploadField_ItemHandler extends UploadField_ItemHandler |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | private static $allowed_actions = array( |
||
0 ignored issues
–
show
|
|||
6 | 'delete', |
||
7 | 'edit', |
||
8 | 'EditForm', |
||
9 | ); |
||
10 | |||
11 | /** |
||
12 | * Gets a DMS document by its ID |
||
13 | * |
||
14 | * @return DMSDocument |
||
0 ignored issues
–
show
|
|||
15 | */ |
||
16 | public function getItem() |
||
17 | { |
||
18 | return DMSDocument::get()->byId($this->itemID); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return Form |
||
23 | */ |
||
24 | public function EditForm() |
||
25 | { |
||
26 | $file = $this->getItem(); |
||
27 | |||
28 | // Get form components |
||
29 | $fields = $this->parent->getDMSFileEditFields($file); |
||
0 ignored issues
–
show
The method
getDMSFileEditFields() does not exist on UploadField . Did you maybe mean getFileEditFields() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
30 | $actions = $this->parent->getDMSFileEditActions($file); |
||
0 ignored issues
–
show
The method
getDMSFileEditActions() does not exist on UploadField . Did you maybe mean getFileEditActions() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
31 | $validator = $this->parent->getDMSFileEditValidator($file); |
||
0 ignored issues
–
show
The method
getDMSFileEditValidator() does not exist on UploadField . Did you maybe mean getFileEditValidator() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
32 | $form = new Form( |
||
33 | $this, |
||
0 ignored issues
–
show
$this is of type this<DMSUploadField_ItemHandler> , but the function expects a object<Controller> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
34 | __FUNCTION__, |
||
35 | $fields, |
||
36 | $actions, |
||
37 | $validator |
||
38 | ); |
||
39 | $form->loadDataFrom($file); |
||
0 ignored issues
–
show
It seems like
$file defined by $this->getItem() on line 26 can be null ; however, Form::loadDataFrom() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
Loading history...
|
|||
40 | |||
41 | return $form; |
||
42 | } |
||
43 | } |
||
44 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.