From e4a7c8f3d79a44238b90dcb75ac038156d4d8b73 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 6 Aug 2011 21:15:31 -0400 Subject: [PATCH] Cleanup of minor issues found with phpmd. --- lib/Cake/Controller/Controller.php | 4 ++-- lib/Cake/Core/Configure.php | 2 +- lib/Cake/Log/CakeLog.php | 2 +- lib/Cake/Network/CakeRequest.php | 2 +- lib/Cake/Network/CakeResponse.php | 1 - lib/Cake/Routing/Route/CakeRoute.php | 9 ++++----- lib/Cake/Utility/Set.php | 21 --------------------- 7 files changed, 9 insertions(+), 32 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index a9ef54f20..079c83c4b 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -491,7 +491,7 @@ class Controller extends Object { if (!$privateAction && !empty($prefixes)) { if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { - list($prefix, $action) = explode('_', $request->params['action']); + list($prefix) = explode('_', $request->params['action']); $privateAction = in_array($prefix, $prefixes); } } @@ -877,7 +877,7 @@ class Controller extends Object { $currentObject = ClassRegistry::getObject($currentModel); if (is_a($currentObject, 'Model')) { $className = get_class($currentObject); - list($plugin, $package) = pluginSplit(App::location($className)); + list($plugin) = pluginSplit(App::location($className)); $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className'); $View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors; } diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 0add376a2..d91ee6d96 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -320,7 +320,7 @@ class Configure { */ public static function version() { if (!isset(self::$_values['Cake']['version'])) { - require(CAKE . 'Config' . DS . 'config.php'); + require CAKE . 'Config' . DS . 'config.php'; self::write($config); } return self::$_values['Cake']['version']; diff --git a/lib/Cake/Log/CakeLog.php b/lib/Cake/Log/CakeLog.php index 5bc37ae05..ecb685dbf 100644 --- a/lib/Cake/Log/CakeLog.php +++ b/lib/Cake/Log/CakeLog.php @@ -190,7 +190,7 @@ class CakeLog { if (empty(self::$_streams)) { self::_autoConfig(); } - foreach (self::$_streams as $key => $logger) { + foreach (self::$_streams as $logger) { $logger->write($type, $message); } return true; diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index eff630f1f..257d8ae30 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -613,7 +613,7 @@ class CakeRequest implements ArrayAccess { $acceptTypes = explode(',', $this->header('accept')); foreach ($acceptTypes as $i => $accepted) { if (strpos($accepted, ';') !== false) { - list($accepted, $prefValue) = explode(';', $accepted); + list($accepted) = explode(';', $accepted); $acceptTypes[$i] = $accepted; } } diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 57a6d9f6d..fe9534fe2 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -572,7 +572,6 @@ class CakeResponse { if (is_array($ctype)) { return array_map(array($this, 'mapType'), $ctype); } - $keys = array_keys($this->_mimeTypes); foreach ($this->_mimeTypes as $alias => $types) { if (is_array($types) && in_array($ctype, $types)) { diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index 79ae86bd0..23c473848 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -156,7 +156,7 @@ class CakeRoute { } $names[] = $name; } - if (preg_match('#\/\*$#', $route, $m)) { + if (preg_match('#\/\*$#', $route)) { $parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed); $this->_greedy = true; } @@ -281,7 +281,7 @@ class CakeRoute { if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); $hasRule = isset($rules[$key]); - $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($key, $val, $rules[$key], $context)); + $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); if ($passIt) { $pass[] = $param; } else { @@ -314,13 +314,12 @@ class CakeRoute { * Return true if a given named $param's $val matches a given $rule depending on $context. Currently implemented * rule types are controller, action and match that can be combined with each other. * - * @param string $param The name of the named parameter * @param string $val The value of the named parameter * @param array $rule The rule(s) to apply, can also be a match string * @param string $context An array with additional context information (controller / action) * @return boolean */ - protected function _matchNamed($param, $val, $rule, $context) { + protected function _matchNamed($val, $rule, $context) { if ($rule === true || $rule === false) { return $rule; } @@ -512,4 +511,4 @@ class CakeRoute { return $out; } -} \ No newline at end of file +} diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index bd4c742ed..4efd43563 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -130,27 +130,6 @@ class Set { return Set::__map($val, $class); } -/** - * Get the array value of $array. If $array is null, it will return - * the current array Set holds. If it is an object of type Set, it - * will return its value. If it is another object, its object variables. - * If it is anything else but an array, it will return an array whose first - * element is $array. - * - * @param mixed $array Data from where to get the array. - * @return array Array from $array. - */ - private function __array($array) { - if (empty($array)) { - $array = array(); - } elseif (is_object($array)) { - $array = get_object_vars($array); - } elseif (!is_array($array)) { - $array = array($array); - } - return $array; - } - /** * Maps the given value as an object. If $value is an object, * it returns $value. Otherwise it maps $value as an object of