8000 [Routing] fixed indentation of dumped collections · jeremymarc/symfony@d428341 · GitHub
[go: up one dir, main page]

Skip to content

Commit d428341

Browse files
committed
[Routing] fixed indentation of dumped collections
1 parent 2ab9974 commit d428341

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ private function countDirectChildRoutes(RouteCollection $routes)
130130
private function compileRoutes(RouteCollection $routes, $supportsRedirections)
131131
{
132132
$code = '';
133-
$indent = 0;
134133
$collections = $this->groupRoutesByHostnameRegex($routes)->getRoot();
135134
$fetchedHostname = false;
136135

137136
foreach ($collections as $collection) {
137+
$indent = 0;
138+
138139
if ($regex = $collection->get('hostname_regex')) {
139140
if (!$fetchedHostname) {
140141
$code .= " \$hostname = \$this->context->getHost();\n\n";
@@ -151,7 +152,6 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)
151152
$code .= $this->indentCode($lines, $indent);
152153

153154
if ($regex) {
154-
$indent = 0;
155155
$code .= " }\n\n";
156156
}
157157
}
@@ -184,7 +184,6 @@ private function compilePrefixRoutes(DumperPrefixCollection $collection, $suppor
184184
}
185185

186186
if ($optimizable) {
187-
$indent = 0;
188187
$code .= " }\n\n";
189188
}
190189

@@ -352,7 +351,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
352351
*/
353352
private function indentCode($lines, $width)
354353
{
355-
return preg_replace('#^(?=.)#', str_repeat(' ', $width), $lines);
354+
return preg_replace('#^(?=.)#m', str_repeat(' ', $width), $lines);
356355
}
357356

358357
/**

src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public function testDump(RouteCollection $collection, $fixture, $options = array
4242
$basePath = __DIR__.'/../../Fixtures/dumper/';
4343

4444
$dumper = new PhpMatcherDumper($collection, new RequestContext());
45-
46-
file_put_contents('/tmp/' . $fixture, $dumper->dump($options));
45+
file_put_contents('/tmp/'.$fixture, $dumper->dump($options));
4746
$this->assertStringEqualsFile($basePath.$fixture, $dumper->dump($options), '->dump() correctly dumps routes as optimized PHP code.');
4847
}
4948

0 commit comments

Comments
 (0)
0