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

Created on 10 July 2023, over 1 year ago
Updated 9 January 2024, 12 months ago

Problem/Motivation

FILE: /var/www/html/vb/d_cont/syncommerce/src/Form/ProductsEditForm.php
--------------------------------------------------------------------------------
FOUND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
180 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
200 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...ar/www/html/vb/d_cont/syncommerce/src/Controller/SyncommerceController.php
--------------------------------------------------------------------------------
FOUND 8 WARNINGS AFFECTING 8 LINES
--------------------------------------------------------------------------------
48 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
62 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
137 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
139 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
153 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
183 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
207 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
227 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 288ms; Memory: 14MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig syncommerce/

Remaining tasks

Patch review

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India urvashi_vora Madhya Pradesh, India

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

Comments & Activities

  • Issue created by @urvashi_vora
  • Status changed to RTBC 12 months ago
  • 🇮🇳India ashutosh ahirwal India

    Provided patch resolve all the \Drupal calls should be avoided in classes, use dependency injection instead
    But it contain other PHPcs error and warnings.
    All the issue found by Phpcs should be include in one issue.

Production build 0.71.5 2024