Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing whitespacing.

  • Loading branch information...
commit b190e462b847f9bd58cc290d188063689300df5d 1 parent c65e2f3
Mark Story markstory authored
2  cake/libs/controller/controller.php
View
@@ -1078,7 +1078,7 @@ function paginate($object = null, $scope = array(), $whitelist = array()) {
if ($object->hasField($field)) {
$options['order'][$alias . '.' . $field] = $value;
- } elseif ($object->hasField($field,true)) {
+ } elseif ($object->hasField($field, true)) {
$options['order'][$field] = $value;
} elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field)) {
$options['order'][$alias . '.' . $field] = $value;
22 cake/libs/model/datasources/dbo_source.php
View
@@ -399,13 +399,13 @@ function fetchAll($sql, $cache = true, $modelName = null) {
function fetchVirtualField(&$result) {
if (isset($result[0]) && is_array($result[0])) {
foreach ($result[0] as $field => $value) {
- if (strpos($field,'__') === false) {
+ if (strpos($field, '__') === false) {
continue;
}
- list($alias,$virtual) = explode('__',$field);
+ list($alias, $virtual) = explode('__', $field);
if (!ClassRegistry::isKeySet($alias)) {
- retrun;
+ return;
}
$model = ClassRegistry::getObject($alias);
if ($model->isVirtualField($virtual)) {
@@ -1365,7 +1365,7 @@ function buildStatement($query, &$model) {
'fields' => implode(', ', $query['fields']),
'table' => $query['table'],
'alias' => $this->alias . $this->name($query['alias']),
- 'order' => $this->order($query['order'],'ASC',$model),
+ 'order' => $this->order($query['order'], 'ASC', $model),
'limit' => $this->limit($query['limit'], $query['offset']),
'joins' => implode(' ', $query['joins']),
'group' => $this->group($query['group'])
@@ -1820,13 +1820,13 @@ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
$virtual = array();
if ($model->getVirtualField()) {
$keys = array_keys($model->getVirtualField());
- $virtual = ($allFields) ? $keys : array_intersect($keys,$fields);
+ $virtual = ($allFields) ? $keys : array_intersect($keys, $fields);
}
$count = count($fields);
if ($count >= 1 && !in_array($fields[0], array('*', 'COUNT(*)'))) {
for ($i = 0; $i < $count; $i++) {
- if (in_array($fields[$i],$virtual)) {
+ if (in_array($fields[$i], $virtual)) {
unset($fields[$i]);
continue;
}
@@ -1884,7 +1884,7 @@ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
}
}
if (!empty($virtual)) {
- $fields = array_merge($fields,$this->_constructVirtualFields($model,$alias,$virtual));
+ $fields = array_merge($fields,$this->_constructVirtualFields($model, $alias, $virtual));
}
return array_unique($fields);
}
@@ -2199,7 +2199,7 @@ function order($keys, $direction = 'ASC', &$model = null) {
$keys = array_filter($keys);
$result = array();
while (!empty($keys)) {
- list($key,$dir) = each($keys);
+ list($key, $dir) = each($keys);
array_shift($keys);
if (is_numeric($key)) {
@@ -2212,10 +2212,10 @@ function order($keys, $direction = 'ASC', &$model = null) {
}
if (is_array($key)) {
//Flatten the array
- $key = array_reverse($key,true);
+ $key = array_reverse($key, true);
foreach ($key as $k => $v) {
if (is_numeric($k)) {
- array_unshift($keys,$v);
+ array_unshift($keys, $v);
} else {
$keys = array($k => $v) + $keys;
}
@@ -2250,7 +2250,7 @@ function order($keys, $direction = 'ASC', &$model = null) {
$result[] = $key;
}
if (!empty($result)) {
- return ' ORDER BY ' . implode(', ',$result);
+ return ' ORDER BY ' . implode(', ', $result);
}
return '';
}
6 cake/libs/model/model.php
View
@@ -1018,7 +1018,7 @@ function getColumnType($column) {
function hasField($name, $checkVirtual = false) {
if (is_array($name)) {
foreach ($name as $n) {
- if ($this->hasField($n,$checkVirtual)) {
+ if ($this->hasField($n, $checkVirtual)) {
return $n;
}
}
@@ -1049,7 +1049,7 @@ function hasField($name, $checkVirtual = false) {
* @access public
*/
function isVirtualField($field) {
- return !empty($this->virtualFields) && is_string($field) && array_key_exists($field,$this->virtualFields);
+ return !empty($this->virtualFields) && is_string($field) && array_key_exists($field, $this->virtualFields);
}
/**
@@ -1159,7 +1159,7 @@ function field($name, $conditions = null, $order = null) {
$recursive = $this->recursive;
}
$fields = $name;
- if ($data = $this->find('first',compact('conditions','fields','order','recursive'))) {
+ if ($data = $this->find('first', compact('conditions', 'fields', 'order', 'recursive'))) {
if (strpos($name, '.') === false) {
if (isset($data[$this->alias][$name])) {
return $data[$this->alias][$name];
6 cake/tests/cases/libs/controller/controller.test.php
View
@@ -1254,15 +1254,15 @@ function testPaginateOrderVirtualField() {
);
$Controller->paginate = array(
- 'fields' => array('id', 'title','offset_test'),
+ 'fields' => array('id', 'title', 'offset_test'),
'order' => array('offset_test' => 'DESC')
);
$result = $Controller->paginate('ControllerPost');
- $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4,3,2));
+ $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4, 3, 2));
$Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc');
$result = $Controller->paginate('ControllerPost');
- $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2,3,4));
+ $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4));
}
}
?>
34 cake/tests/cases/libs/model/model_read.test.php
View
@@ -215,14 +215,14 @@ function testGroupBy() {
array('Product' => array('type' => 'Toy'), array('price' => 3))
);
$result = $Product->find('all',array(
- 'fields'=>array('Product.type','MIN(Product.price) as price'),
+ 'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> 'Product.type',
'order' => 'Product.type ASC'
));
$this->assertEqual($result, $expected);
$result = $Product->find('all', array(
- 'fields'=>array('Product.type','MIN(Product.price) as price'),
+ 'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> array('Product.type'),
'order' => 'Product.type ASC'));
$this->assertEqual($result, $expected);
@@ -7176,45 +7176,45 @@ function testVirtualFields() {
$Post = ClassRegistry::init('Post');
$Post->virtualFields = array('two' => "1 + 1");
$result = $Post->find('first');
- $this->assertEqual($result['Post']['two'],2);
+ $this->assertEqual($result['Post']['two'], 2);
$Post->Author->virtualFields = array('false' => '1 = 2');
$result = $Post->find('first');
- $this->assertEqual($result['Post']['two'],2);
+ $this->assertEqual($result['Post']['two'], 2);
$this->assertEqual($result['Author']['false'],false);
$result = $Post->find('first',array('fields' => array('author_id')));
$this->assertFalse(isset($result['Post']['two']));
$this->assertFalse(isset($result['Author']['false']));
- $result = $Post->find('first',array('fields' => array('author_id','two')));
- $this->assertEqual($result['Post']['two'],2);
+ $result = $Post->find('first',array('fields' => array('author_id', 'two')));
+ $this->assertEqual($result['Post']['two'], 2);
$this->assertFalse(isset($result['Author']['false']));
$result = $Post->find('first',array('fields' => array('two')));
- $this->assertEqual($result['Post']['two'],2);
+ $this->assertEqual($result['Post']['two'], 2);
$Post->id = 1;
$result = $Post->field('two');
- $this->assertEqual($result,2);
+ $this->assertEqual($result, 2);
$result = $Post->find('first',array(
'conditions' => array('two' => 2),
'limit' => 1
));
- $this->assertEqual($result['Post']['two'],2);
+ $this->assertEqual($result['Post']['two'], 2);
$result = $Post->find('first',array(
'conditions' => array('two <' => 3),
'limit' => 1
));
- $this->assertEqual($result['Post']['two'],2);
+ $this->assertEqual($result['Post']['two'], 2);
$result = $Post->find('first',array(
'conditions' => array('NOT' => array('two >' => 3)),
'limit' => 1
));
- $this->assertEqual($result['Post']['two'],2);
+ $this->assertEqual($result['Post']['two'], 2);
$dbo =& $Post->getDataSource();
$Post->virtualFields = array('other_field' => 'Post.id + 1');
@@ -7222,24 +7222,24 @@ function testVirtualFields() {
'conditions' => array('other_field' => 3),
'limit' => 1
));
- $this->assertEqual($result['Post']['id'],2);
+ $this->assertEqual($result['Post']['id'], 2);
$Post->virtualFields = array('other_field' => 'Post.id + 1');
$result = $Post->find('all',array(
- 'fields' => array($dbo->calculate($Post,'max',array('other_field')))
+ 'fields' => array($dbo->calculate($Post, 'max',array('other_field')))
));
- $this->assertEqual($result[0][0]['other_field'],4);
+ $this->assertEqual($result[0][0]['other_field'], 4);
ClassRegistry::flush();
- $Writing = ClassRegistry::init(array('class' => 'Post', 'alias' => 'Writing'),'Model');
+ $Writing = ClassRegistry::init(array('class' => 'Post', 'alias' => 'Writing'), 'Model');
$Writing->virtualFields = array('two' => "1 + 1");
$result = $Writing->find('first');
- $this->assertEqual($result['Writing']['two'],2);
+ $this->assertEqual($result['Writing']['two'], 2);
$Post->create();
$Post->virtualFields = array('other_field' => 'COUNT(Post.id) + 1');
$result = $Post->field('other_field');
- $this->assertEqual($result,4);
+ $this->assertEqual($result, 4);
}
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.