Warning when passing a nowdoc string to t()

Created on 26 May 2023, about 1 year ago
Updated 16 June 2023, about 1 year ago

Problem/Motivation

I get a warning from Drupal.Semantics.FunctionT.NotLiteralString if I pass a nowdoc string to t().

Steps to reproduce

    $help_text = $this->t(<<<'HTML'
      <p>
        For information about what an item is and how to complete it, click it in
        the list below.
      </p>
    HTML);

Note that unlike heredoc strings, which would have no quotes around the terminator like: <<<HTML, nowdoc strings do not allow variable interpolation, so they truly are string literals.

Proposed resolution

Allow translation of nowdoc strings.

✨ Feature request
Status

Closed: won't fix

Version

8.3

Component

Coder Sniffer

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024