Skip to content

docs: final-service composition + array-over-regex idiom#67

Merged
CybotTM merged 2 commits into
mainfrom
feat/retro-final-class-di-wrap
Jul 4, 2026
Merged

docs: final-service composition + array-over-regex idiom#67
CybotTM merged 2 commits into
mainfrom
feat/retro-final-class-di-wrap

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

Two PHP patterns promoted from local memory: composing a final tagged service instead of decorating it, and preferring array functions over regex for token lists.

Came from

/retro promote pass over local memory (2026-07-04), draining a patterns.md note upward to the owning skill.

Change

  • references/symfony-patterns.md — new DI subsection: for a final upstream service in a tagged collection, ->decorate() leaves the inner service registered so the collection gets tagged twice (broke a phpdoc.guides.directive collection on PHP 8.1). Documents composing the wrapper by injecting the upstream service and delegating, then clearing its tag in a compiler pass ($container->has() + findDefinition() + clearTag(), which resolve aliases) so the upstream stays a container service and only its tag is removed — preferred over removeDefinition(), which would break other consumers that inject it.
  • references/core-rules.md — new idiom entry: explode/array_filter/implode over preg_replace for adding/removing specific tokens in a delimited string, with a $c !== '' guard that drops empty tokens.

Two atomic commits, one per pattern.

Test plan

Copilot AI review requested due to automatic review settings July 4, 2026 11:46
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added documentation Improvements or additions to documentation skill labels Jul 4, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jul 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds documentation guidelines for PHP modernization and Symfony patterns, introducing a rule favoring array functions over regular expressions for token lists and a pattern for wrapping final services in tagged collections. The review feedback suggests improving the token list example to handle empty strings robustly, and addresses a dependency injection anti-pattern in the Symfony pattern guide by recommending constructor injection of the upstream service combined with clearing its tag in a compiler pass instead of manual instantiation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread skills/php-modernization/references/core-rules.md
Comment thread skills/php-modernization/references/symfony-patterns.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR promotes two PHP/Symfony patterns into the php-modernization skill’s reference docs: (1) guidance for wrapping final services used in tagged collections, and (2) an idiom favoring array operations over regex when manipulating token lists in delimited strings.

Changes:

  • Adds a Symfony DI subsection documenting pitfalls of ->decorate() with tagged iterators and proposing a wrapper-based approach.
  • Adds a core rule recommending explode/array_filter/implode over preg_replace for adding/removing specific tokens.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
skills/php-modernization/references/symfony-patterns.md Documents a pattern for wrapping final services used in tagged collections, including a compiler-pass snippet to avoid duplicate tag entries.
skills/php-modernization/references/core-rules.md Adds a rule/idiom for manipulating token lists using array functions instead of regex.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/php-modernization/references/core-rules.md
Comment thread skills/php-modernization/references/symfony-patterns.md
Comment thread skills/php-modernization/references/symfony-patterns.md Outdated
@CybotTM

CybotTM commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

The failing composer-audit / SAST (Opengrep) check is not caused by this PR. This PR changes only two .md reference files (67 insertions); reproducing the scan locally (opengrep --config auto --severity WARNING) shows all 5 findings are in skills/php-modernization/templates/github-actions/php-modernization.yml — an untouched template — flagged by yaml.github-actions.security.github-actions-mutable-action-tag for mutable @vN action tags (actions/checkout@v4, shivammathur/setup-php@v2, astral-sh/setup-uv@v6, github/codeql-action/upload-sarif@v3, actions/upload-artifact@v4).

main last passed this check before the --config auto registry ruleset began enforcing that rule, so the first run after the rule landed surfaces it. The finding is legitimate but pre-existing and orthogonal to this docs change — pinning those five actions to commit SHAs belongs in its own PR. My PHP examples in the diff produced zero findings.

@CybotTM

CybotTM commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

The pre-existing SAST finding is fixed in #68 (inline # nosemgrep on the template's intentional mutable tags — chosen over pinning because the template documents those tags as convenient defaults). Once #68 merges, rebasing this branch on main clears the SAST check here too.

@CybotTM
CybotTM force-pushed the feat/retro-final-class-di-wrap branch from bda0c9f to 0539d12 Compare July 4, 2026 12:58
github-actions[bot]
github-actions Bot previously approved these changes Jul 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread skills/php-modernization/references/symfony-patterns.md
CybotTM added 2 commits July 4, 2026 15:08
…corate()

Symfony ->decorate() keeps the inner service registered, so a final
upstream service in a tagged collection ends up tagged twice (inner +
outer); the duplicate registration broke a phpdoc.guides.directive
collection on PHP 8.1. Document manual composition — construct and delegate
to the upstream instance, then removeDefinition() it in a compiler pass so
only the wrapper carries the tag.

From a /retro promote pass over local memory (patterns.md).

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Removing specific tokens from a delimited string (CSS classes, scopes)
reads more clearly as explode/array_filter/implode than preg_replace, and
avoids word-boundary and partial-match traps.

From a /retro promote pass over local memory (patterns.md).

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM
CybotTM force-pushed the feat/retro-final-class-di-wrap branch from 0539d12 to b47a5d4 Compare July 4, 2026 13:08
@CybotTM
CybotTM requested a review from Copilot July 4, 2026 13:08
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread skills/php-modernization/references/symfony-patterns.md
@CybotTM
CybotTM merged commit b4605a4 into main Jul 4, 2026
21 checks passed
@CybotTM
CybotTM deleted the feat/retro-final-class-di-wrap branch July 4, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants