Skip to content

RFC: decompose WeavingTransformer into TokenStreamEditor + TraitConverter #638

Description

@lisachenko

Problem

src/Instrument/Transformer/WeavingTransformer.php is 1037 lines / 20 methods owning: advisor-matching orchestration, class→trait conversion (:255), enum→trait conversion (:454), #[\Override] stripping (:543), attribute-group stripping (:345), promoted-property demotion (:766), constructor-assignment injection (:830), token-blanking helpers (:386, :404, :894, :935), function proxying (:958), and cache writing (~:996). It is the highest-churn, highest-risk file in the repo — most recent audit commits touched it.

Proposed decomposition (for discussion)

  • TokenStreamEditor: the token surgery helpers (blanking, splicing, line-preserving edits) as a directly unit-testable service.
  • TraitConverter: class→trait and enum→trait conversion, including #[\Override]/attribute handling and promoted-property demotion.
  • WeavingTransformer keeps orchestration: match advisors → convert → write cache.

Pure refactor; the fixture suite (tests/Core/Instrument/Transformer/_files/*) must stay byte-for-byte green. Effort L, risk medium. Needs discussion on cut lines before implementation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions