feat: resolve spark routes filters for custom placeholders#10263
Open
paulbalandan wants to merge 2 commits into
Open
feat: resolve spark routes filters for custom placeholders#10263paulbalandan wants to merge 2 commits into
paulbalandan wants to merge 2 commits into
Conversation
26ff99a to
a17baae
Compare
michalsn
reviewed
Jun 1, 2026
michalsn
approved these changes
Jun 1, 2026
Member
michalsn
left a comment
There was a problem hiding this comment.
Looks good, thanks!
Bottom line... That's pretty compex for something that's supposed to handle such a small feature ;)
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.
Description
php spark routesprinted<unknown>in the Before/After Filters columns for any route using a custom placeholder registered with$routes->addPlaceholder().SampleURIGeneratorhad no sample for such placeholders and substituted::unknown::, producing a URI that matched no route, soFilterCollectorcould not resolve its filters. Filter execution at request time was unaffected. This was only the command's display, as confirmed in the issue.This adds two ways to obtain a sample URI for a custom placeholder:
PlaceholderSampleGeneratorderives a value from the placeholder's regular expression, covering the fragments common in route patterns (character classes, shorthand escapes, quantifiers, literals, top-level alternation, anchors). Patterns it cannot reverse (lookarounds, backreferences, named groups, etc.) returnnull, and every candidate is validated withpreg_matchbefore use.Config\Routing::$placeholderSampleslets you set or override the sample per placeholder. A value that does not match the placeholder regex is ignored.SampleURIGeneratorresolves each placeholder in this order: a matching$placeholderSamplesvalue, the built-in sample, an auto-generated value, then::unknown::. Results are memoized per placeholder.Common patterns such as
[A-Z]{3}[0-9]+and UUIDs now resolve without any configuration. The user guide, changelog, and upgrade notes are updated.Fixes #9804
Supersedes and closes #10206
Checklist: