Fix PHPSTAN validation errors

Created on 19 July 2025, 24 days ago

Problem/Motivation

The latest build pipelines are failing due to validation errors for the PHPSTAN job:
Failed build: https://git.drupalcode.org/project/image_link_formatter/-/pipelines/545971
Failed job: https://git.drupalcode.org/project/image_link_formatter/-/jobs/5867330

See detailed report below:

 ------ ------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   src/Plugin/Field/FieldFormatter/ImageLinkFormatterTrait.php (in                                                                           
         context of class                                                                                                                          
         Drupal\image_link_formatter\Plugin\Field\FieldFormatter\ImageLinkFormatter)                                                               
 ------ ------------------------------------------------------------------------------------------------------------------------------------------ 
  92     Parameter #1 $items                                                                                                                       
         (Drupal\Core\Field\FieldItemListInterface<Drupal\Core\Field\FieldItemInterface>)                                                          
         of method                                                                                                                                 
         Drupal\image_link_formatter\Plugin\Field\FieldFormatter\ImageLinkFormatter::viewElements()                                                
         should be compatible with parameter $items                                                                                                
         (Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>)                                                      
         of method                                                                                                                                 
         Drupal\Core\Field\FormatterInterface<Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>>::viewElements()  
         🪪 method.childParameterType                                                                                                              
  92     Parameter #1 $items                                                                                                                       
         (Drupal\Core\Field\FieldItemListInterface<Drupal\Core\Field\FieldItemInterface>)                                                          
         of method                                                                                                                                 
         Drupal\image_link_formatter\Plugin\Field\FieldFormatter\ImageLinkFormatter::viewElements()                                                
         should be compatible with parameter $items                                                                                                
         (Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>)                                                      
         of method                                                                                                                                 
         Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter::viewElements()                                                                   
         🪪 method.childParameterType                                                                                                              
  94     Parameter #1 $items of method                                                                                                             
         Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter::viewElements()                                                                   
         expects                                                                                                                                   
         Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>,                                                       
         Drupal\Core\Field\FieldItemListInterface<Drupal\Core\Field\FieldItemInterface>                                                            
         given.                                                                                                                                    
         🪪 argument.type                                                                                                                          
 ------ ------------------------------------------------------------------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   src/Plugin/Field/FieldFormatter/ImageLinkFormatterTrait.php (in                                                                           
         context of class                                                                                                                          
         Drupal\responsive_image_link_formatter\Plugin\Field\FieldFormatter\ResponsiveImageLinkFormatter)                                          
 ------ ------------------------------------------------------------------------------------------------------------------------------------------ 
  92     Parameter #1 $items                                                                                                                       
         (Drupal\Core\Field\FieldItemListInterface<Drupal\Core\Field\FieldItemInterface>)                                                          
         of method                                                                                                                                 
         Drupal\responsive_image_link_formatter\Plugin\Field\FieldFormatter\ResponsiveImageLinkFormatter::viewElements()                           
         should be compatible with parameter $items                                                                                                
         (Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>)                                                      
         of method                                                                                                                                 
         Drupal\Core\Field\FormatterInterface<Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>>::viewElements()  
         🪪 method.childParameterType                                                                                                              
  92     Parameter #1 $items                                                                                                                       
         (Drupal\Core\Field\FieldItemListInterface<Drupal\Core\Field\FieldItemInterface>)                                                          
         of method                                                                                                                                 
         Drupal\responsive_image_link_formatter\Plugin\Field\FieldFormatter\ResponsiveImageLinkFormatter::viewElements()                           
         should be compatible with parameter $items                                                                                                
         (Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>)                                                      
         of method                                                                                                                                 
         Drupal\responsive_image\Plugin\Field\FieldFormatter\ResponsiveImageFormatter::viewElements()                                              
         🪪 method.childParameterType                                                                                                              
  94     Parameter #1 $items of method                                                                                                             
         Drupal\responsive_image\Plugin\Field\FieldFormatter\ResponsiveImageFormatter::viewElements()                                              
         expects                                                                                                                                   
         Drupal\Core\Field\EntityReferenceFieldItemList<Drupal\Core\Entity\EntityInterface>,                                                       
         Drupal\Core\Field\FieldItemListInterface<Drupal\Core\Field\FieldItemInterface>                                                            
         given.                                                                                                                                    
         🪪 argument.type                                                                                                                          
 ------ ------------------------------------------------------------------------------------------------------------------------------------------ 
 [ERROR] Found 6 errors 

Steps to reproduce

Run build pipelines on the 2.2.x branch.

Proposed resolution

Fix the errors from the report.

📌 Task
Status

Active

Version

2.2

Component

Code

Created by

🇫🇷France dydave

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