Fix the errors/warnings reported by PHP_CodeSniffer

Created on 7 March 2024, 10 months ago
Updated 11 April 2024, 8 months ago

Problem/Motivation

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml shows the following errors/warnings which should be fixed.

FILE: /var/www/html/web/modules/contrib/field_hidden/field_hidden/field_hidden.module
----------------------------------------------------------------------------------------------------------
FOUND 39 ERRORS AND 5 WARNINGS AFFECTING 24 LINES
----------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
  5 | ERROR   | [x] There must be exactly one blank line after the file comment
 11 | WARNING | [ ] Hook implementations should not duplicate @param documentation
 11 | ERROR   | [ ] Missing parameter comment
 13 | WARNING | [ ] Hook implementations should not duplicate @return documentation
 13 | ERROR   | [x] Expected "string|null" but found "string|NULL" for function return type
 13 | ERROR   | [ ] Description for the @return value is missing
 15 | ERROR   | [x] Expected 1 blank line before function; 2 found
 19 | ERROR   | [ ] String concat is not required here; use a single string instead
 19 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 19 | ERROR   | [x] Short array syntax must be used to define arrays
 19 | ERROR   | [x] Short array syntax must be used to define arrays
 21 | ERROR   | [ ] String concat is not required here; use a single string instead
 22 | ERROR   | [ ] String concat is not required here; use a single string instead
 23 | ERROR   | [ ] String concat is not required here; use a single string instead
 24 | ERROR   | [ ] String concat is not required here; use a single string instead
 25 | ERROR   | [ ] String concat is not required here; use a single string instead
 26 | ERROR   | [ ] String concat is not required here; use a single string instead
 27 | ERROR   | [ ] String concat is not required here; use a single string instead
 28 | ERROR   | [ ] String concat is not required here; use a single string instead
 28 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 28 | ERROR   | [x] Short array syntax must be used to define arrays
 28 | ERROR   | [x] Short array syntax must be used to define arrays
 29 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 29 | ERROR   | [x] Short array syntax must be used to define arrays
 29 | ERROR   | [x] Short array syntax must be used to define arrays
 31 | ERROR   | [ ] String concat is not required here; use a single string instead
 31 | ERROR   | [x] Short array syntax must be used to define arrays
 31 | ERROR   | [x] Short array syntax must be used to define arrays
 32 | ERROR   | [x] Short array syntax must be used to define arrays
 32 | ERROR   | [x] Short array syntax must be used to define arrays
 34 | ERROR   | [ ] String concat is not required here; use a single string instead
 34 | ERROR   | [x] Short array syntax must be used to define arrays
 34 | ERROR   | [x] Short array syntax must be used to define arrays
 35 | ERROR   | [x] Short array syntax must be used to define arrays
 35 | ERROR   | [x] Short array syntax must be used to define arrays
 36 | ERROR   | [x] Short array syntax must be used to define arrays
 36 | ERROR   | [x] Short array syntax must be used to define arrays
 37 | ERROR   | [x] Short array syntax must be used to define arrays
 37 | ERROR   | [x] Short array syntax must be used to define arrays
 38 | ERROR   | [x] Short array syntax must be used to define arrays
 38 | ERROR   | [x] Short array syntax must be used to define arrays
 40 | ERROR   | [ ] String concat is not required here; use a single string instead
 43 | ERROR   | [x] Comments may not appear after statements
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 25 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/field_hidden/release_notes/release_notes_8.x-1.0.txt
-----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------
 13 | WARNING | Line exceeds 80 characters; contains 110 characters
 15 | WARNING | Line exceeds 80 characters; contains 82 characters
 38 | WARNING | Line exceeds 80 characters; contains 108 characters
-----------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/field_hidden/release_notes/release_notes_8.x-1.0-beta1.txt
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------
  9 | WARNING | Line exceeds 80 characters; contains 110 characters
 11 | WARNING | Line exceeds 80 characters; contains 82 characters
 34 | WARNING | Line exceeds 80 characters; contains 108 characters
-----------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/field_hidden/src/Plugin/Field/FieldWidget/FieldHiddenNumberWidget.php
----------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/field_hidden/src/Plugin/Field/FieldWidget/FieldHiddenStringTextfieldWidget.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
  2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
 11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/field_hidden/src/Plugin/Field/FieldWidget/FieldHiddenStringTextareaWidget.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
  2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
 11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextareaWidget.
----------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 124ms; Memory: 12MB
πŸ› Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Andrii Momotov

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