Problem/Motivation
phpcs is green now, but phpstan still fails on 8.x-4.x with 5 errors not covered by the baseline:
- 4× Access to an undefined property
FieldItemInterface::$value— in the geocode field formatters. - 1×
drupal.entityStorageDirectInjection— inGeocoderProviderListBuilder.
Proposed resolution
Real fixes, no baseline/ignores:
- Read the item value via
$item->getValue()['value']instead of the magic$item->value(PHPStan can't resolve it on the genericFieldItemInterface). - Inject
EntityTypeManagerInterfaceinto the list builder and derive the storage from it. - Add kernel test coverage for the changed formatter/list-builder paths.
Issue fork geocoder-3613803
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
velmir_taky commentedNo baseline/ignores — fixed all 5 for real.
- Formatters read the item value via
$item->getValue()['value']instead of the magic$item->value. Same value at runtime — checked the file/address case too, where the preprocessor setsvaluedynamically andgetValue()still returns it. PHPStan just couldn't resolve the magic property onFieldItemInterface.-
GeocoderProviderListBuildernow takesentity_type.managerand derives the storage from it, as the rule suggests.Added kernel tests for the changed paths (Geocode formatter, reverse-geocode geofield formatter, provider list builder). phpstan and phpunit are green.