phpstan-drupal icon indicating copy to clipboard operation
phpstan-drupal copied to clipboard

Method XY has parameter $yz with generic interface Drupal\Core\Field\FieldItemListInterface but does not specify its types: T

Open mxr576 opened this issue 1 year ago • 0 comments

Bug report

This is a potential follow up on #455 which still happening from level >=6.

This is just one example from this specific module but it happens in other code as well:

  Line   src/ContentExporterInterface.php                                                                                                                                           
 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  22     Method Drupal\single_content_sync\ContentExporterInterface::doExportToArray() return type has no value type specified in iterable type array.                              
         💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                                                                                  
  46     Method Drupal\single_content_sync\ContentExporterInterface::getFieldValue() has parameter $field with generic interface Drupal\Core\Field\FieldItemListInterface but does  
         not specify its types: T                                                                                                                                                   
  46     Method Drupal\single_content_sync\ContentExporterInterface::getFieldValue() has parameter $field with no value type specified in iterable type                             
         Drupal\Core\Field\FieldItemListInterface.           

Code snippet that reproduces the problem

composer req drupal/single_content_sync mglaman/phpstan-drupal && vendor/bin/phpstan analyze -l 6 web/modules/contrib/single_content_sync/

$ composer show mglaman/* 
mglaman/phpstan-drupal 1.2.11 Drupal extension and rules for PHPStan

$ composer show phpstan/*
phpstan/extension-installer       1.3.1  Composer plugin for automatic installation of PHPStan extensions
phpstan/phpdoc-parser             1.29.0 PHPDoc parser with support for nullable, intersection and generic types
phpstan/phpstan                   1.11.1 PHPStan - PHP Static Analysis Tool
phpstan/phpstan-deprecation-rules 1.2.0  PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.
phpstan/phpstan-phpunit           1.4.0  PHPUnit extensions and rules for PHPStan

 $ composer show drupal/single_content_sync | grep version
versions : * 1.4.5

mxr576 avatar May 22 '24 08:05 mxr576