Simplify slice 1l: PatternContext takes StyleResolver instead of three forwarding closures
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read Patterns/PatternContext.php and HtmlCompilation.php around the two construction sites. Replace the three forwarding closures with the StyleResolver dependency and update both calls, preserving the existing null defaults. Check the listed test construction sites for positional arguments, then run the php-transformer gates; done means byte-identical output and fewer net lines.
Written by the indexing model from the issue text.
Description
Part of #4368. A follow-up to #4723 (PatternContext takes DisclosureControlPresentation).
Problem
Patterns/PatternContext still takes three optional closures that only forward to StyleResolver. HtmlCompilation builds each of them twice, which makes 6 closures:
PatternContext param |
Forwards to | createPatternContext() (positional, about lines 3978 to 3987) |
createProbePatternContext() (named, about lines 4074 to 4077) |
|---|---|---|---|
authoredIconColor |
authoredInheritedPropertyWinner($el, 'color') |
yes | yes |
sourceElementVisuallyClipped |
isVisuallyClippedBox($el) |
yes | yes |
socialPresentationDeclarations |
resolvedPresentationDeclarations($el) |
yes | yes |
Change
PatternContextreplaces those three?Closureparams with one?StyleResolver $styles = null(Style/StyleResolver), placed whereauthoredIconColoris now.authoredIconColor(),sourceElementVisuallyClipped()andsocialPresentationDeclarations()delegate to$this->styles, keeping today's null defaults:'',falseand[].- Delete the three fields and their
@paramlines.
- Update both construction sites in
HtmlCompilation. The first one is positional, so pass$this->styleResolverin the oldauthoredIconColorslot and drop the other two closure arguments, keeping every remaining argument in order. Alternatively, switch that call to named arguments. - Test construction sites:
tests/unit/pattern-recognizer-registry.php,pattern-registry-staged-dispatch.php,button-link-dispatcher.php,flow-container-element-converter.phpandtests/contract/run.php. Check them all: none passes these three params today, so they should need no changes. If any passes positional arguments pastauthoredIconColor, update it.
Read only HtmlCompilation.php (lines 3920 to 4080), Patterns/PatternContext.php and the test files listed above.
Acceptance
- Byte-identical output; the php-transformer gates pass.
- Net lines go down.
- The PR body reports closures removed (6) and net lines.
AI assistance: scoped by Claude Opus (Anthropic) via Pi/Roadie.
- Dominant language
- PHP
- Stars
- 25
- Forks
- 3
- Avg merge
- 2h 29m
- Merged PRs (30d)
- 931
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Automattic/blocks-engine
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Automattic/blocks-engine#4836 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Automattic/blocks-engine#775 ·
Maintainers usually reply within 1 day
-
Shared-chrome CSS factoring merges device-document stylesheets, so phones render the desktop widthOpen
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Automattic/blocks-engine#4894 ·
Maintainers usually reply within 1 day
-
non core block: layout-shell@a[data-testid][href][target]Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 46/100
Automattic/blocks-engine#4888 ·
Maintainers usually reply within 1 day
-
non core block: layout-shell@div[data-bg-effect-name][data-has-ssr-src][data-image-info][data-motion-part]Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Automattic/blocks-engine#4887 ·
Maintainers usually reply within 1 day
All issues in Automattic/blocks-engine
Similar issues
-
sync-en
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
feature-request-triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Codeinwp/wp-menu-icons#360 ·
-
[Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
endoflife-date/endoflife.date#11561 ·
Maintainers usually reply within 1 day
-
area:php-extension priority:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
crazy-goat/go-mesi#623 ·
Maintainers usually reply within 1 day