Repository navigation
Check declared service IDs against the plugin's service prefix - #165
Merged
Merged
Conversation
schlessera
added a commit
to mwpd/content-freshness
that referenced
this pull request
Oct 23, 2026
Ported from mwpd/basic-scaffold@1241979 (mwpd/basic-scaffold#165). The plugin's own cron fixtures go too: the scaffold's cron model, ported further on, brings its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #162
What changed
The composition-root contract now checks every key of a root's
get_service_classes()against that root's ownSERVICE_PREFIX, read by reflection likeHOOK_PREFIXalready is. An unprefixed ID, or any ID under an empty prefix, fails asarchitecture.serviceIdsPrefixedwith the ID, the root and the configured prefix, and says how to fix it. The principle-13 row indocs/architecture-rules.mdnow names the rule, and "prefixes of service identifiers" leaves the manual-review column. IDs added by runtime filters stay outside the check and are listed that way in the docs.Why this shape
The check inspects only the recorded declaration keys, so it neither resolves callables nor builds services. It lives in
CompositionRootContractrather than a PHPStan rule because the IDs are array keys built from a constant, which the contract already reads declaratively. Existing fixture roots got aSERVICE_PREFIXand prefixed IDs instead of the check being loosened.Proof
New tests were written first. Before the change, 3 of the 4 new tests failed because invalid IDs produced no diagnostic. They cover an unprefixed ID with the full diagnostic asserted, a fixture root with a different prefix that passes with its own IDs and fails with sample-plugin IDs, and an empty prefix.
Checklist
composer testandcomposer lintpass locally, and CI is green on the current head.breakingand a ruling.Anything left open
Nothing. Generated roots that declare unprefixed IDs will now fail this check and must correct them.