Skip to content

Commit 736d0be

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Translation] [Bridge] [Lokalise] do not export empty strings [Lock] Use platform to identify the PDO driver fix merge [HttpFoundation] Update http messages of statuses 413 and 422 [DependencyInjection] fix support for "new" in initializers on PHP 8.1 added missing trasnlations in Greek add translation for zh_TW 41830 missing translations for serbian sr latn Changed some translations to be more in line with native Serbian language [HttpFoundation] Fix ianaCodesReasonPhrasesProvider to consume a local file Add armenian translation for #41835 Add swedish translation for #41835 Added missing danish translations and fixed typo in validators.da.xlf [FrameworkBundle] Minor improvement - No `array_merge` in loop
2 parents 54788c6 + 9139475 commit 736d0be

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

Routing/Router.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ private function resolveParameters(RouteCollection $collection)
130130

131131
$schemes = [];
132132
foreach ($route->getSchemes() as $scheme) {
133-
$schemes = array_merge($schemes, explode('|', $this->resolve($scheme)));
133+
$schemes[] = explode('|', $this->resolve($scheme));
134134
}
135-
$route->setSchemes($schemes);
135+
$route->setSchemes(array_merge([], ...$schemes));
136136

137137
$methods = [];
138138
foreach ($route->getMethods() as $method) {
139-
$methods = array_merge($methods, explode('|', $this->resolve($method)));
139+
$methods[] = explode('|', $this->resolve($method));
140140
}
141-
$route->setMethods($methods);
141+
$route->setMethods(array_merge([], ...$methods));
142142
$route->setCondition($this->resolve($route->getCondition()));
143143
}
144144
}

Tests/Routing/RouterTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,44 @@ public function testCacheValidityWithContainerParameters($parameter)
553553
}
554554
}
555555

556+
public function testResolvingSchemes()
557+
{
558+
$routes = new RouteCollection();
559+
560+
$route = new Route('/test', [], [], [], '', ['%parameter.http%', '%parameter.https%']);
561+
$routes->add('foo', $route);
562+
563+
$sc = $this->getPsr11ServiceContainer($routes);
564+
$parameters = $this->getParameterBag([
565+
'parameter.http' => 'http',
566+
'parameter.https' => 'https',
567+
]);
568+
569+
$router = new Router($sc, 'foo', [], null, $parameters);
570+
$route = $router->getRouteCollection()->get('foo');
571+
572+
$this->assertEquals(['http', 'https'], $route->getSchemes());
573+
}
574+
575+
public function testResolvingMethods()
576+
{
577+
$routes = new RouteCollection();
578+
579+
$route = new Route('/test', [], [], [], '', [], ['%parameter.get%', '%parameter.post%']);
580+
$routes->add('foo', $route);
581+
582+
$sc = $this->getPsr11ServiceContainer($routes);
583+
$parameters = $this->getParameterBag([
584+
'PARAMETER.GET' => 'GET',
585+
'PARAMETER.POST' => 'POST',
586+
]);
587+
588+
$router = new Router($sc, 'foo', [], null, $parameters);
589+
$route = $router->getRouteCollection()->get('foo');
590+
591+
$this->assertEquals(['GET', 'POST'], $route->getMethods());
592+
}
593+
556594
public function getContainerParameterForRoute()
557595
{
558596
yield 'String' => ['"foo"'];

0 commit comments

Comments
 (0)