Fix PHPCS Fixer, PHPStan, PHP MND

Created on 9 February 2023, over 1 year ago

Problem/Motivation

PHP MND

phpmnd version 2.5.0 by Povilas Susinskas



-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

entity_share_cron/src/Form/SettingsForm.php:88. Magic number: 60
  > 88|       '#min' => 60,

entity_share_cron/src/Form/SettingsForm.php:89. Magic number: 60
  > 89|       '#step' => 60,

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

entity_share_cron/entity_share_cron.install:74. Magic number: 5
  > 74|   $config->set('page_limit', 5);

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PHP CS Fixer:

Paths from configuration file have been overridden by paths provided as command arguments.
   1) /project/app/modules/custom/entity_share_cron/tests/src/Functional/EntityShareCronFunctionalTest.php
   2) /project/app/modules/custom/entity_share_cron/src/EntityShareCronService.php
   3) /project/app/modules/custom/entity_share_cron/src/Plugin/QueueWorker/EntityShareCronPending.php
   4) /project/app/modules/custom/entity_share_cron/src/Form/SettingsForm.php
   5) /project/app/modules/custom/entity_share_cron/src/HookHandler/CronHookHandler.php
   6) /project/app/modules/custom/entity_share_cron/src/EntityShareCronServiceInterface.php

PHPStan:

