Need DI for translation in hooks

Created on 23 July 2025, 13 days ago

Problem/Motivation

phpcs is giving this warning:

FILE: ...ncrypt/tests/modules/field_encrypt_test/src/Hook/FieldEncryptTestHooks.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 26 | ERROR | Missing member variable doc comment
    |       | (Drupal.Commenting.VariableComment.Missing)
--------------------------------------------------------------------------------
FILE: ...web/modules/custom/field_encrypt/src/Hook/FieldEncryptRequirementsHook.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
 27 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         | $this->t() instead
    |         | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
 29 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         | $this->t() instead
    |         | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
 30 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         | $this->t() instead
    |         | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
--------------------------------------------------------------------------------
Time: 826ms; Memory: 10MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇯🇵Japan ptmkenny

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

Comments & Activities

Production build 0.71.5 2024