refactor(Data model): #3591680 Make `Coalescer` operate on `EntityFieldBasedPropExpressionInterface` objects instead of strings

Closes #3591680

What this MR does

Coalescer::coalesce() and ::expand() now carry EntityFieldBasedPropExpressionInterface objects throughout, instead of parsing expression strings on the way in and casting back to strings on the way out. String ⇄ object conversion happens only at the boundaries that actually deal in stored strings:

  • JavaScriptComponent::coalesceEntityFields() / ::expandEntityFields() — parse the stored dataDependencies.entityFields strings via StructuredDataPropExpression::fromString(), run the Coalescer, then stringify the result.
  • EntityFieldExpressionsMustBeIdempotentConstraintValidator — same boundary, per validated entry.

Internally the class already worked on objects; this removes the per-call fromString()/(string) round-trips and makes the data flow obvious. Boundaries narrow parsed input with Inspector::assertAllObjects(…), which also serves as the PHPStan type guard. No behavior change — output is identical, just typed.

Follow-up of !1112 (merged) (see the "Optional follow-up tightening" list in note 1200411).

Testing steps

This is an internal refactor with no user-facing change; coverage is via existing tests.

  1. PHPUnit — CoalescerTest (unit), JavaScriptComponentUpdateFromClientSideTest (expand boundary), JavaScriptComponentValidationTest (coalesce-on-save boundary + idempotency validator) all pass.
  2. composer run phpstan is clean.
  3. composer run phpcs is clean.

Notes for reviewers

  • The Coalescer public contract is now object-based, but every caller is a thin boundary that still reads/writes strings — so config storage and the client wire format are unchanged.
  • CoalescerTest expectations are still expressed/compared as strings for readability (the test parses the constructed objects to strings on both sides), which lines up with the direction of #3591679.
  • AI use disclosure per Drupal.org's policy: parts of this branch were drafted with assistance from Claude (Anthropic), reviewed and verified by a human contributor.

Merge request reports

Loading