t() calls should be avoided in classes

Created on 27 June 2023, over 1 year ago
Updated 27 August 2023, over 1 year ago

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\aggregator\src\FeedViewBuilder.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------------------
145 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
153 | 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\aggregator\tests\src\Functional\migrate_drupal_ui\MigrateUpgradeExecuteTestBase.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 1 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
76 | 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\aggregator\tests\src\Kernel\FeedValidationTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
58 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
60 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India arti_parmar

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

  • 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 & MariaDB 10.3.22
    last update over 1 year ago
    144 pass
  • 🇮🇳India arti_parmar

    Kindly review patch.

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

    Hi @arti
    You need to update the command which we need to run to test.
    patch applied cleanly so moving to RTBC.

  • Status changed to Needs work over 1 year ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
    1. +++ b/tests/src/Functional/migrate_drupal_ui/MigrateUpgradeExecuteTestBase.php
      @@ -73,7 +76,7 @@ abstract class MigrateUpgradeExecuteTestBase extends CoreUpgradeTestBase {
      -    $session->pageTextContains(t('Congratulations, you upgraded Drupal!'));
      +    $session->pageTextContains($this->t('Congratulations, you upgraded Drupal!'));
      

      This fix is wrong, we shuoldn't be using t() in tests, can you remove the trait and t() altogether

    2. +++ b/tests/src/Kernel/FeedValidationTest.php
      @@ -55,9 +58,9 @@ class FeedValidationTest extends EntityKernelTestBase {
      -    $this->assertEquals(t('A feed named %value already exists. Enter a unique title.', ['%value' => $feed->label()]), $violations[0]->getMessage());
      +    $this->assertEquals($this->t('A feed named %value already exists. Enter a unique title.', ['%value' => $feed->label()]), $violations[0]->getMessage());
           $this->assertEquals('url', $violations[1]->getPropertyPath());
      -    $this->assertEquals(t('A feed with this URL %value already exists. Enter a unique URL.', ['%value' => $feed->getUrl()]), $violations[1]->getMessage());
      

      here too

    Thanks for working on this.

    Per my blog post, phpcs issues are great for new contributors. However I notice from your profile you already have several credits for PHPCS issues. As a result I'm removing credit in this instance. Feel free to stick around and help with the other issues in the module if you're looking to for the next step in your contribution journey.

  • 🇮🇳India indrapatil Bangalore

    Sure @larowlan I will work on the other issues.
    Thank you.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    147 pass
  • 🇺🇸United States dcam
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    147 pass
    • dcam committed 3bedab43 on 2.x
      Issue #3370387:  t() calls should be avoided in classes
      
    • dcam committed 8215f1ed on 1.x
      Issue #3370387:  t() calls should be avoided in classes
      
  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States dcam
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024