[META] Replace t() calls inside of classes

Created on 15 February 2020, over 4 years ago
Updated 2 March 2023, over 1 year 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

no

API changes

no

Data model changes

no

Release notes snippet

n/a

πŸ“Œ Task
Status

Active

Version

10.1 ✨

Component
OtherΒ  β†’

Last updated about 8 hours 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.69.0 2024