------ ------------------------------------------------------------------------------------------ 
  Line   modules/custom/entity_share_cron/entity_share_cron.install                                
 ------ ------------------------------------------------------------------------------------------ 
  16     Function entity_share_cron_install() has no return type specified.                        
  25     Function entity_share_cron_uninstall() has no return type specified.                      
  25     Function entity_share_cron_uninstall() has parameter $is_syncing with no type specified.  
  35     Function entity_share_cron_update_8101() has no return type specified.                    
  40     Argument of an invalid type mixed supplied for foreach, only iterables are supported.     
  41     Cannot access offset 'channels' on mixed.                                                 
  41     Cannot access offset 'channels' on mixed.                                                 
  42     Parameter #1 $array of function array_keys expects array, mixed given.                    
  43     Cannot access offset 'operations' on mixed.                                               
  56     Function entity_share_cron_update_8201() has no return type specified.                    
  68     Function entity_share_cron_update_8301() has no return type specified.                    
  76     Argument of an invalid type mixed supplied for foreach, only iterables are supported.     
  77     Cannot access offset 'channels' on mixed.                                                 
  77     Cannot access offset 'channels' on mixed.                                                 
  78     Parameter #1 $array of function array_keys expects array, mixed given.                    
  80     Cannot access offset 'import_config' on mixed.                                            
  82     Cannot access offset 'channels' on mixed.                                                 
  82     Cannot access offset 'url' on mixed.                                                      
  82     Cannot access offset int|string on mixed.                                                 
  82     Cannot access offset mixed on mixed.                                                      
  83     Cannot access offset 'channels' on mixed.                                                 
  83     Cannot access offset 'url_uuid' on mixed.                                                 
  83     Cannot access offset int|string on mixed.                                                 
  83     Cannot access offset mixed on mixed.                                                      
 ------ ------------------------------------------------------------------------------------------ 

 ------ ----------------------------------------------------------------- 
  Line   modules/custom/entity_share_cron/entity_share_cron.module        
 ------ ----------------------------------------------------------------- 
  15     Function entity_share_cron_cron() has no return type specified.  
 ------ ----------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------------------------------------------------------- 
  Line   modules/custom/entity_share_cron/src/EntityShareCronService.php                                                        
 ------ ----------------------------------------------------------------------------------------------------------------------- 
  75     Method Drupal\entity_share_cron\EntityShareCronService::enqueue() has no return type specified.                        
  88     Method Drupal\entity_share_cron\EntityShareCronService::sync() has no return type specified.                           
  151    Cannot access offset 'data' on mixed.                                                                                  
  151    Parameter #1 $data of static method Drupal\entity_share\EntityShareUtility::prepareData() expects array, mixed given.  
  154    Cannot access offset 'href' on mixed.                                                                                  
  154    Cannot access offset 'href' on mixed.                                                                                  
  154    Cannot access offset 'links' on mixed.                                                                                 
  154    Cannot access offset 'links' on mixed.                                                                                 
  154    Cannot access offset 'next' on mixed.                                                                                  
  154    Cannot access offset 'next' on mixed.                                                                                  
  168    Method Drupal\entity_share_cron\EntityShareCronService::filterDataToImport() has no return type specified.             
  182    Cannot call method getKey() on Drupal\Core\Entity\EntityTypeInterface|null.                                            
  225    Cannot access offset 'channels' on mixed.                                                                              
  225    Cannot access offset string on mixed.                                                                                  
  225    Cannot access offset string on mixed.                                                                                  
  226    Cannot access offset 'channels' on mixed.                                                                              
  226    Cannot access offset string on mixed.                                                                                  
  226    Cannot access offset string on mixed.                                                                                  
  228    Method Drupal\entity_share_cron\EntityShareCronService::getChannelConfig() should return array but returns mixed.      
 ------ ----------------------------------------------------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------------------------------- 
  Line   modules/custom/entity_share_cron/src/EntityShareCronServiceInterface.php                                  
 ------ ---------------------------------------------------------------------------------------------------------- 
  25     Method Drupal\entity_share_cron\EntityShareCronServiceInterface::enqueue() has no return type specified.  
  38     Method Drupal\entity_share_cron\EntityShareCronServiceInterface::sync() has no return type specified.     
 ------ ---------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   modules/custom/entity_share_cron/src/Form/SettingsForm.php                                                                                                                                            
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  57     Method Drupal\entity_share_cron\Form\SettingsForm::create() has no return type specified.                                                                                                             
  58     Unsafe usage of new static().                                                                                                                                                                         
         💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static                                                                                                                     
  110    Cannot access offset (int|string) on mixed.                                                                                                                                                           
  110    Cannot access offset (int|string) on mixed.                                                                                                                                                           
  115    Cannot access offset 'enabled' on mixed.                                                                                                                                                              
  155    Cannot access offset 'channels' on mixed.                                                                                                                                                             
  155    Cannot access offset 'channels' on mixed.                                                                                                                                                             
  155    Cannot access offset (int|string) on mixed.                                                                                                                                                           
  155    Cannot access offset (int|string) on mixed.                                                                                                                                                           
  162    Cannot access offset 'enabled' on mixed.                                                                                                                                                              
  168    Cannot access offset 'import_config' on mixed.                                                                                                                                                        
  168    Cannot access offset 'import_config' on mixed.                                                                                                                                                        
  192    Cannot access offset 'create' on mixed.                                                                                                                                                               
  192    Cannot access offset 'create' on mixed.                                                                                                                                                               
  192    Cannot access offset 'operations' on mixed.                                                                                                                                                           
  192    Cannot access offset 'operations' on mixed.                                                                                                                                                           
  197    Cannot access offset 'operations' on mixed.                                                                                                                                                           
  197    Cannot access offset 'operations' on mixed.                                                                                                                                                           
  197    Cannot access offset 'update' on mixed.                                                                                                                                                               
  197    Cannot access offset 'update' on mixed.                                                                                                                                                               
  209    Method Drupal\entity_share_cron\Form\SettingsForm::validateForm() has no return type specified.                                                                                                       
  256    Method Drupal\entity_share_cron\Form\SettingsForm::submitForm() has no return type specified.                                                                                                         
  278    Offset '#parents' does not exist on array|null.                                                                                                                                                       
  295    Method Drupal\entity_share_cron\Form\SettingsForm::getImportConfigOptions() should return array<string> but returns array<int|string, Drupal\Core\StringTranslation\TranslatableMarkup|string|null>.  
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------------------ 
  Line   modules/custom/entity_share_cron/src/HookHandler/CronHookHandler.php                                  
 ------ ------------------------------------------------------------------------------------------------------ 
  81     Method Drupal\entity_share_cron\HookHandler\CronHookHandler::create() has no return type specified.   
  82     Unsafe usage of new static().                                                                         
         💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static                     
  93     Method Drupal\entity_share_cron\HookHandler\CronHookHandler::process() has no return type specified.  
  100    Comparison operation "<" between int<1, max> and (array|float|int) results in an error.               
 ------ ------------------------------------------------------------------------------------------------------ 

 ------ ---------------------------------------------------------------------------------------------------------------------------------- 
  Line   modules/custom/entity_share_cron/src/Plugin/QueueWorker/EntityShareCronPending.php                                                
 ------ ---------------------------------------------------------------------------------------------------------------------------------- 
  68     Unsafe usage of new static().                                                                                                     
         💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static                                                 
  79     Method Drupal\entity_share_cron\Plugin\QueueWorker\EntityShareCronPending::processItem() has no return type specified.            
  80     Cannot access offset 'remote_id' on mixed.                                                                                        
  81     Cannot access offset 'channel_id' on mixed.                                                                                       
  82     Cannot access offset 'url' on mixed.                                                                                              
  87     Parameter #1 $remote_id of method Drupal\entity_share_cron\EntityShareCronServiceInterface::sync() expects string, mixed given.   
  87     Parameter #2 $channel_id of method Drupal\entity_share_cron\EntityShareCronServiceInterface::sync() expects string, mixed given.  
  87     Parameter #3 $url of method Drupal\entity_share_cron\EntityShareCronServiceInterface::sync() expects string|null, mixed given.    
 ------ ---------------------------------------------------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------------------------------------------------------- 
  Line   modules/custom/entity_share_cron/tests/src/Functional/EntityShareCronFunctionalTest.php                                               
 ------ -------------------------------------------------------------------------------------------------------------------------------------- 
  52     Method Drupal\Tests\entity_share_cron\Functional\EntityShareCronFunctionalTest::getEntitiesDataArray() has no return type specified.  
  77     Method Drupal\Tests\entity_share_cron\Functional\EntityShareCronFunctionalTest::testCron() has no return type specified.              
  156    Cannot call method delete() on Drupal\Core\Entity\EntityInterface|null.                                                               
  158    Cannot call method set() on Drupal\Core\Entity\EntityInterface|null.                                                                  
  159    Cannot call method save() on Drupal\Core\Entity\EntityInterface|null.                                                                 
  183    Cannot call method label() on Drupal\Core\Entity\EntityInterface|null.                                                                
  188    Cannot call method set() on Drupal\Core\Entity\EntityInterface|null.                                                                  
  189    Cannot call method save() on Drupal\Core\Entity\EntityInterface|null.                                                                 
  213    Cannot call method label() on Drupal\Core\Entity\EntityInterface|null.                                                                
 ------ -------------------------------------------------------------------------------------------------------------------------------------- 

                                                                                                                        
 [ERROR] Found 91 errors                                                                                                
                                                                                                               
📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

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

Comments & Activities

Production build 0.69.0 2024