@return string is wrong because the $templateEngine variable could be an instance of the \Magento\Framework\View\TemplateEngine\Xhtml class, and its render() method returns an instance of the \Magento\Framework\View\TemplateEngine\Xhtml\ResultInterface (particularly, \Magento\Ui\TemplateEngine\Xhtml\Result), not a string: