Only string literals should be passed to t() where possible

Created on 28 July 2020, almost 5 years ago
Updated 29 January 2025, 3 months ago

Problem/Motivation

After running phpcs for Drupal best practices, found the following issues:

phpcs --standard=DrupalPractice,Drupal .

FILE: /var/www/html/drupal_contrib/web/modules/custom/module_missing_message_fixer/src/ModuleMissingMessageFixer.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
 112 | WARNING | Line exceeds 80 characters; contains 82 characters
 117 | WARNING | Line exceeds 80 characters; contains 82 characters
 138 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 138 | WARNING | Only string literals should be passed to t() where possible
------------------------------------------------------------------------------------------------------------------------------------------

Proposed resolution

Ensure string literals are passed to t() if possible and also replace t() calls with $this->t() wherever needed.

User interface changes

NONE

API changes

NONE

Data model changes

NONE

๐Ÿ“Œ Task
Status

RTBC

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia ankithashetty Karnataka, India

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024