Ha team phpstan-drupal!
Today we got the following error:
TypeError: Drupal\\Component\\Utility\\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /var/www/html/app/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238 in Drupal\\Component\\Utility\\Html::escape() (line 433 of /var/www/html/app/core/lib/Drupal/Component/Utility/Html.php
And a custom module was the cause, FormattableMarkup (and TranslatableMarkup) allows null in the $arguments array.
This should be illigal, since they put the value (straight) trough Html::escape, where the argument is typed to a non nullable string
tldr:
places that call Html::escape should be checked to be string/stringable
can we type-hint FormattableMarkup (and TranslatableMarkup) so we can staticly analyze these places
Ha team phpstan-drupal!
Today we got the following error:
And a custom module was the cause, FormattableMarkup (and TranslatableMarkup) allows
nullin the$argumentsarray.This should be illigal, since they put the value (straight) trough Html::escape, where the argument is typed to a non nullable
stringtldr:
places that call
Html::escapeshould be checked to be string/stringablecan we type-hint FormattableMarkup (and TranslatableMarkup) so we can staticly analyze these places