Cleanup of minor issues found with phpmd.

This commit is contained in:
mark_story 2011-08-06 21:15:31 -04:00
parent be262f30f0
commit e4a7c8f3d7
7 changed files with 9 additions and 32 deletions

View file

@ -491,7 +491,7 @@ class Controller extends Object {
if (!$privateAction && !empty($prefixes)) { if (!$privateAction && !empty($prefixes)) {
if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { 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); $privateAction = in_array($prefix, $prefixes);
} }
} }
@ -877,7 +877,7 @@ class Controller extends Object {
$currentObject = ClassRegistry::getObject($currentModel); $currentObject = ClassRegistry::getObject($currentModel);
if (is_a($currentObject, 'Model')) { if (is_a($currentObject, 'Model')) {
$className = get_class($currentObject); $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'); $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');
$View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors; $View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
} }

View file

@ -320,7 +320,7 @@ class Configure {
*/ */
public static function version() { public static function version() {
if (!isset(self::$_values['Cake']['version'])) { if (!isset(self::$_values['Cake']['version'])) {
require(CAKE . 'Config' . DS . 'config.php'); require CAKE . 'Config' . DS . 'config.php';
self::write($config); self::write($config);
} }
return self::$_values['Cake']['version']; return self::$_values['Cake']['version'];

View file

@ -190,7 +190,7 @@ class CakeLog {
if (empty(self::$_streams)) { if (empty(self::$_streams)) {
self::_autoConfig(); self::_autoConfig();
} }
foreach (self::$_streams as $key => $logger) { foreach (self::$_streams as $logger) {
$logger->write($type, $message); $logger->write($type, $message);
} }
return true; return true;

View file

@ -613,7 +613,7 @@ class CakeRequest implements ArrayAccess {
$acceptTypes = explode(',', $this->header('accept')); $acceptTypes = explode(',', $this->header('accept'));
foreach ($acceptTypes as $i => $accepted) { foreach ($acceptTypes as $i => $accepted) {
if (strpos($accepted, ';') !== false) { if (strpos($accepted, ';') !== false) {
list($accepted, $prefValue) = explode(';', $accepted); list($accepted) = explode(';', $accepted);
$acceptTypes[$i] = $accepted; $acceptTypes[$i] = $accepted;
} }
} }

View file

@ -572,7 +572,6 @@ class CakeResponse {
if (is_array($ctype)) { if (is_array($ctype)) {
return array_map(array($this, 'mapType'), $ctype); return array_map(array($this, 'mapType'), $ctype);
} }
$keys = array_keys($this->_mimeTypes);
foreach ($this->_mimeTypes as $alias => $types) { foreach ($this->_mimeTypes as $alias => $types) {
if (is_array($types) && in_array($ctype, $types)) { if (is_array($types) && in_array($ctype, $types)) {

View file

@ -156,7 +156,7 @@ class CakeRoute {
} }
$names[] = $name; $names[] = $name;
} }
if (preg_match('#\/\*$#', $route, $m)) { if (preg_match('#\/\*$#', $route)) {
$parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed); $parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed);
$this->_greedy = true; $this->_greedy = true;
} }
@ -281,7 +281,7 @@ class CakeRoute {
if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) {
list($key, $val) = explode($namedConfig['separator'], $param, 2); list($key, $val) = explode($namedConfig['separator'], $param, 2);
$hasRule = isset($rules[$key]); $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) { if ($passIt) {
$pass[] = $param; $pass[] = $param;
} else { } 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 * 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. * 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 string $val The value of the named parameter
* @param array $rule The rule(s) to apply, can also be a match string * @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) * @param string $context An array with additional context information (controller / action)
* @return boolean * @return boolean
*/ */
protected function _matchNamed($param, $val, $rule, $context) { protected function _matchNamed($val, $rule, $context) {
if ($rule === true || $rule === false) { if ($rule === true || $rule === false) {
return $rule; return $rule;
} }

View file

@ -130,27 +130,6 @@ class Set {
return Set::__map($val, $class); 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, * Maps the given value as an object. If $value is an object,
* it returns $value. Otherwise it maps $value as an object of * it returns $value. Otherwise it maps $value as an object of