Fix issues reported by PHPCS

Created on 7 March 2025, 2 days ago

Problem/Motivation

It would be great to address the below minor PHPCS issues :

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

FILE: /var/www/web/modules/contrib/field_sample_value/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
 3 | WARNING | Line exceeds 80 characters; contains 171 characters
 4 | WARNING | Line exceeds 80 characters; contains 175 characters
 5 | WARNING | Line exceeds 80 characters; contains 115 characters
----------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/src/Plugin/Field/SampleValueGenerator/RandomTextValue.php
----------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------
 45 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 71 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/src/SampleValueGeneratorBase.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
 57 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 59 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/src/SampleValueEntityGeneratorInterface.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------------------------------------------------------------
  6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\FieldableEntityInterface.
 11 | ERROR | [x] Expected 1 space after interface name; 2 found
 11 | ERROR | [x] Expected 1 space before opening brace; found 2
 29 | ERROR | [x] Parameter $bundle has null default value, but is not marked as nullable.
 35 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 4 spaces
 45 | ERROR | [ ] Description for the @return value is missing
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/src/Annotation/SampleValueGenerator.php
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
 32 | ERROR | The @var tag must be the first tag in a member variable comment
---------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/src/SampleValueEntityGenerator.php
-------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------
 19 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
 25 | ERROR | [x] Parameter $bundle has null default value, but is not marked as nullable.
 66 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 3
-------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/src/SampleValueGeneratorInterface.php
-------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------
 19 | ERROR | Description for the @return value is missing
 26 | ERROR | Description for the @return value is missing
-------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/field_sample_value/field_sample_value.module
-------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------
 164 | ERROR | Description for the @return value is missing
 180 | ERROR | Description for the @return value is missing
-------------------------------------------------------------------------------

Time: 309ms; Memory: 12MB

Steps to reproduce

  • Install the module, composer require 'drupal/default_content_deploy:^2.1'
  • Run the command,

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

Proposed resolution

Fix the PHPCS issues.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India abhiyanshu

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024