Skip to content

Commit

Permalink
Cleanup of minor issues found with phpmd.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 7, 2011
1 parent be262f3 commit e4a7c8f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 32 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Controller.php
Expand Up @@ -491,7 +491,7 @@ protected function _isPrivateAction(ReflectionMethod $method, CakeRequest $reque

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);
}
}
Expand Down Expand Up @@ -877,7 +877,7 @@ public function render($view = null, $layout = null) {
$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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Core/Configure.php
Expand Up @@ -320,7 +320,7 @@ public static function load($key, $config = 'default', $merge = true) {
*/
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'];
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Log/CakeLog.php
Expand Up @@ -190,7 +190,7 @@ public static function write($type, $message) {
if (empty(self::$_streams)) {
self::_autoConfig();
}
foreach (self::$_streams as $key => $logger) {
foreach (self::$_streams as $logger) {
$logger->write($type, $message);
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -613,7 +613,7 @@ public function accepts($type = null) {
$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;
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Network/CakeResponse.php
Expand Up @@ -572,7 +572,6 @@ public function mapType($ctype) {
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)) {
Expand Down
9 changes: 4 additions & 5 deletions lib/Cake/Routing/Route/CakeRoute.php
Expand Up @@ -156,7 +156,7 @@ protected function _writeRoute() {
}
$names[] = $name;
}
if (preg_match('#\/\*$#', $route, $m)) {
if (preg_match('#\/\*$#', $route)) {
$parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed);
$this->_greedy = true;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ protected function _parseArgs($args, $context) {
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 {
Expand Down Expand Up @@ -314,13 +314,12 @@ protected function _parseArgs($args, $context) {
* 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;
}
Expand Down Expand Up @@ -512,4 +511,4 @@ protected function _writeUrl($params) {
return $out;
}

}
}
21 changes: 0 additions & 21 deletions lib/Cake/Utility/Set.php
Expand Up @@ -130,27 +130,6 @@ public static function map($class = 'stdClass', $tmp = 'stdClass') {
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
Expand Down

0 comments on commit e4a7c8f

Please sign in to comment.