[META] Replace t() calls inside of classes

Created on 15 February 2020, almost 5 years ago
Updated 30 July 2024, 5 months ago

Problem/Motivation

There's many places in core where t() function is used in classes without dependency injection.
It makes this classes hard to unit test because t() defined in core/includes/bootstrap.inc
Also it makes harder to get rid of this include in later core

The sniff is already enabled for Plugins, in phpcs.xml.dist

  <rule ref="DrupalPractice.Objects.GlobalFunction">
    <include-pattern>*/Plugin/*</include-pattern>
  </rule>

Proposed resolution

Replace usage with one of following ways
- $this->t() for controllers using StringTranslationTrait or add if it's missing
- new TranslatableMarkup() in static methods

Remaining tasks

Non-Tests

Tests

Need a final issue to enable the sniff and fix any remaining problems.

User interface changes

API changes

no

Data model changes

no

Release notes snippet

n/a

📌 Task
Status

Active

Version

11.0 🔥

Component
Other 

Last updated 2 days ago

Created by

🇫🇷France andypost

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

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