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.
  • drupal.entityStorageDirectInjection — in GeocoderProviderListBuilder.

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 generic FieldItemInterface).
  • Inject EntityTypeManagerInterface into the list builder and derive the storage from it.
  • Add kernel test coverage for the changed formatter/list-builder paths.

Issue fork geocoder-3613803

Command icon 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

velmir_taky created an issue. See original summary.

velmir_taky’s picture

Assigned: velmir_taky » Unassigned
Status: Active » Needs review

No 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 sets value dynamically and getValue() still returns it. PHPStan just couldn't resolve the magic property on FieldItemInterface.
- GeocoderProviderListBuilder now takes entity_type.manager and 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.