Fix PHPStan errors

Created on 28 December 2023, 9 months ago
Updated 15 January 2024, 9 months ago

Problem/Motivation

Pipeline from 📌 Fix the issues reported by phpcs Needs review

 php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
 ------ ---------------------------------------------------------------- 
  Line   src/EntityReferenceRevisionsFieldItemList.php                   
 ------ ---------------------------------------------------------------- 
  41     Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
  113    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
 ------ ---------------------------------------------------------------- 
 ------ ------------------------------------------------------------------ 
  Line   src/EntityReferenceRevisionsOrphanPurger.php                      
 ------ ------------------------------------------------------------------ 
  140    Call to deprecated method deleteRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                        
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
         \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
         instead.                                                          
 ------ ------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/OrphanedCompositeEntitiesDeleteForm.php                              
 ------ ------------------------------------------------------------------------------ 
  60     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------------------------- 
  Line   src/Normalizer/EntityReferenceRevisionItemNormalizer.php                                         
 ------ ------------------------------------------------------------------------------------------------- 
  34     Return type mixed of method                                                                      
         Drupal\entity_reference_revisions\Normalizer\EntityReferenceRevisionItemNormalizer::normalize()  
         is not covariant with return type                                                                
         array|ArrayObject|bool|float|int|string|null of method                                           
         Drupal\hal\Normalizer\EntityReferenceItemNormalizer::normalize().                                
 ------ ------------------------------------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------- 
  Line   src/Plugin/DataType/EntityReferenceRevisions.php                
 ------ ---------------------------------------------------------------- 
  81     Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
 ------ ---------------------------------------------------------------- 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/Field/FieldFormatter/EntityReferenceRevisionsEntityFormatter.php   
 ------ ------------------------------------------------------------------------------ 
  73     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
  142    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
 ------ ------------------------------------------------------------------------------ 
 ------ --------------------------------------------------------------------------------------------------- 
  Line   src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php                                        
 ------ --------------------------------------------------------------------------------------------------- 
  366    Method                                                                                             
         Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::postSave()  
         should return bool but return statement is missing.                                                
  400    Call to deprecated method deleteRevision() of class                                                
         Drupal\Core\Entity\EntityStorageInterface:                                                         
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                                            
         \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision                                   
         instead.                                                                                           
 ------ --------------------------------------------------------------------------------------------------- 
 ------ ----------------------------------------------------------------------------- 
  Line   src/Plugin/Field/FieldWidget/EntityReferenceRevisionsAutocompleteWidget.php  
 ------ ----------------------------------------------------------------------------- 
  29     \Drupal calls should be avoided in classes, use dependency injection         
         instead                                                                      
 ------ ----------------------------------------------------------------------------- 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/QueueWorker/OrphanPurger.php                                       
 ------ ------------------------------------------------------------------------------ 
  71     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------ 
  Line   src/Plugin/migrate/destination/EntityReferenceRevisions.php       
 ------ ------------------------------------------------------------------ 
  120    Call to deprecated method loadRevision() of class                 
         Drupal\Core\Entity\EntityStorageInterface:                        
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
         instead.                                                          
  174    Call to deprecated method loadRevision() of class                 
         Drupal\Core\Entity\EntityStorageInterface:                        
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
         instead.                                                          
  200    Call to deprecated method loadRevision() of class                 
         Drupal\Core\Entity\EntityStorageInterface:                        
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
         instead.                                                          
  206    Call to deprecated method deleteRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                        
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
         \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
         instead.                                                          
 ------ ------------------------------------------------------------------ 
 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/views/display/EntityReferenceRevisions.php                 
 ------ ---------------------------------------------------------------------- 
  137    \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/views/style/EntityReferenceRevisions.php                   
 ------ ---------------------------------------------------------------------- 
  90     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------- 
  Line   tests/src/Kernel/EntityReferenceRevisionsCompositeTest.php      
 ------ ---------------------------------------------------------------- 
  396    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
  436    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
  447    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
  450    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
  501    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
  504    Call to deprecated method loadRevision() of class               
         Drupal\Core\Entity\EntityStorageInterface:                      
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
         instead.                                                        
 ------ ---------------------------------------------------------------- 
 ------ ----------------------------------------------------------------------------- 
  Line   tests/src/Kernel/EntityReferenceRevisionsCompositeTranslatableFieldTest.php  
 ------ ----------------------------------------------------------------------------- 
  156    Call to deprecated method loadRevision() of class                            
         Drupal\Core\Entity\EntityStorageInterface:                                   
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                      
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision               
         instead.                                                                     
  204    Call to deprecated method loadRevision() of class                            
         Drupal\Core\Entity\EntityStorageInterface:                                   
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                      
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision               
         instead.                                                                     
  220    Call to deprecated method loadRevision() of class                            
         Drupal\Core\Entity\EntityStorageInterface:                                   
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                      
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision               
         instead.                                                                     
  262    Call to deprecated method loadRevision() of class                            
         Drupal\Core\Entity\EntityStorageInterface:                                   
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                      
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision               
         instead.                                                                     
 ------ ----------------------------------------------------------------------------- 
 ------ ----------------------------------------------------------------------- 
  Line   tests/src/Kernel/EntityReferenceRevisionsCompositeTranslationTest.php  
 ------ ----------------------------------------------------------------------- 
  239    Call to deprecated method loadRevision() of class                      
         Drupal\Core\Entity\EntityStorageInterface:                             
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision         
         instead.                                                               
  273    Call to deprecated method loadRevision() of class                      
         Drupal\Core\Entity\EntityStorageInterface:                             
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision         
         instead.                                                               
  287    Call to deprecated method loadRevision() of class                      
         Drupal\Core\Entity\EntityStorageInterface:                             
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision         
         instead.                                                               
  308    Call to deprecated method loadRevision() of class                      
         Drupal\Core\Entity\EntityStorageInterface:                             
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision         
         instead.                                                               
  335    Call to deprecated method loadRevision() of class                      
         Drupal\Core\Entity\EntityStorageInterface:                             
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision         
         instead.                                                               
  350    Call to deprecated method loadRevision() of class                      
         Drupal\Core\Entity\EntityStorageInterface:                             
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision         
         instead.                                                               
 ------ ----------------------------------------------------------------------- 
 ------ ----------------------------------------------------------------------------------------- 
  Line   tests/src/Kernel/Plugin/migrate/destination/EntityReferenceRevisionsDestinationTest.php  
 ------ ----------------------------------------------------------------------------------------- 
  111    Call to deprecated method loadRevision() of class                                        
         Drupal\Core\Entity\EntityStorageInterface:                                               
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                                  
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                           
         instead.                                                                                 
  118    Call to deprecated method loadRevision() of class                                        
         Drupal\Core\Entity\EntityStorageInterface:                                               
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                                  
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                           
         instead.                                                                                 
  267    Call to deprecated method loadRevision() of class                                        
         Drupal\Core\Entity\EntityStorageInterface:                                               
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                                  
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                           
         instead.                                                                                 
  275    Call to deprecated method loadRevision() of class                                        
         Drupal\Core\Entity\EntityStorageInterface:                                               
         in drupal:10.1.0 and is removed from drupal:11.0.0. Use                                  
         \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                           
         instead.                                                                                 
 ------ ----------------------------------------------------------------------------------------- 
 [ERROR] Found 38 errors  

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇷🇺Russia zniki.ru

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