The expression $this->val(); of type dokuwiki\Form\HTMLElement|string adds the type dokuwiki\Form\HTMLElement to the return on line 29 which is incompatible with the return type declared by the abstract method dokuwiki\Form\Element::toHTML of type string.