Fix phpstan issues

Created on 2 November 2023, over 1 year ago

Problem/Motivation

When running automated tests. We get the next phpstan issues:

------------------------------------------------------------------------------ 
  Line   src/Controller/AutologoutController.php                                       
 ------ ------------------------------------------------------------------------------ 
  63     Unsafe usage of new static().                                                 
         πŸ’‘ See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/AutologoutBlockForm.php                                              
 ------ ------------------------------------------------------------------------------ 
  43     Unsafe usage of new static().                                                 
         πŸ’‘ See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/AutologoutSettingsForm.php                                           
 ------ ------------------------------------------------------------------------------ 
  67     Unsafe usage of new static().                                                 
         πŸ’‘ See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/Block/AutologoutWarningBlock.php                                   
 ------ ------------------------------------------------------------------------------ 
  107    Unsafe usage of new static().                                                 
         πŸ’‘ See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/migrate/destination/ConfigAutologoutRoles.php              
 ------ ---------------------------------------------------------------------- 
  22     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 ------ --------------------------------------------------------------------- 
  Line   tests/src/Kernel/Migrate/d6/MigrateAutologoutSettingsTest.php        
 ------ --------------------------------------------------------------------- 
  47     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  49     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  52     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  53     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
 ------ --------------------------------------------------------------------- 
 ------ --------------------------------------------------------------------- 
  Line   tests/src/Kernel/Migrate/d7/MigrateAutologoutSettingsTest.php        
 ------ --------------------------------------------------------------------- 
  44     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  46     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  49     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  50     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
  51     You should use assertFalse() instead of assertSame() when expecting  
         "false"                                                              
 ------ --------------------------------------------------------------------- 

Remaining tasks

  1. Create phpstan.neon.dist file similar to core, we need to ignore Unsafe usage of new static(), since this is standard practice for Drupal development.
  2. Remove \Drupal call and replace with dependency injection.
  3. Replace assertSame() with assertFalse() in tests where applicable.
πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024