diff --git a/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php index 9fd35ea112559..35f7af09c7599 100644 --- a/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php @@ -93,13 +93,18 @@ private function generateDeclaredRoutes() $properties[] = $compiledRoute->getHostTokens(); $properties[] = $route->getSchemes(); - $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); + $routes .= sprintf(" '%s' => %s,\n", $name, $this->exportArray($properties)); } - $routes .= ' )'; + $routes .= ' )'; return $routes; } + protected function exportArray($array) + { + return preg_replace(array('/array \(/', '/,\n *\)/', '/,\n */', '/\n */'), array('array(', ')', ', ', ''), var_export($array, true)); + } + /** * Generates PHP code representing the `generate` method that implements the UrlGeneratorInterface. * diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index c04605c3f7fef..3781f0b6bcb5f 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -98,7 +98,7 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac */ private function generateMatchMethod($supportsRedirections) { - $code = rtrim($this->compileRoutes($this->getRoutes(), $supportsRedirections), "\n"); + $code = $this->compileRoutes($this->getRoutes(), $supportsRedirections); return <<compilePrefixRoutes($route, $supportsRedirections, $optimizedPrefix); } else { - $code .= $this->compileRoute($route->getRoute(), $route->getName(), $supportsRedirections, $optimizedPrefix)."\n"; + $code .= $this->compileRoute($route->getRoute(), $route->getName(), $supportsRedirections, $optimizedPrefix); } + $code .= "\n\n"; } + $code = rtrim($code, "\n"); + if ($optimizable) { - $code .= " }\n\n"; + $code .= "\n }"; // apply extra indention at each line (except empty ones) $code = preg_replace('/^.{2,}$/m', ' $0', $code); } @@ -300,7 +305,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren if (!$supportsRedirections) { throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); } - $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); + $schemes = $this->exportArray(array_flip($schemes)); $code .= <<context->getScheme()])) { @@ -325,17 +330,17 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren $code .= sprintf( " return \$this->mergeDefaults(array_replace(%s), %s);\n", implode(', ', $vars), - str_replace("\n", '', var_export($route->getDefaults(), true)) + $this->exportArray($route->getDefaults()) ); } elseif ($route->getDefaults()) { - $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); + $code .= sprintf(" return %s;\n", $this->exportArray(array_replace($route->getDefaults(), array('_route' => $name)))); } else { $code .= sprintf(" return array('_route' => '%s');\n", $name); } - $code .= " }\n"; + $code .= ' }'; if ($methods) { - $code .= " $gotoname:\n"; + $code .= "\n $gotoname:"; } return $code; @@ -371,6 +376,11 @@ private function groupRoutesByHostRegex(RouteCollection $routes) return $groups; } + protected function exportArray($array) + { + return preg_replace(array('/array \(/', '/,\n *\)/', '/,\n */', '/\n */'), array('array(', ')', ', ', ''), var_export($array, true)); + } + /** * Organizes the routes into a prefix tree. * diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index 4ea0b8a1a3e7c..4b243286bcc6f 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -29,7 +29,7 @@ public function match($pathinfo) // foo if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array('def' => 'test')); } if (0 === strpos($pathinfo, '/bar')) { @@ -40,7 +40,7 @@ public function match($pathinfo) goto not_bar; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array()); } not_bar: @@ -51,10 +51,9 @@ public function match($pathinfo) goto not_barhead; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array()); } not_barhead: - } if (0 === strpos($pathinfo, '/test')) { @@ -73,12 +72,11 @@ public function match($pathinfo) if ($pathinfo === '/test/baz3/') { return array('_route' => 'baz3'); } - } // baz4 if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array()); } // baz5 @@ -88,7 +86,7 @@ public function match($pathinfo) goto not_baz5; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array()); } not_baz5: @@ -99,20 +97,19 @@ public function match($pathinfo) goto not_bazbaz6; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array()); } not_bazbaz6: - } // foofoo if ($pathinfo === '/foofoo') { - return array ( 'def' => 'test', '_route' => 'foofoo',); + return array('def' => 'test', '_route' => 'foofoo'); } // quoter if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array()); } // space @@ -124,40 +121,37 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a/b\'b')) { // foo1 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array()); } // bar1 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array()); } - } // overridden if (preg_match('#^/a/(?P.*)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array()); } if (0 === strpos($pathinfo, '/a/b\'b')) { // foo2 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array()); } // bar2 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array()); } - } - } if (0 === strpos($pathinfo, '/multi')) { // helloWorld if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array('who' => 'World!')); } // overridden2 @@ -169,17 +163,16 @@ public function match($pathinfo) if ($pathinfo === '/multi/hey/') { return array('_route' => 'hey'); } - } // foo3 if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array()); } // bar3 if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array()); } if (0 === strpos($pathinfo, '/aba')) { @@ -190,9 +183,8 @@ public function match($pathinfo) // foo4 if (preg_match('#^/aba/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array()); } - } $host = $this->context->getHost(); @@ -207,7 +199,6 @@ public function match($pathinfo) if ($pathinfo === '/c2/route2') { return array('_route' => 'route2'); } - } if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { @@ -215,7 +206,6 @@ public function match($pathinfo) if ($pathinfo === '/c2/route3') { return array('_route' => 'route3'); } - } if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { @@ -223,7 +213,6 @@ public function match($pathinfo) if ($pathinfo === '/route4') { return array('_route' => 'route4'); } - } if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { @@ -231,7 +220,6 @@ public function match($pathinfo) if ($pathinfo === '/route5') { return array('_route' => 'route5'); } - } // route6 @@ -243,47 +231,43 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/route1')) { // route11 if ($pathinfo === '/route11') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); + return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array()); } // route12 if ($pathinfo === '/route12') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); + return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array('var1' => 'val')); } // route13 if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); + return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array()); } // route14 if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); + return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array('var1' => 'val')); } - } - } if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { // route15 if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array()); } - } if (0 === strpos($pathinfo, '/route1')) { // route16 if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array('var1' => 'val')); } // route17 if ($pathinfo === '/route17') { return array('_route' => 'route17'); } - } if (0 === strpos($pathinfo, '/a')) { @@ -295,16 +279,14 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a/b')) { // b if (preg_match('#^/a/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array()); } // c if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array()); } - } - } throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index f9d3fa2d8257b..81e7e727395d5 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -29,7 +29,7 @@ public function match($pathinfo) // foo if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array('def' => 'test')); } if (0 === strpos($pathinfo, '/bar')) { @@ -40,7 +40,7 @@ public function match($pathinfo) goto not_bar; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array()); } not_bar: @@ -51,10 +51,9 @@ public function match($pathinfo) goto not_barhead; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array()); } not_barhead: - } if (0 === strpos($pathinfo, '/test')) { @@ -77,7 +76,6 @@ public function match($pathinfo) return array('_route' => 'baz3'); } - } // baz4 @@ -86,7 +84,7 @@ public function match($pathinfo) return $this->redirect($pathinfo.'/', 'baz4'); } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array()); } // baz5 @@ -96,7 +94,7 @@ public function match($pathinfo) goto not_baz5; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array()); } not_baz5: @@ -107,20 +105,19 @@ public function match($pathinfo) goto not_bazbaz6; } - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array()); } not_bazbaz6: - } // foofoo if ($pathinfo === '/foofoo') { - return array ( 'def' => 'test', '_route' => 'foofoo',); + return array('def' => 'test', '_route' => 'foofoo'); } // quoter if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array()); } // space @@ -132,40 +129,37 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a/b\'b')) { // foo1 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array()); } // bar1 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array()); } - } // overridden if (preg_match('#^/a/(?P.*)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array()); } if (0 === strpos($pathinfo, '/a/b\'b')) { // foo2 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array()); } // bar2 if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array()); } - } - } if (0 === strpos($pathinfo, '/multi')) { // helloWorld if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array('who' => 'World!')); } // overridden2 @@ -181,17 +175,16 @@ public function match($pathinfo) return array('_route' => 'hey'); } - } // foo3 if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array()); } // bar3 if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array()); } if (0 === strpos($pathinfo, '/aba')) { @@ -202,9 +195,8 @@ public function match($pathinfo) // foo4 if (preg_match('#^/aba/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array()); } - } $host = $this->context->getHost(); @@ -219,7 +211,6 @@ public function match($pathinfo) if ($pathinfo === '/c2/route2') { return array('_route' => 'route2'); } - } if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { @@ -227,7 +218,6 @@ public function match($pathinfo) if ($pathinfo === '/c2/route3') { return array('_route' => 'route3'); } - } if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { @@ -235,7 +225,6 @@ public function match($pathinfo) if ($pathinfo === '/route4') { return array('_route' => 'route4'); } - } if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { @@ -243,7 +232,6 @@ public function match($pathinfo) if ($pathinfo === '/route5') { return array('_route' => 'route5'); } - } // route6 @@ -255,47 +243,43 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/route1')) { // route11 if ($pathinfo === '/route11') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); + return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array()); } // route12 if ($pathinfo === '/route12') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); + return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array('var1' => 'val')); } // route13 if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); + return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array()); } // route14 if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); + return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array('var1' => 'val')); } - } - } if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { // route15 if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array()); } - } if (0 === strpos($pathinfo, '/route1')) { // route16 if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array('var1' => 'val')); } // route17 if ($pathinfo === '/route17') { return array('_route' => 'route17'); } - } if (0 === strpos($pathinfo, '/a')) { @@ -307,21 +291,19 @@ public function match($pathinfo) if (0 === strpos($pathinfo, '/a/b')) { // b if (preg_match('#^/a/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array()); } // c if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array()); } - } - } // secure if ($pathinfo === '/secure') { - $requiredSchemes = array ( 'https' => 0,); + $requiredSchemes = array('https' => 0); if (!isset($requiredSchemes[$this->context->getScheme()])) { return $this->redirect($pathinfo, 'secure', key($requiredSchemes)); } @@ -331,7 +313,7 @@ public function match($pathinfo) // nonsecure if ($pathinfo === '/nonsecure') { - $requiredSchemes = array ( 'http' => 0,); + $requiredSchemes = array('http' => 0); if (!isset($requiredSchemes[$this->context->getScheme()])) { return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes)); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index d9da7b02d4b43..c68811e1e7322 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -35,9 +35,8 @@ public function match($pathinfo) // dynamic if (preg_match('#^/rootprefix/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ()); + return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array()); } - } // with-condition