Fix PHPStan errors

Created on 22 November 2023, 12 months ago
Updated 15 January 2024, 10 months ago

Problem/Motivation

After implementing ๐Ÿ“Œ Integration with Gitlab CI Needs review PHPStan reporting errors.
You can see it in the pipeline.

$ vendor/bin/phpstan analyze modules/contrib/contact_storage/ -c modules/contrib/contact_storage/phpstan.neon 
 27/27 [โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“] 100%

 ------ ------------------------------------------------------------------------------------------ 
  Line   contact_storage.module                                                                    
 ------ ------------------------------------------------------------------------------------------ 
  48     Variable $contact_form in PHPDoc tag @var does not match assigned variable $form_object.  
  49     Call to an undefined method Drupal\Core\Form\FormInterface::getOperation().               
  53     Call to an undefined method Drupal\Core\Form\FormInterface::getEntity().                  
  168    Call to an undefined method Drupal\Core\Form\FormInterface::getEntity().                  
  209    Variable $form_mode in PHPDoc tag @var does not exist.                                    
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/ContactFormViewBuilder.php                                                                                             
 ------ ------------------------------------------------------------------------------------------ 
  87     Call to an undefined method Drupal\Core\Entity\EntityInterface::status().                                                  
  103    Call to an undefined method Drupal\Core\Entity\EntityInterface::getThirdPartySetting().                                    
  104    Call to an undefined method Drupal\Core\Entity\EntityInterface::getThirdPartySetting().                                    
  135    Method Drupal\contact_storage\ContactFormViewBuilder::getCacheTags() should return array but return statement is missing.  
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/EventSubscriber/ContactStorageSettingsFormSave.php                        
 ------ ------------------------------------------------------------------------------------------ 
  22     \Drupal calls should be avoided in classes, use dependency injection instead  
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/Form/ContactFormCloneForm.php                                                                                   
 ------ ------------------------------------------------------------------------------------------ 
  20     Class Drupal\contact_storage\Form\ContactFormCloneForm extends @internal class Drupal\contact\ContactFormEditForm.  
  141    Method Drupal\contact_storage\Form\ContactFormCloneForm::save() should return int but return statement is missing.  
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/Form/ContactFormDisableForm.php                                                      
 ------ ------------------------------------------------------------------------------------------ 
  51     Call to an undefined method Drupal\Core\Entity\EntityInterface::getThirdPartySetting().  
  61     Call to an undefined method Drupal\Core\Entity\EntityInterface::setThirdPartySetting().  
  62     Call to an undefined method Drupal\Core\Entity\EntityInterface::disable().               
 ------ ----------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/Form/ContactFormEnableForm.php                                         
 ------ ------------------------------------------------------------------------------------------ 
  46     Call to an undefined method Drupal\Core\Entity\EntityInterface::enable().  
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/MessageEditForm.php                                                                                                       
 ------ ------------------------------------------------------------------------------------------ 
  41     Method Drupal\contact_storage\MessageEditForm::save() should return int but return statement is missing.                      
  42     Call to an undefined method Drupal\Core\Entity\ContentEntityInterface|Drupal\Core\Entity\RevisionLogInterface::getSubject().  
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/Plugin/Mail/HTMLTestingMailSystem.php                                     
 ------ ------------------------------------------------------------------------------------------ 
  36     \Drupal calls should be avoided in classes, use dependency injection instead  
  38     \Drupal calls should be avoided in classes, use dependency injection instead  
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   src/Plugin/Validation/Constraint/ConstactStorageMaximumSubmissionsConstraintValidator.php  
 ------ ------------------------------------------------------------------------------------------ 
  22     Access to an undefined property Symfony\Component\Validator\Constraint::$limitReached.     
         ๐Ÿ’ก Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property       
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   tests/src/Kernel/ContactStorageFieldTest.php                                                                
 ------ ------------------------------------------------------------------------------------------ 
  17     Property Drupal\Tests\contact_storage\Kernel\ContactStorageFieldTest::$modules property must be protected.  
         ๐Ÿ’ก Change record: https://www.drupal.org/node/2909426                                                       
 ------ ------------------------------------------------------------------------------------------ 

                                                                                                                        
 [ERROR] Found 22 errors                                                                                                                                                                                                       
                                                                                          
                                                                                                                        
๐Ÿ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024