nette / application

🏆 A full-stack component-based MVC kernel for PHP that helps you write powerful and modern web applications. Write less, have cleaner code and your work will bring you joy.

Home Page:https://doc.nette.org/application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flashMessage() accepting general interface

dakur opened this issue · comments

commented
  • Is your feature request related to a problem? Please describe.

Rendering HtmlStringable in flash message.

  • Explain your intentions.

We have class SanitizedHtml which implements HtmlStringable and which we use to render safe HTML into template. Often, we need to render HTML in flash message as well (e.g. bold text). That's where we call $this->flashMessage($sanitizedHtmlInstance)

But phpstan complains Parameter #1 $message of method Nette\Application\UI\Control::flashMessage() expects stdClass|string, Nette\HtmlStringable given.

I suggest making an interface for flash message parameter objects so that the type would be \stdClass|string|FlashMessage which our SanitizedHtml could implement then.

  • It's up to you to make a strong case to convince the project's developers of the merits of this feature.
    😅
commented

Or maybe just add HtmlStringable instead of creating FlashMessage interface..