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 — 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.

itamair made their first commit to this issue’s fork.

  • itamair committed d7a846a1 on 8.x-4.x authored by velmir_taky
    Issue #3613803: Fix PHPStan level 2 errors in formatters and list...
itamair’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.