Fix PHPCS issues

Created on 25 September 2024, about 2 months ago

Problem/Motivation

Currently the PHPCS CI job shows the following issues:

FILE: ...w_mode_switch/tests/src/Unit/Entity/EntityViewModeDeleteFormHelperTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 13 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Tests\UnitTestCase.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...s/custom/view_mode_switch/tests/src/Unit/Entity/EntityFieldManagerTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Tests\UnitTestCase.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...tch/tests/src/Kernel/Plugin/Field/FieldWidget/ViewModeSwitchWidgetTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\view_mode_switch\Kernel\ViewModeSwitchTestBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ..._switch/tests/src/Kernel/Plugin/Field/FieldType/ViewModeSwitchItemTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 13 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is
    |       |     Drupal\Tests\view_mode_switch\Kernel\ViewModeSwitchTestBase.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...tch/tests/src/Kernel/Plugin/Field/FieldType/ViewModeSwitchItemListTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\view_mode_switch\Kernel\ViewModeSwitchTestBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ts/src/Kernel/Plugin/Field/FieldFormatter/ViewModeSwitchFormattersTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\view_mode_switch\Kernel\ViewModeSwitchTestBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...mode_switch/tests/src/Kernel/Entity/EntityViewModeDeleteFormHelperTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\view_mode_switch\Kernel\ViewModeSwitchTestBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...custom/view_mode_switch/tests/src/Kernel/Entity/EntityFieldManagerTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\view_mode_switch\Kernel\ViewModeSwitchTestBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...custom/view_mode_switch/tests/src/Functional/ViewModeSwitchFieldUITest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Tests\field_ui\Traits\FieldUiTestTrait.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...es/custom/view_mode_switch/tests/src/Functional/ViewModeSwitchDiffTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\view_mode_switch\Traits\ViewModeSwitchTestTrait.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...iew_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItemInterface.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 62 | ERROR | [x] Parameter $account has null default value, but is not marked
    |       |     as nullable.
    |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
 76 | ERROR | [x] Parameter $account has null default value, but is not marked
    |       |     as nullable.
    |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: .../custom/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------
 162 | ERROR | [x] Parameter $account has null default value, but is not marked
     |       |     as nullable.
     |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
 183 | ERROR | [x] Parameter $account has null default value, but is not marked
     |       |     as nullable.
     |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
 195 | ERROR | [x] Parameter $account has null default value, but is not marked
     |       |     as nullable.
     |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
 230 | ERROR | [x] Parameter $account has null default value, but is not marked
     |       |     as nullable.
     |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 926ms; Memory: 12MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE                                                            ERRORS  WARNINGS
--------------------------------------------------------------------------------
...de_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php  4       0
.../src/Plugin/Field/FieldType/ViewModeSwitchItemInterface.php  2       0
...mode_switch/tests/src/Functional/ViewModeSwitchDiffTest.php  1       0
...e_switch/tests/src/Functional/ViewModeSwitchFieldUITest.php  1       0
...e_switch/tests/src/Kernel/Entity/EntityFieldManagerTest.php  1       0
...ts/src/Kernel/Entity/EntityViewModeDeleteFormHelperTest.php  1       0
...lugin/Field/FieldFormatter/ViewModeSwitchFormattersTest.php  1       0
...ernel/Plugin/Field/FieldType/ViewModeSwitchItemListTest.php  1       0
...rc/Kernel/Plugin/Field/FieldType/ViewModeSwitchItemTest.php  1       0
...ernel/Plugin/Field/FieldWidget/ViewModeSwitchWidgetTest.php  1       0
...ode_switch/tests/src/Unit/Entity/EntityFieldManagerTest.php  1       0
...ests/src/Unit/Entity/EntityViewModeDeleteFormHelperTest.php  1       0
--------------------------------------------------------------------------------
A TOTAL OF 16 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
--------------------------------------------------------------------------------
PHPCBF CAN FIX 16 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
    SOURCE                                                                 COUNT
--------------------------------------------------------------------------------
[x] SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.Incorrectl  10
[x] SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.Null  6
--------------------------------------------------------------------------------
A TOTAL OF 16 SNIFF VIOLATIONS WERE FOUND IN 2 SOURCES
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SOURCES AUTOMATICALLY (16 VIOLATIONS IN TOTAL)
--------------------------------------------------------------------------------

Proposed resolution

  • Fix PHPCS issues

Remaining tasks

  • Create issue fork and MR to fix this issue
📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany hctom

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024