I changed it like you suggested:

```php
        $messagesToPrint = array();
        $self            = $this;
        array_walk_recursive($messages, function ($item) use (&$messagesToPrint, $self) {
            if (null !== ($translator = $self->getTranslator())) {
                $item = $translator->translate(
                    $item, $self->getTranslatorTextDomain()
                );
            }
            $escapeHtml = $self->getEscapeHtmlHelper();
            $messagesToPrint[] = $escapeHtml($item);
        });
```

But then I get an error:

Fatal error: Call to protected method Zend\Form\View\Helper\AbstractHelper::getEscapeHtmlHelper() from context '' in /home/devhost/myproject/vendor/zendframework/zendframework/library/Zend/Form/View/Helper/FormElementErrors.php on line 157