Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code standards formatting #380

Merged
merged 2 commits into from Dec 16, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/ApiShell.php
Expand Up @@ -101,7 +101,7 @@ public function main() {
$this->_stop();
}
$method = $parsed[$this->params['method']];
$this->out($class .'::'.$method['method'] . $method['parameters']);
$this->out($class . '::' . $method['method'] . $method['parameters']);
$this->hr();
$this->out($method['comment'], true);
} else {
Expand All @@ -127,7 +127,7 @@ public function main() {
if (isset($methods[--$number])) {
$method = $parsed[$methods[$number]];
$this->hr();
$this->out($class .'::'.$method['method'] . $method['parameters']);
$this->out($class . '::' . $method['method'] . $method['parameters']);
$this->hr();
$this->out($method['comment'], true);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/Task/ProjectTask.php
Expand Up @@ -269,7 +269,7 @@ public function securitySalt($path) {
$contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.salt\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \'' . $string . '\');', $contents);
if ($File->write($result)) {
return true;
}
Expand All @@ -290,7 +290,7 @@ public function securityCipherSeed($path) {
if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
App::uses('Security', 'Utility');
$string = substr(bin2hex(Security::generateAuthKey()), 0, 30);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \'' . $string . '\');', $contents);
if ($File->write($result)) {
return true;
}
Expand Down Expand Up @@ -357,7 +357,7 @@ public function cakeAdmin($name) {
$File = new File($path . 'core.php');
$contents = $File->read();
if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) {
$result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', array(\''.$name.'\'));', $contents);
$result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', array(\'' . $name . '\'));', $contents);
if ($File->write($result)) {
Configure::write('Routing.prefixes', array($name));
return true;
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Controller/Component/AclComponent.php
Expand Up @@ -488,11 +488,11 @@ public function getAclLink($aro, $aco) {
}

return array(
'aro' => Set::extract($obj, 'Aro.0.'.$this->Aro->alias.'.id'),
'aco' => Set::extract($obj, 'Aco.0.'.$this->Aco->alias.'.id'),
'aro' => Set::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id'),
'aco' => Set::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id'),
'link' => $this->Aro->Permission->find('all', array('conditions' => array(
$this->Aro->Permission->alias . '.aro_id' => Set::extract($obj, 'Aro.0.'.$this->Aro->alias.'.id'),
$this->Aro->Permission->alias . '.aco_id' => Set::extract($obj, 'Aco.0.'.$this->Aco->alias.'.id')
$this->Aro->Permission->alias . '.aro_id' => Set::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id'),
$this->Aro->Permission->alias . '.aco_id' => Set::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id')
)))
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Controller/Controller.php
Expand Up @@ -981,7 +981,7 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl
$arrayOp = is_array($op);
foreach ($data as $model => $fields) {
foreach ($fields as $field => $value) {
$key = $model.'.'.$field;
$key = $model . '.' . $field;
$fieldOp = $op;
if ($arrayOp) {
if (array_key_exists($key, $op)) {
Expand All @@ -998,9 +998,9 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl
$fieldOp = strtoupper(trim($fieldOp));
if ($fieldOp === 'LIKE') {
$key = $key.' LIKE';
$value = '%'.$value.'%';
$value = '%' . $value . '%';
} elseif ($fieldOp && $fieldOp != '=') {
$key = $key.' '.$fieldOp;
$key = $key.' ' . $fieldOp;
}
$cond[$key] = $value;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Core/App.php
Expand Up @@ -656,7 +656,7 @@ protected static function _loadClass($name, $plugin, $type, $originalType, $pare
}
App::uses($extends, $extendType);
if ($plugin && in_array($originalType, array('controller', 'model'))) {
App::uses($plugin . $extends, $plugin . '.' .$type);
App::uses($plugin . $extends, $plugin . '.' . $type);
}
}
if ($plugin) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/I18n/I18n.php
Expand Up @@ -164,7 +164,7 @@ public static function translate($singular, $plural = null, $domain = null, $cat
}

if ($_this->category == 'LC_TIME') {
return $_this->_translateTime($singular,$domain);
return $_this->_translateTime($singular, $domain);
}

if (!isset($count)) {
Expand Down Expand Up @@ -466,7 +466,7 @@ protected function _loadPo($file, $domain) {
} while (!feof($file));
fclose($file);
$merge[""] = $header;
return $this->_domains[$domain][$this->_lang][$this->category] = array_merge($merge ,$translations);
return $this->_domains[$domain][$this->_lang][$this->category] = array_merge($merge, $translations);
}

/**
Expand All @@ -486,7 +486,7 @@ protected function _loadLocaleDefinition($file, $domain = null) {
if (empty($line) || $line[0] === $comment) {
continue;
}
$parts = preg_split("/[[:space:]]+/",$line);
$parts = preg_split("/[[:space:]]+/", $line);
if ($parts[0] === 'comment_char') {
$comment = $parts[1];
continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/I18n/Multibyte.php
Expand Up @@ -893,7 +893,7 @@ public static function strtoupper($string) {
* @param string $haystack The string being checked.
* @param string $needle The string being found.
* @return integer The number of times the $needle substring occurs in the $haystack string.
*/
*/
public static function substrCount($haystack, $needle) {
$count = 0;
$haystack = Multibyte::utf8($haystack);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/AclNode.php
Expand Up @@ -95,7 +95,7 @@ public function node($ref = null) {
$queryData['joins'][] = array(
'table' => $table,
'alias' => "{$type}{$i}",
'type' => 'LEFT',
'type' => 'LEFT',
'conditions' => array(
$db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"),
$db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"),
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Behavior/ContainableBehavior.php
Expand Up @@ -308,10 +308,10 @@ public function containments($Model, $contain, $containments = array(), $throwEr
$val = preg_split('/\s*,\s*/', substr(substr($key, 1), 0, -1));
} elseif (preg_match('/ASC|DESC$/', $key)) {
$option = 'order';
$val = $Model->{$name}->alias.'.'.$key;
$val = $Model->{$name}->alias . '.' . $key;
} elseif (preg_match('/[ =!]/', $key)) {
$option = 'conditions';
$val = $Model->{$name}->alias.'.'.$key;
$val = $Model->{$name}->alias . '.' . $key;
}
$children[$option] = is_array($val) ? $val : array($val);
$newChildren = null;
Expand Down
38 changes: 19 additions & 19 deletions lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -103,8 +103,8 @@ public function beforeFind($model, $query) {
$joinTable->tablePrefix = $tablePrefix;
$joinTable->table = $RuntimeModel->table;

if (is_string($query['fields']) && 'COUNT(*) AS '.$db->name('count') == $query['fields']) {
$query['fields'] = 'COUNT(DISTINCT('.$db->name($model->alias . '.' . $model->primaryKey) . ')) ' . $db->alias . 'count';
if (is_string($query['fields']) && 'COUNT(*) AS ' . $db->name('count') == $query['fields']) {
$query['fields'] = 'COUNT(DISTINCT(' . $db->name($model->alias . '.' . $model->primaryKey) . ')) ' . $db->alias . 'count';
$query['joins'][] = array(
'type' => 'INNER',
'alias' => $RuntimeModel->alias,
Expand All @@ -126,7 +126,7 @@ public function beforeFind($model, $query) {
foreach ($fields as $key => $value) {
$field = (is_numeric($key)) ? $value : $key;

if (in_array($model->alias.'.*', $query['fields']) || in_array($model->alias.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) {
if (in_array($model->alias.'.*', $query['fields']) || in_array($model->alias.'.' . $field, $query['fields']) || in_array($field, $query['fields'])) {
$addFields[] = $field;
}
}
Expand All @@ -137,7 +137,7 @@ public function beforeFind($model, $query) {
foreach ($addFields as $_f => $field) {
$aliasField = is_numeric($_f) ? $field : $_f;

foreach (array($aliasField, $model->alias.'.'.$aliasField) as $_field) {
foreach (array($aliasField, $model->alias . '.' . $aliasField) as $_field) {
$key = array_search($_field, (array)$query['fields']);

if ($key !== false) {
Expand All @@ -147,36 +147,36 @@ public function beforeFind($model, $query) {

if (is_array($locale)) {
foreach ($locale as $_locale) {
$model->virtualFields['i18n_'.$field.'_'.$_locale] = 'I18n__'.$field.'__'.$_locale.'.content';
$model->virtualFields['i18n_' . $field . '_' . $_locale] = 'I18n__' . $field . '__' . $_locale . '.content';
if (!empty($query['fields'])) {
$query['fields'][] = 'i18n_'.$field.'_'.$_locale;
$query['fields'][] = 'i18n_' . $field . '_' . $_locale;
}
$query['joins'][] = array(
'type' => 'LEFT',
'alias' => 'I18n__'.$field.'__'.$_locale,
'alias' => 'I18n__' . $field . '__' . $_locale,
'table' => $joinTable,
'conditions' => array(
$model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}__{$_locale}.foreign_key"),
'I18n__'.$field.'__'.$_locale.'.model' => $model->name,
'I18n__'.$field.'__'.$_locale.'.'.$RuntimeModel->displayField => $aliasField,
'I18n__'.$field.'__'.$_locale.'.locale' => $_locale
'I18n__' . $field . '__' . $_locale . '.model' => $model->name,
'I18n__' . $field . '__' . $_locale . '.' . $RuntimeModel->displayField => $aliasField,
'I18n__' . $field . '__' . $_locale . '.locale' => $_locale
)
);
}
} else {
$model->virtualFields['i18n_'.$field] = 'I18n__'.$field.'.content';
$model->virtualFields['i18n_' . $field] = 'I18n__' . $field . '.content';
if (!empty($query['fields'])) {
$query['fields'][] = 'i18n_'.$field;
$query['fields'][] = 'i18n_' . $field;
}
$query['joins'][] = array(
'type' => 'INNER',
'alias' => 'I18n__'.$field,
'alias' => 'I18n__' . $field,
'table' => $joinTable,
'conditions' => array(
$model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}.foreign_key"),
'I18n__'.$field.'.model' => $model->name,
'I18n__'.$field.'.'.$RuntimeModel->displayField => $aliasField,
'I18n__'.$field.'.locale' => $locale
'I18n__' . $field . '.model' => $model->name,
'I18n__' . $field . '.' . $RuntimeModel->displayField => $aliasField,
'I18n__' . $field . '.locale' => $locale
)
);
}
Expand Down Expand Up @@ -211,11 +211,11 @@ public function afterFind($model, $results, $primary) {

if (is_array($locale)) {
foreach ($locale as $_locale) {
if (!isset($row[$model->alias][$aliasField]) && !empty($row[$model->alias]['i18n_'.$field.'_'.$_locale])) {
$row[$model->alias][$aliasField] = $row[$model->alias]['i18n_'.$field.'_'.$_locale];
if (!isset($row[$model->alias][$aliasField]) && !empty($row[$model->alias]['i18n_' . $field . '_' . $_locale])) {
$row[$model->alias][$aliasField] = $row[$model->alias]['i18n_' . $field . '_' . $_locale];
$row[$model->alias]['locale'] = $_locale;
}
unset($row[$model->alias]['i18n_'.$field.'_'.$_locale]);
unset($row[$model->alias]['i18n_' . $field . '_' . $_locale]);
}

if (!isset($row[$model->alias][$aliasField])) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Model/Behavior/TreeBehavior.php
Expand Up @@ -163,8 +163,8 @@ public function beforeSave($Model) {
$this->_addToWhitelist($Model, $parent);
} else {
$values = $Model->find('first', array(
'conditions' => array($scope,$Model->escapeField() => $Model->id),
'fields' => array($Model->primaryKey, $parent, $left, $right ), 'recursive' => $recursive)
'conditions' => array($scope, $Model->escapeField() => $Model->id),
'fields' => array($Model->primaryKey, $parent, $left, $right), 'recursive' => $recursive)
);

if ($values === false) {
Expand Down Expand Up @@ -503,7 +503,7 @@ public function moveUp($Model, $id = null, $number = 1) {
extract($this->settings[$Model->alias]);
list($node) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $id),
'fields' => array($Model->primaryKey, $left, $right, $parent ), 'recursive' => $recursive
'fields' => array($Model->primaryKey, $left, $right, $parent), 'recursive' => $recursive
)));
if ($node[$parent]) {
list($parentNode) = array_values($Model->find('first', array(
Expand All @@ -527,7 +527,7 @@ public function moveUp($Model, $id = null, $number = 1) {
}
$edge = $this->_getMax($Model, $scope, $right, $recursive);
$this->_sync($Model, $edge - $previousNode[$left] +1, '+', 'BETWEEN ' . $previousNode[$left] . ' AND ' . $previousNode[$right]);
$this->_sync($Model, $node[$left] - $previousNode[$left], '-', 'BETWEEN ' .$node[$left] . ' AND ' . $node[$right]);
$this->_sync($Model, $node[$left] - $previousNode[$left], '-', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right]);
$this->_sync($Model, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge);
if (is_int($number)) {
$number--;
Expand Down
16 changes: 8 additions & 8 deletions lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -67,7 +67,7 @@ class Postgres extends DboSource {
*/
public $columns = array(
'primary_key' => array('name' => 'serial NOT NULL'),
'string' => array('name' => 'varchar', 'limit' => '255'),
'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'),
'integer' => array('name' => 'integer', 'formatter' => 'intval'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
Expand All @@ -78,7 +78,7 @@ class Postgres extends DboSource {
'binary' => array('name' => 'bytea'),
'boolean' => array('name' => 'boolean'),
'number' => array('name' => 'numeric'),
'inet' => array('name' => 'inet')
'inet' => array('name' => 'inet')
);

/**
Expand Down Expand Up @@ -218,14 +218,14 @@ public function describe($model) {
$length = null;
}
$fields[$c->name] = array(
'type' => $this->column($type),
'null' => ($c->null == 'NO' ? false : true),
'type' => $this->column($type),
'null' => ($c->null == 'NO' ? false : true),
'default' => preg_replace(
"/^'(.*)'$/",
"$1",
preg_replace('/::.*/', '', $c->default)
),
'length' => $length
'length' => $length
);
if ($model instanceof Model) {
if ($c->name == $model->primaryKey) {
Expand Down Expand Up @@ -412,7 +412,7 @@ protected function _quoteFunctionField($match) {
$match[1] = $this->name($match[1]);
}
}
return '(' . $prepend .$match[1] . ')';
return '(' . $prepend . $match[1] . ')';
}

/**
Expand Down Expand Up @@ -480,13 +480,13 @@ public function alterSchema($compare, $table = null) {
case 'add':
foreach ($column as $field => $col) {
$col['name'] = $field;
$colList[] = 'ADD COLUMN '.$this->buildColumn($col);
$colList[] = 'ADD COLUMN ' . $this->buildColumn($col);
}
break;
case 'drop':
foreach ($column as $field => $col) {
$col['name'] = $field;
$colList[] = 'DROP COLUMN '.$this->name($field);
$colList[] = 'DROP COLUMN ' . $this->name($field);
}
break;
case 'change':
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Sqlite.php
Expand Up @@ -238,7 +238,7 @@ public function column($real) {
if (is_array($real)) {
$col = $real['name'];
if (isset($real['limit'])) {
$col .= '('.$real['limit'].')';
$col .= '(' . $real['limit'] . ')';
}
return $col;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -302,7 +302,7 @@ public function fields($model, $alias = null, $fields = array(), $quote = true)
$fieldAlias = $this->name($alias . '__' . $fields[$i]);
} else {
$build = explode('.', $fields[$i]);
$this->_fieldMappings[$build[0] . '__' .$build[1]] = $fields[$i];
$this->_fieldMappings[$build[0] . '__' . $build[1]] = $fields[$i];
$fieldName = $this->name($build[0] . '.' . $build[1]);
$fieldAlias = $this->name(preg_replace("/^\[(.+)\]$/", "$1", $build[0]) . '__' . $build[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -787,7 +787,7 @@ public function name($data) {
}
return $data;
}
$cacheKey = crc32($this->startQuote.$data.$this->endQuote);
$cacheKey = crc32($this->startQuote . $data . $this->endQuote);
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
return $return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Model.php
Expand Up @@ -2417,7 +2417,7 @@ public function hasAny($conditions = null) {
* Queries the datasource and returns a result set array.
*
* Also used to perform notation finds, where the first argument is type of find operation to perform
* (all / first / count / neighbors / list / threaded ),
* (all / first / count / neighbors / list / threaded),
* second parameter options for finding ( indexed array, including: 'conditions', 'limit',
* 'recursive', 'page', 'fields', 'offset', 'order')
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeResponse.php
Expand Up @@ -372,7 +372,7 @@ protected function _setContentLength() {
$this->_headers['Content-Length'] = $offset + strlen($this->_body);
}
}
}
}

/**
* Sends a header to the client.
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Network/CakeSocket.php
Expand Up @@ -106,9 +106,9 @@ public function connect() {
}

if ($this->config['persistent'] == true) {
$this->connection = @pfsockopen($scheme.$this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
$this->connection = @pfsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
} else {
$this->connection = @fsockopen($scheme.$this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
$this->connection = @fsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
}

if (!empty($errNum) || !empty($errStr)) {
Expand Down