Problem/Motivation
FILE: /var/www/html/vb/d_cont/mosparo_integration/src/Service/MosparoService.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
116 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------
FILE: ...ion/modules/mosparo_contact/src/Plugin/Field/FieldWidget/MosparoWidget.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
33 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
34 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------
Time: 372ms; Memory: 12MB
Steps to reproduce
Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig mosparo_integration/
Remaining tasks
Patch review
| Comment | File | Size | Author |
|---|---|---|---|
| dependency-injection-fixed.patch | 4.24 KB | urvashi_vora |
Issue fork mosparo_integration-3372740
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
zepich commentedComment #5
zepich commentedHi @urvashi_vora
Thank you very much for your issue and the patch.
I've reviewed it and adjusted it. In my eyes, we cannot replace the \Drupal call in the
MosparoWidgetbecause it uses the constructor method fromWidgetBasewhich is not able to accept Dependency Injection (https://git.drupalcode.org/project/mosparo_integration/-/blob/1.0.x/modu...).I'm open to suggestions if you know how we could solve that. We have the same problem in the other module (https://git.drupalcode.org/project/mosparo_integration/-/blob/1.0.x/modu...) which the CodeSniffer didn't found.
Thank you very much, and have a nice day!
Kind regards,
zepich
Comment #6
zepich commentedI fixed one
\Drupalusage. The other uses are not fixable in my view.