diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 80d00e39d5..2c420d9446 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -75,6 +75,7 @@ EOF; $routeIterator = $routes->getIterator(); $keys = array_keys($routeIterator->getArrayCopy()); + $keysCount = count($keys); $i = 0; @@ -86,8 +87,10 @@ EOF; $optimizable = $prefix && count($route->all()) > 1 && false === strpos($route->getPrefix(), '{'); $indent = ''; if ($optimizable) { - for ($j = $i; $j < count($keys); $j++) { - if ($keys[$j] === null) continue; + for ($j = $i; $j < $keysCount; $j++) { + if ($keys[$j] === null) { + continue; + } $testRoute = $routeIterator->offsetGet($keys[$j]); $isCollection = ($testRoute instanceof RouteCollection);