Problem/Motivation
Phpstan pipeline: https://git.drupalcode.org/project/soembed/-/jobs/2707120
Line src/Plugin/Filter/SoEmbedFilter.php
------ ----------------------------------------------------------------------
176 \Drupal calls should be avoided in classes, use dependency injection
instead
182 \Drupal calls should be avoided in classes, use dependency injection
instead
341 \Drupal calls should be avoided in classes, use dependency injection
instead
343 \Drupal calls should be avoided in classes, use dependency injection
instead
Proposed resolution
Use D.I to avoid these warnings or use @phpstan-ignore-next-line if Drupal calls are used on purpose.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | soembed-MR7.patch | 2.83 KB | loze |
| #3 | finalss.png | 74.15 KB | girish_lnweb |
Issue fork soembed-3473083
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
girish_lnweb commentedI will be working on it.
Comment #3
girish_lnweb commented@ankitv18 I have use same version of the module and trying to replicate the issue but I have not get any error as you mentioned above, I use this command to check for the errors
./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/custom/soembed/
and got some errors, mention in the attached screenshot.
Kindly give me the steps to replicate.
Thank you
Comment #4
rajdip_755Hi @girish_lnweb, I have also run the phpcs but can't replicating the issue as you mentioned in #3 .
Along with this I have checked lines mentioned by @ankitv18 in the codebase of the module and the \Drupal is used in those lines which is not good as per the Drupal Coding Standard, we should use the DI for those lines.
Thanks !
Comment #5
ankitv18 commentedComment #7
ankitv18 commentedComment #9
ki commentedComment #10
loze commentedthis latest change gives me this error
Error: Call to a member function moduleExists() on null in Drupal\soembed\Plugin\Filter\SoEmbedFilter->getEnabledProviders()Comment #12
loze commentedMR7 gets this working for me.
Comment #13
loze commentedhere is a patch for composer
Comment #15
ki commented