Skip to content

Dedupe transformer helpers duplicated by decomposition slices 3/4#270

Merged
chubes4 merged 1 commit into
trunkfrom
refactor/dedupe-transformer-helpers
Jun 28, 2026
Merged

Dedupe transformer helpers duplicated by decomposition slices 3/4#270
chubes4 merged 1 commit into
trunkfrom
refactor/dedupe-transformer-helpers

Conversation

@chubes4

@chubes4 chubes4 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Refs #242

Dedupe helpers that were duplicated by HtmlTransformer decomposition slices 3 (#246, Diagnostics/SemanticParityReporter) and 4 (#249, Diagnostics/FallbackEmitter). Those slices were file-scoped, so they copied shared leaf helpers instead of promoting them. This is a pure, behavior-preserving dedupe — parity is identical.

What changed

Each helper below was confirmed byte-identical across all its copies (diffed before collapsing), then consolidated into the single existing home Support/DomHelpersTrait (already used by all three classes), with the duplicate copies removed:

Helper Was duplicated in
hasAncestorTag HtmlTransformer + SemanticParityReporter
hasSourceNavigationSignal HtmlTransformer + SemanticParityReporter
safeNavigationUrl HtmlTransformer + SemanticParityReporter
runtimeIslandSelector HtmlTransformer + FallbackEmitter
eventMetadata HtmlTransformer + FallbackEmitter
isSafeSvgContent HtmlTransformer + FallbackEmitter
dedupeArrayRows HtmlTransformer + FallbackEmitter

Also removed a stray orphan docblock (@param array<string, string> $attrs) that was left dangling above eventMetadata in HtmlTransformer.

Intentionally left duplicated

While auditing, several other methods appear in both HtmlTransformer and FallbackEmitter (recordRuntimeIsland, sourceContext, requiredScriptsForElement, captureCanvasFallback, captureInlineSvgFallback, captureScriptFallback, captureStaticScriptMetadata, captureTemplateFallback, isRuntimeCanvasTarget). These were diffed and found to have diverged — they are the decomposition delegation boundary, not duplication (e.g. HtmlTransformer's recordRuntimeIsland delegates to $this->fallbackEmitter, and its sourceContext calls a resolver closure while FallbackEmitter holds the full implementation). They were left untouched.

Behavior preservation

  • composer test:canonical — all pass, before and after.
  • composer parity144 fixtures pass, identical before and after.
  • Full composer test (canonical + parity + packaging) green.
  • php -l clean on all four files. No fixtures touched. No logic/signature changes.

Net: +109 / -217 lines (net -108).

Scope limited to HtmlTransformer.php, Diagnostics/SemanticParityReporter.php, Diagnostics/FallbackEmitter.php, Support/DomHelpersTrait.php.

🤖 Generated with Claude Code

DO NOT MERGE pending review.

Refactor slices 3 (#246, SemanticParityReporter) and 4 (#249, FallbackEmitter)
were file-scoped, so they copied shared leaf helpers instead of promoting them.
Each of the following was byte-identical across its copies; consolidate the
single definition into Support/DomHelpersTrait (already used by all three
classes) and remove the duplicates:

- hasAncestorTag (HtmlTransformer + SemanticParityReporter)
- hasSourceNavigationSignal (HtmlTransformer + SemanticParityReporter)
- safeNavigationUrl (HtmlTransformer + SemanticParityReporter)
- runtimeIslandSelector (HtmlTransformer + FallbackEmitter)
- eventMetadata (HtmlTransformer + FallbackEmitter)
- isSafeSvgContent (HtmlTransformer + FallbackEmitter)
- dedupeArrayRows (HtmlTransformer + FallbackEmitter)

Behavior-preserving pure dedupe: no logic or signature changes. Canonical and
parity (144 fixtures) identical before and after; full composer test green.

Refs #242

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chubes4 chubes4 merged commit a731f98 into trunk Jun 28, 2026
1 check passed
@chubes4 chubes4 deleted the refactor/dedupe-transformer-helpers branch June 28, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant