From 833ca68a554aea8fc6b0a7a77931f73908c50f95 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 20 Oct 2014 16:35:53 -0400 Subject: [PATCH] Replaced for loops by foreach --- lib/Cake/Routing/Router.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index f5768ebbd..14891d4eb 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -610,11 +610,9 @@ class Router { extract(self::_parseExtension($url)); - for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { - $route =& self::$routes[$i]; - + foreach (self::$routes as $route) { if (($r = $route->parse($url)) !== false) { - self::$_currentRoute[] =& $route; + self::$_currentRoute[] = $route; $out = $r; break; } @@ -906,12 +904,12 @@ class Router { $match = false; - for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { + foreach (self::$routes as $route) { $originalUrl = $url; - $url = self::$routes[$i]->persistParams($url, $params); + $url = $route->persistParams($url, $params); - if ($match = self::$routes[$i]->match($url)) { + if ($match = $route->match($url)) { $output = trim($match, '/'); break; } @@ -995,12 +993,10 @@ class Router { ); $keys = array_values(array_diff(array_keys($url), $skip)); - $count = count($keys); // Remove this once parsed URL parameters can be inserted into 'pass' - for ($i = 0; $i < $count; $i++) { - $key = $keys[$i]; - if (is_numeric($keys[$i])) { + foreach ($keys as $key) { + if (is_numeric($key)) { $args[] = $url[$key]; } else { $named[$key] = $url[$key];