$ phpcs --standard=Drupalpractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml panolens/
FILE: C:\xampp\htdocs\contribution\web\modules\contrib\panolens\src\Commands\PanolensCommands.php
-------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------
74 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
79 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
90 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
181 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------
FILE: C:\xampp\htdocs\contribution\web\modules\contrib\panolens\src\Plugin\Field\FieldFormatter\ImagePanoramaFormatter.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------
47 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------------------------
Time: 132ms; Memory: 6MB
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3291712-9-drupal-call-should-be-avoided.patch | 10.09 KB | sanduhrs |
| #7 | 3291712-7-drupal-call-should-be-avoided.patch | 6.58 KB | dipayanpramanik5 |
Comments
Comment #2
rakhi soni commentedI have created a patch to fix the issue of '\Drupal calls should be avoided in classes, use dependency injection instead',, please review.
Comment #3
sanduhrsGood idea, you might want to consider using phpcs Drupal standard aswell:
phpcs --standard=Drupal,DrupalpracticeOpening brace should be on the same line as the declaration
Opening brace should be on the same line as the declaration
Expected 1 blank line after function; 2 found
Opening brace should be on the same line as the declaration.
Missing semicolon at the end of the line.
Also take care of the parent constructor ImageFormatter::__construct
Opening brace should be on the same line as the declaration.
Also take care of parent creator ImageFormatter::create
Expected 1 blank line after function
No need for a local copy if injected.
Comment #4
sourabhjainI have resolved the issue mentioned in #3.
Please review.
Comment #5
sanduhrsArgumentCountError: Too few arguments to function Drupal\panolens\Commands\PanolensCommands::__construct(), 0 passed
The argument probably needs to be declared in the service definition.
The parent constructor call is missing.
; is missing after $file_url_generator.
Declaration must be compatible with ImageFormatter::create
Comment #6
dipayanpramanik5 commentedComment #7
dipayanpramanik5 commentedComment #8
dipayanpramanik5 commentedComment #9
sanduhrsAdding the same to
VideoPanoramaFormatter.Committing to *dev, thanks!
Comment #11
sanduhrs