The expression return $formField->setParent($this) also could return the type SilverStripe\Forms\FormF...UserFormsFieldContainer which is incompatible with the return type mandated by SilverStripe\UserForms\F...ontainer::processNext() of SilverStripe\UserForms\F...\EditableContainerField.
The expression return $this returns the type SilverStripe\UserForms\F...ield\UserFormsFieldList which is incompatible with the return type mandated by SilverStripe\UserForms\F...ontainer::processNext() of SilverStripe\UserForms\F...\EditableContainerField.
In the issue above, the returned value is violating the contract defined by the
mentioned interface.
Let's take a look at an example:
interfaceHasName{/** @return string */publicfunctiongetName();}className{public$name;}classUserimplementsHasName{/** @return string|Name */publicfunctiongetName(){returnnewName('foo');// This is a violation of the ``HasName`` interface// which only allows a string value to be returned.}}
Loading history...
27
}
28
29
public function getParent()
30
{
31
// Field list does not have a parent
32
return null;
33
}
34
35
public function setParent(UserFormsFieldContainer $parent)
36
{
37
return $this;
38
}
39
40
/**
41
* Remove all empty steps
42
*/
43
public function clearEmptySteps()
44
{
45
foreach ($this as $field) {
46
if ($field instanceof UserFormsStepField && count($field->getChildren()) === 0) {