Problem/Motivation

Several Search API components type-hint services against concrete classes, preventing alternative implementations (e.g. decorators or test doubles).

Proposed resolution

Use the corresponding interfaces in setter type hints and property, parameter and return types:

- ReverseEntityReferences: EntityFieldManagerInterface instead of EntityFieldManager.
- SearchApiEntity: EntityTypeBundleInfoInterface instead of EntityTypeBundleInfo.
- BackendPluginBase: FieldsHelperInterface instead of FieldsHelper.
- Database: DataTypeHelperInterface.

Remaining tasks

Review.

Issue fork search_api-3624776

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

amateescu created an issue. See original summary.

amateescu’s picture

Status: Active » Needs review

This should do it.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

This is a no brainer so I'll just self-RTBC it :)

huzooka’s picture

I hit a very similar limitation, but with EntityTypeBundleInfo

huzooka’s picture

Added some more fixes. I changed only those where a service-specific interface exists, so (most of SAPI's own) plugin service references were kept.

huzooka changed the visibility of the branch 3637303-fix-cache-unit-test to hidden.

huzooka’s picture

Status: Reviewed & tested by the community » Needs review
huzooka’s picture

Title: ReverseEntityReferences processor type-hints against EntityFieldManager instead of its interface » Services referred by class instead of interface, making decoration impossible
Issue summary: View changes
alorenc’s picture

Assigned: Unassigned » alorenc
alorenc’s picture

Assigned: alorenc » Unassigned
Status: Needs review » Reviewed & tested by the community

Looks good: switching the property, setter and docblock types to the interfaces is correct

PHPunit fails but the same problem is on https://git.drupalcode.org/project/search_api/-/pipelines/1039490