Replaced for loops by foreach

This commit is contained in:
Juan Basso 2014-10-20 16:35:53 -04:00
parent 6b723b9327
commit 833ca68a55

View file

@ -610,11 +610,9 @@ class Router {
extract(self::_parseExtension($url)); extract(self::_parseExtension($url));
for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { foreach (self::$routes as $route) {
$route =& self::$routes[$i];
if (($r = $route->parse($url)) !== false) { if (($r = $route->parse($url)) !== false) {
self::$_currentRoute[] =& $route; self::$_currentRoute[] = $route;
$out = $r; $out = $r;
break; break;
} }
@ -906,12 +904,12 @@ class Router {
$match = false; $match = false;
for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { foreach (self::$routes as $route) {
$originalUrl = $url; $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, '/'); $output = trim($match, '/');
break; break;
} }
@ -995,12 +993,10 @@ class Router {
); );
$keys = array_values(array_diff(array_keys($url), $skip)); $keys = array_values(array_diff(array_keys($url), $skip));
$count = count($keys);
// Remove this once parsed URL parameters can be inserted into 'pass' // Remove this once parsed URL parameters can be inserted into 'pass'
for ($i = 0; $i < $count; $i++) { foreach ($keys as $key) {
$key = $keys[$i]; if (is_numeric($key)) {
if (is_numeric($keys[$i])) {
$args[] = $url[$key]; $args[] = $url[$key];
} else { } else {
$named[$key] = $url[$key]; $named[$key] = $url[$key];