Skip to content

Commit f5077aa

Browse files
committed
update for all in one pregmatch
1 parent 4da1d65 commit f5077aa

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/Symfony/Component/Routing/Loader/AttributeClassLoader.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,14 @@ protected function addRoute(RouteCollection $collection, object $attr, array $gl
219219
continue;
220220
}
221221
foreach ($paths as $locale => $path) {
222-
if (preg_match(\sprintf('/\{%s(?:<.*?>)?\}/', preg_quote($param->name)), $path)) {
222+
if (preg_match(\sprintf('/\{(?|([^\:]++):%s(?:\.[^\}<]++)?|(%1$s))(?:<.*?>)?\}/', preg_quote($param->name)), $path, $matches)) {
223223
if (\is_scalar($defaultValue = $param->getDefaultValue()) || null === $defaultValue) {
224-
$defaults[$param->name] = $defaultValue;
224+
$defaults[$matches[1]] = $defaultValue;
225225
} elseif ($defaultValue instanceof \BackedEnum) {
226-
$defaults[$param->name] = $defaultValue->value;
226+
$defaults[$matches[1]] = $defaultValue->value;
227227
}
228228
break;
229229
}
230-
231-
if (preg_match(\sprintf('/\{(?<argName>[^\:]+):%s(?:(\.[^\}]+)?)\}/', preg_quote($param->name)), $path, $matches)) {
232-
$defaults[$matches['argName']] = $param->getDefaultValue();
233-
break;
234-
}
235230
}
236231
}
237232

0 commit comments

Comments
 (0)