@@ -97,8 +97,8 @@ private function resolveSample(string $placeholder, string $regex): string
9797 return $ this ->resolvedCache [$ placeholder ];
9898 }
9999
100- $ sample = $ this ->configuredSample ( $ placeholder , $ regex )
101- ?? $ this ->samples [$ placeholder ]
100+ $ sample = $ this ->matchingSample ( $ this -> config -> placeholderSamples [ $ placeholder] ?? null , $ regex )
101+ ?? $ this ->matchingSample ( $ this -> samples [$ placeholder ] ?? null , $ regex )
102102 ?? $ this ->sampleGenerator ->generate ($ regex )
103103 ?? self ::UNKNOWN_SAMPLE ;
104104
@@ -108,14 +108,14 @@ private function resolveSample(string $placeholder, string $regex): string
108108 }
109109
110110 /**
111- * Returns the configured sample for the placeholder when one is set and it
112- * matches the placeholder regex, otherwise ``null`` so resolution falls
113- * through to the built-in, auto-generated, or unknown sample.
111+ * Returns the given sample when it is set and matches the placeholder
112+ * regex, otherwise ``null`` so resolution falls through to the next source.
113+ * Guards both the configured and built-in samples, since a built-in
114+ * placeholder name may be redefined with a different regex via
115+ * ``RouteCollection::addPlaceholder()``.
114116 */
115- private function configuredSample ( string $ placeholder , string $ regex ): ?string
117+ private function matchingSample (? string $ sample , string $ regex ): ?string
116118 {
117- $ sample = $ this ->config ->placeholderSamples [$ placeholder ] ?? null ;
118-
119119 if ($ sample === null ) {
120120 return null ;
121121 }
0 commit comments