Fix phpcs and phpstan issues

Created on 27 May 2024, about 1 month ago
Updated 29 May 2024, about 1 month ago

Problem/Motivation

The added .gitlab-ci.yml in ๐Ÿ“Œ Fix tests & enable GitLab CI Needs work revealed a few phpcs and phpstan issues, which need to get solved.

Full list of phpcs issues:

EE.EEEWW...EEEW.... 19 / 19 (100%)



FILE: /var/www/html/web/modules/custom/commerce_xattributes/src/Form/XattributesProductAttributeForm.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
   |       |     Drupal\commerce_product\Form\ProductAttributeForm.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/src/Form/XattributesProductVariationTypeForm.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
   |       |     Drupal\commerce_product\Form\ProductVariationTypeForm.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/src/XattributesProductAttributeFieldManager.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
   |       |     Drupal\commerce_product\Entity\ProductAttributeInterface.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/src/XattributesProductAttributeListBuilder.php
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Xss.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/commerce_xattributes.module
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
    |       |     Drupal\commerce_xattributes\Form\XattributesProductVariationTypeForm.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/tests/src/Functional/XattributesProductAttributeTest.php
------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
 132 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         | $this->t() instead
 147 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         | $this->t() instead
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 4 | WARNING | Line exceeds 80 characters; contains 175 characters
 6 | WARNING | Line exceeds 80 characters; contains 95 characters
----------------------------------------------------------------------


FILE: ...s/custom/commerce_xattributes/modules/commerce_cattributes/src/Element/CorrectCommerceProductRenderedAttribute.php
------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------------------
  6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is
    |         |     Drupal\Component\Utility\Html.
 27 | WARNING | [ ] Unused variable $exists.
 51 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 55 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: ..._xattributes/modules/commerce_cattributes/src/Plugin/Field/FieldWidget/CorrectProductVariationAttributesWidget.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 9 WARNINGS AFFECTING 10 LINES
------------------------------------------------------------------------------------------------------------------------
   5 | WARNING | [x] Unused use statement
   7 | WARNING | [x] Unused use statement
   9 | WARNING | [x] Unused use statement
  10 | WARNING | [x] Unused use statement
  11 | WARNING | [x] Unused use statement
  16 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is
     |         |     Drupal\commerce_product\Plugin\Field\FieldWidget\ProductVariationWidgetBase.
  17 | WARNING | [x] Unused use statement
  19 | WARNING | [x] Unused use statement
 220 | WARNING | [x] 'TODO: decide what we should to do in this case.' should match the format '@todo Fix problem X
     |         |     here.'
 378 | WARNING | [x] 'TODO: remove this after a while.' should match the format '@todo Fix problem X here.'
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: ...merce_xattributes/modules/commerce_cattributes/src/Plugin/Field/FieldWidget/CorrectProductVariationTitleWidget.php
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
   9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
     |       |     Drupal\commerce_product\Plugin\Field\FieldWidget\ProductVariationTitleWidget.
 113 | ERROR | [x] Expected 1 blank line after function; 2 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/commerce_xattributes/modules/commerce_cattributes/README.md
--------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------
 8 | WARNING | Line exceeds 80 characters; contains 90 characters
--------------------------------------------------------------------------------------------------

Steps to reproduce

Proposed resolution

Fix the phpcs and phpstan issues.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

RTBC

Version

2.0

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024