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 storeddataDependencies.entityFieldsstrings viaStructuredDataPropExpression::fromString(), run theCoalescer, 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.
- PHPUnit —
CoalescerTest(unit),JavaScriptComponentUpdateFromClientSideTest(expand boundary),JavaScriptComponentValidationTest(coalesce-on-save boundary + idempotency validator) all pass. composer run phpstanis clean.composer run phpcsis clean.
Notes for reviewers
- The
Coalescerpublic 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. CoalescerTestexpectations 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.