The return type could not be reliably inferred; please add a @return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a @return
annotation as described here.
Loading history...
9
{
10
$result = $this->getComponents('Widgets');
11
12
if ($result instanceof UnsavedRelationList) {
13
// Setup a proper UnsavedRelationList so that an page using this extension can be created
14
// programmatically and have unsaved/saved BaseElement records attached to it.
15
16
// NOTE(SilbinaryWolf): Able to set protected var 'dataClass' due to ViewableData using magic get/set for properties
17
$result->dataClass = 'BaseElement'; // Change from 'Widget' to 'BaseElement'
18
return $result;
19
}
20
21
$list = new HasManyList('BaseElement', $result->getForeignKey());
22
$list->setDataModel($this->model);
23
$list->sort('Sort ASC');
24
25
$list = $list->forForeignID($this->ID);
26
$list = $list->filter(array(
27
'Enabled' => 1
28
));
29
30
return $list;
31
}
32
33
/**
34
* @return HasManyList
35
*/
36
public function ItemsToRender() {
37
return $this->Elements();
38
}
39
40
/**
41
* Return an ArrayList of pages with the Element Page Extension
The expression $classes of type null|array is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
$collection=json_decode($data,true);if(!is_array($collection)){thrownew\RuntimeException('$collection must be an array.');}foreach($collectionas$item){/** ... */}
If you are sure that the expression is traversable, you might want to add a
doc comment cast to improve IDE auto-completion and static analysis:
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.