Fix issues reported by PHPStan

Created on 5 July 2024, 6 months ago
Updated 7 July 2024, 6 months ago

Problem/Motivation

With the integration of GitLab CI from 📌 Add Gitlab CI to V2 of the module Active there is now a report for PHPStan issues at https://git.drupalcode.org/project/activecampaign/-/jobs/2043632

PHPStan - PHP Static Analysis Tool 1.11.6
$ php --version
PHP 8.1.29 (cli) (built: Jun  6 2024 17:38:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.29, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.29, Copyright (c), by Zend Technologies
$ echo "Executing php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION"
Executing php vendor/bin/phpstan analyze web/modules/custom/activecampaign --configuration=web/modules/custom/activecampaign/phpstan.neon
$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --error-format=junit > junit.xml || true
  0/15 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
 15/15 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress --error-format=gitlab > phpstan-quality-report.json || true
$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
 ------ ----------------------------------------------------------------------------------------------------------------- 
  Line   modules/activecampaign_webform/src/Plugin/WebformHandler/ActiveCampaignFormHandler.php                           
 ------ ----------------------------------------------------------------------------------------------------------------- 
  24     Class                                                                                                            
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler                                    
         extends unknown class Drupal\webform\Plugin\WebformHandlerBase.                                                  
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                              
  42     Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::create()                          
         calls parent::create() but                                                                                       
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler                                    
         does not extend any class.                                                                                       
  65     Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$webform.                         
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  68     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  79     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  82     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  83     Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  87     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  90     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  91     Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  94     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  97     Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  98     Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  104    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  108    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  109    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  111    Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  116    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  117    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  122    Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  125    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::setSettingsParents().             
  133    Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::submitConfigurationForm()         
         calls parent::submitConfigurationForm() but                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler                                    
         does not extend any class.                                                                                       
  136    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::applyFormStateToConfiguration().  
  139    Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  139    Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$configuration.                   
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  146    Parameter $webform_submission of method                                                                          
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::submitForm()                      
         has invalid type Drupal\webform\webformSubmissionInterface.                                                      
  148    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::getConfiguration().               
  194    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::getLogger().                      
  198    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::getLogger().                      
  203    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  205    Call to static method encode() on an unknown class                                                               
         Drupal\webform\Utility\WebformYaml.                                                                              
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                              
  209    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::t().                              
  211    Call to static method encode() on an unknown class                                                               
         Drupal\webform\Utility\WebformYaml.                                                                              
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                              
  217    Access to an undefined property                                                                                  
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::$renderer.                        
         💡 Learn more:                                                                                                   
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                         
  218    Call to an undefined method                                                                                      
         Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::getLogger().                      
 ------ ----------------------------------------------------------------------------------------------------------------- 
 [ERROR] Found 35 errors                                                        
$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress --generate-baseline --allow-empty-baseline || true # collapsed multi-line command
 [WARNING] Baseline generated with 34 errors.                                   
           Some errors could not be put into baseline. Re-run PHPStan and fix   
           them.                                                                
This baseline file is an artifact you can download and use in the project.

Steps to reproduce

https://git.drupalcode.org/project/activecampaign/-/jobs/2043632

Proposed resolution

Fix the issues and create a merge request.

Review the changes and merge the MR.

Remaining tasks

Add code and review the changes.

📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇧🇪Belgium dtfabio Ninove

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

Merge Requests

Comments & Activities

  • Issue created by @dtfabio
  • First commit to issue fork.
  • Merge request !16Drupal 11 upgrade → (Open) created by VladimirAus
  • Pipeline finished with Canceled
    6 months ago
    Total: 19s
    #217415
  • Pipeline finished with Failed
    6 months ago
    Total: 150s
    #217417
  • Pipeline finished with Failed
    6 months ago
    #217424
  • Pipeline finished with Running
    6 months ago
    #217443
  • Pipeline finished with Failed
    6 months ago
    Total: 145s
    #217445
  • Pipeline finished with Failed
    6 months ago
    Total: 145s
    #217447
  • Pipeline finished with Canceled
    6 months ago
    Total: 99s
    #217453
  • Pipeline finished with Failed
    6 months ago
    Total: 167s
    #217455
  • Status changed to Needs review 6 months ago
  • 🇦🇺Australia VladimirAus Brisbane, Australia
  • 🇦🇺Australia VladimirAus Brisbane, Australia

    PHPStan errors are fixed.

  • Status changed to Needs work 6 months ago
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    Needs rebase

Production build 0.71.5 2024