t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead

Created on 28 June 2023, over 1 year ago
Updated 17 April 2024, 7 months ago

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\freelinking\modules\freelinking_prepopulate\tests\src\Functional\FreelinkingPrepopulateTest.php
---------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------------
126 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\freelinking\tests\src\Functional\FreelinkingBrowserTestBase.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
58 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
59 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
104 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\freelinking\tests\src\Functional\FreelinkingFilterTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
30 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
44 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
57 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
63 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
67 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
69 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
71 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\freelinking\tests\src\Functional\FreelinkingMultilingualTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
101 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\freelinking\tests\src\Functional\FreelinkingPrefixAffixTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
37 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\freelinking\tests\src\Functional\NodeTitleBuiltinFailoverTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
39 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
45 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

📌 Task
Status

Closed: outdated

Version

4.0

Component

Code

Created by

🇮🇳India arti_parmar

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

Comments & Activities

  • Issue created by @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    132 pass
  • 🇮🇳India arti_parmar

    Kindly review patch.

  • 🇮🇳India Raveen Kumar

    @artii,
    a) I have reviewed the code in the patch. The warning message you mentioned is related to Drupal coding standards and best practices. In Drupal, when working with translations, it is recommended to use the $this->t() method instead of the global t() function within classes.

    b) By using $this->t() instead of t() within classes, you ensure that the translation service is properly injected and available for use. It also improves the testability and maintainability of your code.

    Your Patch is good to go. And Thank you.

  • Status changed to RTBC over 1 year ago
  • 🇮🇳India indrapatil Bangalore

    The patch is applied cleanly so moving to RTBC.

  • Status changed to Closed: outdated 7 months ago
  • 🇺🇸United States mradcliffe USA

    This ended up no longer applying. Sorry I didn't get to this, but I ended up in a different direction while implementing GitLab CI.

Production build 0.71.5 2024