Drupal Coding Standards Issues | phpcs

Created on 1 February 2023, over 1 year ago
Updated 22 February 2023, over 1 year ago

Problem/Motivation

Getting following error/warnings.

FILE: ...mpp\htdocs\abc\drupal\modules\domain_finder\domain_finder.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
75 | ERROR | The array declaration extends to column 116 (the limit
| | is 80). The array content should be split up over
| | multiple lines
----------------------------------------------------------------------

FILE: ...\modules\domain_finder\src\Controller\DomainFinderController.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
20 | ERROR | No key specified for array entry; first entry
| | specifies key
31 | ERROR | The $_GET super global must not be accessed directly;
| | inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('domain_text')
| | instead
32 | ERROR | The $_GET super global must not be accessed directly;
| | inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('domain_text')
| | instead
37 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
51 | WARNING | Unused variable $in_form.
51 | ERROR | The $_GET super global must not be accessed directly;
| | inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('domains_in_form')
| | instead
52 | ERROR | The $_GET super global must not be accessed directly;
| | inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('domains')
| | instead
92 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
----------------------------------------------------------------------

FILE: ...drupal\modules\domain_finder\src\Form\DomainFinderSearchForm.php
----------------------------------------------------------------------
FOUND 8 ERRORS AND 5 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------
30 | WARNING | Unused variable $input.
36 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
37 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
57 | ERROR | The $_GET super global must not be accessed
| | directly; inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('domain_text')
| | instead
62 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
71 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
73 | ERROR | The $_GET super global must not be accessed
| | directly; inject the request_stack service and use
| | $stack->getCurrentRequest()->query instead
75 | ERROR | The $_GET super global must not be accessed
| | directly; inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('block_id')
| | instead
76 | ERROR | The $_GET super global must not be accessed
| | directly; inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('block_id')
| | instead
76 | ERROR | The $_GET super global must not be accessed
| | directly; inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('block_id')
| | instead
80 | ERROR | The $_GET super global must not be accessed
| | directly; inject the request_stack service and use
| | $stack->getCurrentRequest()->query->get('domains')
| | instead
105 | ERROR | Expected type hint "FormStateInterface"; found
| | "array" for $form
105 | ERROR | Expected type hint "array"; found
| | "FormStateInterface" for $form_state
----------------------------------------------------------------------

FILE: ...pal\modules\domain_finder\src\Plugin\Block\DomainFinderBlock.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
24 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
53 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
67 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
73 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
80 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
----------------------------------------------------------------------

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/domain_finder/

Proposed resolution

Above error/warnings need to be fixed.

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇮🇳India Charchil Khandelwal

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

Comments & Activities

Production build 0.71.5 2024