Address GitLab CI phpstan errors

Created on 28 March 2024, 7 months ago
Updated 11 April 2024, 7 months ago

Problem/Motivation

Since adding a GitLab CI configuration ( πŸ“Œ Add .gitlab-ci.yml Fixed ), the GitLab CI phpstan check that is run on MRs reports various issues:

$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
 ------ -------------------------------------------------------------------------------- 
  Line   config_merge_filter/src/Plugin/ConfigFilter/MergeFilter.php                     
 ------ -------------------------------------------------------------------------------- 
  20     Class Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter                
         extends unknown class Drupal\config_filter\Plugin\ConfigFilterBase.             
         πŸ’‘ Learn more at https://phpstan.org/user-guide/discovering-symbols             
  58     Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter::__construct()       
         calls parent::__construct() but                                                 
         Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter does not             
         extend any class.                                                               
  68     Unsafe usage of new static().                                                   
         πŸ’‘ See:                                                                         
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static    
  162    Access to an undefined property                                                 
         Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter::$configuration.     
         πŸ’‘ Learn more:                                                                  
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property        
  162    Access to an undefined property                                                 
         Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter::$pluginDefinition.  
         πŸ’‘ Learn more:                                                                  
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property        
  162    Access to an undefined property                                                 
         Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter::$pluginId.          
         πŸ’‘ Learn more:                                                                  
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property        
  162    Unsafe usage of new static().                                                   
         πŸ’‘ See:                                                                         
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static    
 ------ -------------------------------------------------------------------------------- 
 ------ ----------------------------------------- 
  Line   tests/src/Unit/ConfigMergerTest.php      
 ------ ----------------------------------------- 
  24     Missing call to parent::setUp() method.  
 ------ ----------------------------------------- 
 [ERROR] Found 8 errors 

Steps to reproduce

Run GitLab CI pipelines in a MR.

Proposed resolution

  • Add config_filter as a requireDev dependency in composer.json to resolve the errors for Drupal\config_merge_filter\Plugin\ConfigFilter\MergeFilter
  • Consider adding a phpstan.neon file that ignores the Unsafe usage of new static() errors.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

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