Simplify slice 1g: move the 10 most-wired leaf methods out of HtmlCompilation and delete their 33 closures

Đã đóng
#4,637 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Read HtmlCompilation.php, the listed methods, and the consumers that receive them through constructor closures; inspect SourceBlockCreator and the existing style or presentation services to identify suitable owners. Trace the constructor wiring and internal call sites before moving the methods and removing closure parameters, fields, and forwarders. Run the php-transformer gates and compare output byte for byte; report closures removed, the HtmlCompilation.php line change, and net lines.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Part of #4368. Measured at trunk after #4634.

Problem

43 closure-wired methods in HtmlCompilation, behind 66 constructor closures, call no other HtmlCompilation method except createBlock and attr. They only use services, the session or static helpers, so they don't need to live in HtmlCompilation, and the closures exist only to reach them.

Scope: the 10 most-wired, 33 closures

Method Closures Lines Notes
htmlPreservationBlock 8 5 createBlock('core/html', safeFallbackHtml(..., tagMarkers))
disclosureControlPresentation 6 10
codePresentationAttributes 3 15
recognizePatterns 3 14
requiredScriptsForElement 3 11
runtimeAuthoredButton 2 32 uses createBlock
socialAnchorColors 2 14
rememberAccordionDisclosureRoot 2 9
imageDimensions 2 8
parsedCssSelector 2 5

Change

  1. Move each method to its natural owner:
    • htmlPreservationBlock goes onto SourceBlockCreator, or a small service next to it. Converters already receive SourceBlockCreator.
    • Presentation and attribute helpers go to the existing style or presentation service they read from.
    • Use a new small service only when no existing owner fits.
    • If a method has one consumer, move it into that consumer.
  2. Every consumer that received one of these methods as a closure gets the owning service instead. Delete those closure parameters, fields and forwarders, plus the constructor wiring.
  3. HtmlCompilation's own internal call sites call the new owner directly. Delete the methods from HtmlCompilation.
  4. Keep the change mechanical. The other 33 leaf methods are follow-up work.

Acceptance

  • Byte-identical output across all php-transformer gates.
  • The PR body reports closures removed (target 33), the HtmlCompilation.php line change, and net lines (which must go down).
  • No new tests.

AI assistance: measured and scoped by Claude Opus (Anthropic) via Pi/Roadie.

Ngôn ngữ chính
PHP
Star
25
Fork
3
Merge trung bình
2 giờ 20 phút
Pull request đã merge (30 ngày)
934

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Automattic/blocks-engine

Tất cả issue của Automattic/blocks-engine

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.