Fix issues reported by PHPCS

Created on 13 February 2025, 2 months 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 google_calendar_service/


FILE: /var/www/web/modules/contrib/google_calendar_service/google_calendar_service.module
------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 24 ERRORS AND 4 WARNINGS AFFECTING 20 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------
   9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Render\Element.
  31 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "_save_google_event_form_submit" but
     |         |     expected "google_calendar_service__save_google_event_form_submit"
  31 | ERROR   | [x] Missing function doc comment
  64 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "_validate_time_save_google_event" but
     |         |     expected "google_calendar_service__validate_time_save_google_event"
  64 | ERROR   | [x] Missing function doc comment
  67 | WARNING | [ ] Unused variable $name.
  68 | WARNING | [ ] Unused variable $location.
  69 | WARNING | [ ] Unused variable $description.
  81 | WARNING | [ ] Unused variable $time_available.
  82 | ERROR   | [x] No space found before comment text; expected "// Error message set in verifyTimeGoogleCalendar method." but found "//Error
     |         |     message set in verifyTimeGoogleCalendar method."
  91 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
  91 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 106 | ERROR   | [x] Expected 1 blank line after function; 2 found
 118 | ERROR   | [x] Missing function doc comment
 118 | ERROR   | [x] Expected 1 blank line before function; 0 found
 148 | ERROR   | [x] Object operator not indented correctly; expected 6 spaces but found 12
 153 | ERROR   | [x] Whitespace found at end of line
 177 | ERROR   | [x] There must be one blank line after the last USE statement; 0 found;
 178 | ERROR   | [x] Missing function doc comment
 178 | ERROR   | [x] Expected 1 blank line before function; 0 found
 197 | ERROR   | [x] Expected 1 blank line after function; 2 found
 223 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 223 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 242 | ERROR   | [x] Concat operator must be surrounded by a single space
 242 | ERROR   | [x] Concat operator must be surrounded by a single space
 243 | ERROR   | [x] Concat operator must be surrounded by a single space
 243 | ERROR   | [x] Concat operator must be surrounded by a single space
 246 | ERROR   | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 22 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
 42 | WARNING | Line exceeds 80 characters; contains 423 characters
 43 | WARNING | Line exceeds 80 characters; contains 209 characters
 45 | WARNING | Line exceeds 80 characters; contains 112 characters
 47 | WARNING | Line exceeds 80 characters; contains 275 characters
----------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Plugin/QueueWorker/CalendarImportProcessor.php
-------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AND 2 WARNINGS AFFECTING 8 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
  4 | ERROR   | [x] Doc comment short description must end with a full stop
  9 | WARNING | [x] Unused use statement
 13 | WARNING | [x] Unused use statement
 26 | ERROR   | [x] Expected 2 spaces before interface name; 0 found
 35 | ERROR   | [ ] Parameter $configuration is not described in comment
 35 | ERROR   | [ ] Parameter $plugin_id is not described in comment
 35 | ERROR   | [ ] Parameter $plugin_definition is not described in comment
 54 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 54 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Plugin/Validation/Constraint/TimeAvailableConstraint.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------
 19 | ERROR | [x] You must use "/**" style comments for a member variable comment
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Plugin/Validation/Constraint/TimeAvailableConstraintValidator.php
------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------
  7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\DependencyInjection\ContainerInjectionInterface.
 19 | ERROR | [ ] Missing short description in doc comment
 43 | ERROR | [ ] Class property $EditEventService should use lowerCamel naming without underscores
 45 | ERROR | [ ] Parameter $edit_events is not described in comment
 52 | ERROR | [ ] Doc comment for parameter $route_match does not match actual variable name $edit_events
------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/GoogleHttpClientFactory.php
---------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 4 LINES
---------------------------------------------------------------------------------------------------------------------
  5 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Google_Service_Calendar.
  7 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
 15 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 41 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 41 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/CalendarAccessControlHandler.php
----------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------
  8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Access\AccessResult.
 23 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 23 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 25 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
 62 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 62 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/CalendarListBuilder.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Link.
 31 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
 33 | WARNING | [ ] Only string literals should be passed to t() where possible
 75 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Form/CalendarEventForm.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 1 WARNING AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeBundleInfoInterface.
  14 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  47 | ERROR   | [ ] Missing short description in doc comment
  59 | ERROR   | [ ] Doc comment for parameter $bundle_info does not match actual variable name <undefined>
  72 | ERROR   | [x] Parameter $bundle_info has null default value, but is not marked as nullable.
  73 | ERROR   | [x] Parameter $time has null default value, but is not marked as nullable.
  77 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
  77 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 105 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Form/CalendarEventDeleteForm.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeBundleInfoInterface.
 28 | ERROR | [ ] Missing short description in doc comment
 40 | ERROR | [ ] Doc comment for parameter $bundle_info does not match actual variable name <undefined>
 49 | ERROR | [x] Parameter $bundle_info has null default value, but is not marked as nullable.
 50 | ERROR | [x] Parameter $time has null default value, but is not marked as nullable.
 52 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
 52 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Form/CalendarForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeBundleInfoInterface.
 36 | ERROR   | [ ] Missing short description in doc comment
 48 | ERROR   | [ ] Doc comment for parameter $bundle_info does not match actual variable name <undefined>
 59 | ERROR   | [x] Parameter $bundle_info has null default value, but is not marked as nullable.
 60 | ERROR   | [x] Parameter $time has null default value, but is not marked as nullable.
 63 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 63 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 89 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Form/CalendarSettingsForm.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 3 WARNINGS AFFECTING 8 LINES
-----------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityFieldManager.
  19 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
  29 | ERROR   | [ ] Missing short description in doc comment
  67 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
  67 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 116 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 118 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 162 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 264 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 264 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Form/ImportEventsForm.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\google_calendar_service\CalendarImport.
 52 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
 52 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/CalendarEventAccessControlHandler.php
----------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------
  8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Access\AccessResult.
 23 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 23 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 25 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
 62 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 62 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Controller/CalendarImportController.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 5 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\google_calendar_service\CalendarImport.
  15 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
  39 | ERROR   | [ ] Missing short description in doc comment
  60 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
  60 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 127 | ERROR   | [x] Additional blank lines found at end of doc comment
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Entity/Calendar.php
--------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------------------------------
   6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\ContentEntityBase.
 166 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
 166 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
--------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/Entity/CalendarEvent.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------------------------
  7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\ContentEntityBase.
 60 | ERROR | [x] Expected 2 spaces before interface name; 4 found
 69 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
 69 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/CalendarImport.php
----------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 1 WARNING AFFECTING 9 LINES
----------------------------------------------------------------------------------------------------------------------
   9 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  10 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  11 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  12 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is DateTime.
  12 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  13 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  20 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
  77 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
  77 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 183 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
 183 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 275 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 11 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/CalendarEventListBuilder.php
-------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 28 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/src/CalendarEditEvents.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 7 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeManagerInterface.
   9 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  10 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  11 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  63 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
  63 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 147 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
 147 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 253 | ERROR | [ ] Parameter $eventId is not described in comment
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/web/modules/contrib/google_calendar_service/config/install/views.view.gcs_calendar_events.yml
------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------
 1336 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------

Time: 1.25 secs; Memory: 14MB

Steps to reproduce

Run the command,
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml google_calendar_service/

Proposed resolution

Fix the phpcs issues.

📌 Task
Status

Active

Version

3.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

Comments & Activities

Production build 0.71.5 2024