Update code to pass phpcs and phpstan

Created on 5 August 2024, 5 months ago

Problem/Motivation

Several phpcs and phpstan errors show in tests.

phpcs:

FILE: ...roject/file_download/web/modules/custom/file_download/file_download.module
--------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
--------------------------------------------------------------------------------
  3 | ERROR   | Missing short description in doc comment
    |         | (Drupal.Commenting.DocComment.MissingShort)
 26 | ERROR   | The array declaration extends to column 165 (the limit is 120).
    |         | The array content should be split up over multiple lines
    |         | (Drupal.Arrays.Array.LongLineDeclaration)
 31 | ERROR   | Doc comment short description must start with a capital letter
    |         | (Drupal.Commenting.DocComment.ShortNotCapital)
 51 | WARNING | Line exceeds 80 characters; contains 81 characters
    |         | (Drupal.Files.LineLength.TooLong)
--------------------------------------------------------------------------------
Time: 193ms; Memory: 6MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE                                                            ERRORS  WARNINGS
--------------------------------------------------------------------------------
...nload/web/modules/custom/file_download/file_download.module  3       1
--------------------------------------------------------------------------------
A TOTAL OF 3 ERRORS AND 1 WARNING WERE FOUND IN 12 FILES
--------------------------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
----------------------------------------------------------------------
SOURCE                                                           COUNT
----------------------------------------------------------------------
Drupal.Arrays.Array.LongLineDeclaration                          1
Drupal.Commenting.DocComment.MissingShort                        1
Drupal.Commenting.DocComment.ShortNotCapital                     1
Drupal.Files.LineLength.TooLong                                  1
----------------------------------------------------------------------
A TOTAL OF 4 SNIFF VIOLATIONS WERE FOUND IN 4 SOURCES
----------------------------------------------------------------------

phpstan

------ --------------------------------------------------------- 
  Line   file_download.module                                     
 ------ --------------------------------------------------------- 
  77     Call to deprecated function file_icon_class():           
         in drupal:10.3.0 and is removed from drupal:11.0.0. Use  
           \Drupal\file\IconMimeTypes::getIconClass() instead.    
 ------ --------------------------------------------------------- 
 ------ ----------------------------------------------------------------------- 
  Line   modules/file_download_counter/file_download_counter.install            
 ------ ----------------------------------------------------------------------- 
  67     Function file_download_counter_update_8001() should return string but  
         return statement is missing.                                           
 ------ ----------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   modules/file_download_counter/file_download_counter.module            
 ------ ---------------------------------------------------------------------- 
  10     Class Drupal\Core\Database\Database referenced with incorrect case:   
         Drupal\core\Database\Database.                                        
  66     Function file_download_counter_title_list() has invalid return type   
         SelectQuery.                                                          
  105    Function file_download_counter_get() should return array<string> but  
         return statement is missing.                                          
  107    Class Drupal\Core\Database\Database referenced with incorrect case:   
         Drupal\core\Database\Database.                                        
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Controller/FileDownloadDownloadController.php                     
 ------ ---------------------------------------------------------------------- 
  74     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
  75     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/Field/FieldFormatter/FileDownloadFieldFormatter.php        
 ------ ---------------------------------------------------------------------- 
  117    \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
  143    \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 [ERROR] Found 10 errors           

cspell

daycount
dbfield
dbrows
totalcount

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States shelane

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