\Drupal calls should be avoided in classes, use dependency injection instead

Created on 29 February 2024, 10 months ago

Steps to reproduce

Run Drupal Coding standards commend then show some errors and warnings.

this is the commend =
phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/drupal/example_module

FILE: C:\xampp\htdocs\newdrupal\web\modules\contrib\taxonomy_breadcrumb\src\Form\TaxonomyBreadcrumbAdminSettings.php
--------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------------------------
42 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
49 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
64 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
72 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\newdrupal\web\modules\contrib\taxonomy_breadcrumb\src\TaxonomyBreadcrumb.php
--------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------
129 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\newdrupal\web\modules\contrib\taxonomy_breadcrumb\src\VocabularyForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
51 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
54 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\newdrupal\web\modules\contrib\taxonomy_breadcrumb\taxonomy_breadcrumb.info.yml
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------
4 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
----------------------------------------------------------------------------------------------------

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India jayprakash.kushwah India

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024