Repository: symfony/symfony
File: src/Symfony/Component/Routing/Loader/AttributeClassLoader.php (PHP)

Code before:
                    $paths[$locale] = $prefix[$locale].$localePath;
                }
            }
        } elseif (\is_array($prefix)) {
            foreach ($prefix as $locale => $localePrefix) {
                $paths[$locale] = $localePrefix.$path;
            }
        } else {
            $paths[] = $prefix.$path;
        }

        foreach ($method->getParameters() as $param) {
            if (isset($defaults[$param->name]) || !$param->isDefaultValueAvailable()) {
                continue;
            }
            foreach ($paths as $locale => $path) {
                if (preg_match(\sprintf('/\{%s(?:<.*?>)?\}/', preg_quote($param->name)), $path)) {
                    if (\is_scalar($defaultValue = $param->getDefaultValue()) || null === $defaultValue) {
                        $defaults[$param->name] = $defaultValue;
                    } elseif ($defaultValue instanceof \BackedEnum) {
                        $defaults[$param->name] = $defaultValue->value;
                    }
                    break;
                }

                if (preg_match(\sprintf('/\{(?<argName>[^\:]+):%s(?:(\.[^\}]+)?)\}/', preg_quote($param->name)), $path, $matches)) {
                    $defaults[$matches['argName']] = $param->getDefaultValue();
                    break;
                }
            }
        }

        foreach ($paths as $locale => $path) {
            $route = $this->createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
            $this->configureRoute($route, $class, $method, $attr);
            if (0 !== $locale) {
                $route->setDefault('_locale', $locale);
                $route->setRequirement('_locale', preg_quote($locale));
                $route->setDefault('_canonical_route', $name);
                $collection->add($name.'.'.$locale, $route, $priority);
            } else {
                $collection->add($name, $route, $priority);
            }
            foreach ($attr->getAliases() as $aliasAttribute) {
                if ($aliasAttribute instanceof DeprecatedAlias) {
                    $alias = $collection->addAlias($aliasAttribute->getAliasName(), $name);
                    $alias->setDeprecated(
                        $aliasAttribute->getPackage(),
                        $aliasAttribute->getVersion(),
                        $aliasAttribute->getMessage()
                    );

Review comment (suggestion):
```suggestion
                if (preg_match(\sprintf('/\{(?<argName>[^\:]++):%s(?:(\.[^\}]++)?)\}/', preg_quote($param->name)), $path, $matches)) {
```

Code after:
                    $paths[$locale] = $prefix[$locale].$localePath;
                }
            }
        } elseif (\is_array($prefix)) {
            foreach ($prefix as $locale => $localePrefix) {
                $paths[$locale] = $localePrefix.$path;
            }
        } else {
            $paths[] = $prefix.$path;
        }

        foreach ($method->getParameters() as $param) {
            if (isset($defaults[$param->name]) || !$param->isDefaultValueAvailable()) {
                continue;
            }
            foreach ($paths as $locale => $path) {
                if (preg_match(\sprintf('/\{(?|([^\}:<]++):%s(?:\.[^\}<]++)?|(%1$s))(?:<.*?>)?\}/', preg_quote($param->name)), $path, $matches)) {
                    if (\is_scalar($defaultValue = $param->getDefaultValue()) || null === $defaultValue) {
                        $defaults[$matches[1]] = $defaultValue;
                    } elseif ($defaultValue instanceof \BackedEnum) {
                        $defaults[$matches[1]] = $defaultValue->value;
                    }
                    break;
                }
            }
        }

        foreach ($paths as $locale => $path) {
            $route = $this->createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
            $this->configureRoute($route, $class, $method, $attr);
            if (0 !== $locale) {
                $route->setDefault('_locale', $locale);
                $route->setRequirement('_locale', preg_quote($locale));
                $route->setDefault('_canonical_route', $name);
                $collection->add($name.'.'.$locale, $route, $priority);
            } else {
                $collection->add($name, $route, $priority);
            }
            foreach ($attr->getAliases() as $aliasAttribute) {
                if ($aliasAttribute instanceof DeprecatedAlias) {
                    $alias = $collection->addAlias($aliasAttribute->getAliasName(), $name);
                    $alias->setDeprecated(
                        $aliasAttribute->getPackage(),
                        $aliasAttribute->getVersion(),
                        $aliasAttribute->getMessage()
                    );
                    continue;
                }

                $collection->addAlias($aliasAttribute, $name);
            }