diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 277563251..791427cbc 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -56,6 +56,7 @@ class AclNode extends Model { * * @param mixed $ref Array with 'model' and 'foreign_key', model object, or string value * @return array Node found in database + * @throws CakeException when binding to a model that doesn't exist. */ public function node($ref = null) { $db = $this->getDataSource(); @@ -177,4 +178,5 @@ class AclNode extends Model { } return $result; } + } diff --git a/lib/Cake/Model/Behavior/AclBehavior.php b/lib/Cake/Model/Behavior/AclBehavior.php index 583aa9c04..36322c78e 100644 --- a/lib/Cake/Model/Behavior/AclBehavior.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -137,4 +137,5 @@ class AclBehavior extends ModelBehavior { } } } + } diff --git a/lib/Cake/Model/Behavior/ContainableBehavior.php b/lib/Cake/Model/Behavior/ContainableBehavior.php index 4c9bbf719..3506776b1 100644 --- a/lib/Cake/Model/Behavior/ContainableBehavior.php +++ b/lib/Cake/Model/Behavior/ContainableBehavior.php @@ -186,7 +186,7 @@ class ContainableBehavior extends ModelBehavior { if (!empty($Model->{$type})) { foreach ($Model->{$type} as $assoc => $data) { if ($Model->useDbConfig == $Model->{$assoc}->useDbConfig && !empty($data['fields'])) { - foreach ((array) $data['fields'] as $field) { + foreach ((array)$data['fields'] as $field) { $query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field; } } @@ -286,7 +286,7 @@ class ContainableBehavior extends ModelBehavior { $children = (array)$children; foreach ($children as $key => $val) { if (is_string($key) && is_string($val) && !in_array($key, $options, true)) { - $children[$key] = (array) $val; + $children[$key] = (array)$val; } } @@ -326,7 +326,7 @@ class ContainableBehavior extends ModelBehavior { } if ($optionKey && isset($children[$key])) { if (!empty($keep[$name][$key]) && is_array($keep[$name][$key])) { - $keep[$name][$key] = array_merge((isset($keep[$name][$key]) ? $keep[$name][$key] : array()), (array) $children[$key]); + $keep[$name][$key] = array_merge((isset($keep[$name][$key]) ? $keep[$name][$key] : array()), (array)$children[$key]); } else { $keep[$name][$key] = $children[$key]; } @@ -424,4 +424,5 @@ class ContainableBehavior extends ModelBehavior { } return $map; } + } diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index e6a3deed3..7b2012953 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -120,15 +120,15 @@ class TranslateBehavior extends ModelBehavior { $this->_runtimeModel = $RuntimeModel; 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['fields'] = 'COUNT(DISTINCT(' . $db->name($model->alias . '.' . $model->primaryKey) . ')) ' . $db->alias . 'count'; $query['joins'][] = array( 'type' => 'INNER', 'alias' => $RuntimeModel->alias, 'table' => $joinTable, 'conditions' => array( - $model->alias . '.' . $model->primaryKey => $db->identifier($RuntimeModel->alias.'.foreign_key'), - $RuntimeModel->alias.'.model' => $model->name, - $RuntimeModel->alias.'.locale' => $locale + $model->alias . '.' . $model->primaryKey => $db->identifier($RuntimeModel->alias . '.foreign_key'), + $RuntimeModel->alias . '.model' => $model->name, + $RuntimeModel->alias . '.locale' => $locale ) ); $conditionFields = $this->_checkConditions($model, $query); @@ -147,7 +147,7 @@ class TranslateBehavior extends ModelBehavior { 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; } } @@ -221,34 +221,34 @@ class TranslateBehavior extends ModelBehavior { foreach ($locale as $_locale) { $model->virtualFields['i18n_' . $field . '_' . $_locale] = 'I18n__' . $field . '__' . $_locale . '.content'; if (!empty($query['fields']) && is_array($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'; if (!empty($query['fields']) && is_array($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 ) ); } @@ -446,6 +446,8 @@ class TranslateBehavior extends ModelBehavior { * @param string|array $fields string with field or array(field1, field2=>AssocName, field3) * @param boolean $reset * @return boolean + * @throws CakeException when attempting to bind a translating called name. This is not allowed + * as it shadows Model::$name. */ public function bindTranslation(Model $model, $fields, $reset = true) { if (is_string($fields)) { @@ -570,5 +572,6 @@ class TranslateBehavior extends ModelBehavior { } return true; } + } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 66f98de68..22bbf6bf6 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -86,7 +86,7 @@ class TreeBehavior extends ModelBehavior { if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) { return $this->_setParent($Model, $Model->data[$Model->alias][$parent], $created); } - } elseif ($__parentChange) { + } elseif ($this->settings[$Model->alias]['__parentChange']) { $this->settings[$Model->alias]['__parentChange'] = false; return $this->_setParent($Model, $Model->data[$Model->alias][$parent]); } @@ -118,7 +118,7 @@ class TreeBehavior extends ModelBehavior { public function beforeDelete(Model $Model, $cascade = true) { extract($this->settings[$Model->alias]); $data = current($Model->find('first', array( - 'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id), + 'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id), 'fields' => array($Model->alias . '.' . $left, $Model->alias . '.' . $right), 'recursive' => -1))); @@ -163,8 +163,8 @@ class TreeBehavior extends ModelBehavior { return false; } list($parentNode) = array_values($parentNode); - $Model->data[$Model->alias][$left] = 0; //$parentNode[$right]; - $Model->data[$Model->alias][$right] = 0; //$parentNode[$right] + 1; + $Model->data[$Model->alias][$left] = 0; + $Model->data[$Model->alias][$right] = 0; } else { $edge = $this->_getMax($Model, $scope, $right, $recursive); $Model->data[$Model->alias][$left] = $edge + 1; @@ -357,7 +357,7 @@ class TreeBehavior extends ModelBehavior { while ($stack && ($stack[count($stack) - 1] < $result[$Model->alias][$right])) { array_pop($stack); } - $results[$i]['tree_prefix'] = str_repeat($spacer,count($stack)); + $results[$i]['tree_prefix'] = str_repeat($spacer, count($stack)); $stack[] = $result[$Model->alias][$right]; } if (empty($results)) { @@ -542,7 +542,7 @@ class TreeBehavior extends ModelBehavior { return false; } $edge = $this->_getMax($Model, $scope, $right, $recursive); - $this->_sync($Model, $edge - $previousNode[$left] +1, '+', 'BETWEEN ' . $previousNode[$left] . ' AND ' . $previousNode[$right]); + $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, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge); if (is_int($number)) { @@ -766,7 +766,7 @@ class TreeBehavior extends ModelBehavior { } $min = $this->_getMin($Model, $scope, $left, $recursive); $edge = $this->_getMax($Model, $scope, $right, $recursive); - $errors = array(); + $errors = array(); for ($i = $min; $i <= $edge; $i++) { $count = $Model->find('count', array('conditions' => array( @@ -873,7 +873,7 @@ class TreeBehavior extends ModelBehavior { ); $Model->data = $result; } else { - $this->_sync($Model, $edge - $node[$left] +1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created); + $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created); $diff = $node[$right] - $node[$left] + 1; if ($node[$left] > $parentNode[$left]) { @@ -976,4 +976,5 @@ class TreeBehavior extends ModelBehavior { $Model->updateAll(array($Model->alias . '.' . $field => $Model->escapeField($field) . ' ' . $dir . ' ' . $shift), $conditions); $Model->recursive = $ModelRecursive; } + } diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index a9edf0324..00287a827 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -291,4 +291,5 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener { 'Model.afterDelete' => 'trigger' ); } + } diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index 49c379a9f..7bbf09679 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -161,13 +161,13 @@ class CakeSchema extends Object { $this->build($options); extract(get_object_vars($this)); - $class = $name .'Schema'; + $class = $name . 'Schema'; if (!class_exists($class)) { if (file_exists($path . DS . $file) && is_file($path . DS . $file)) { - require_once($path . DS . $file); + require_once $path . DS . $file; } elseif (file_exists($path . DS . 'schema.php') && is_file($path . DS . 'schema.php')) { - require_once($path . DS . 'schema.php'); + require_once $path . DS . 'schema.php'; } } @@ -175,7 +175,6 @@ class CakeSchema extends Object { $Schema = new $class($options); return $Schema; } - return false; } @@ -207,7 +206,7 @@ class CakeSchema extends Object { } $tables = array(); - $currentTables = (array) $db->listSources(); + $currentTables = (array)$db->listSources(); $prefix = null; if (isset($db->config['prefix'])) { @@ -703,4 +702,5 @@ class CakeSchema extends Object { protected function _noPrefixTable($prefix, $table) { return preg_replace('/^' . preg_quote($prefix) . '/', '', $table); } + } diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index f53b0b9e8..0ac20811c 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -189,7 +189,7 @@ class ConnectionManager { if (empty(self::$_init)) { self::_init(); } - return (array) self::$config; + return (array)self::$config; } /** @@ -262,4 +262,5 @@ class ConnectionManager { } return compact('package', 'classname', 'plugin'); } + } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index cf3b40818..7d9239c80 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -682,4 +682,5 @@ class CakeSession { self::$error[$errorNumber] = $errorMessage; self::$lastError = $errorNumber; } + } diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index 84127de93..60daa7f22 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -428,4 +428,5 @@ class DataSource extends Object { $this->close(); } } + } diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 4a4811d9d..2cdcfda55 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -444,7 +444,7 @@ class Mysql extends DboSource { $indices = $this->_execute('SHOW INDEX FROM ' . $table); while ($idx = $indices->fetch(PDO::FETCH_OBJ)) { if ($old) { - $idx = (object) current((array)$idx); + $idx = (object)current((array)$idx); } if (!isset($index[$idx->Key_name]['column'])) { $col = array(); @@ -589,9 +589,9 @@ class Mysql extends DboSource { } } if (is_array($value['column'])) { - $out .= 'KEY '. $name .' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; + $out .= 'KEY ' . $name . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; } else { - $out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')'; + $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')'; } $alter[] = $out; } @@ -618,7 +618,7 @@ class Mysql extends DboSource { } else { $tables = array(); foreach ($result as $row) { - $tables[$row['Name']] = (array) $row; + $tables[$row['Name']] = (array)$row; unset($tables[$row['Name']]['queryString']); if (!empty($row['Collation'])) { $charset = $this->getCharsetName($row['Collation']); @@ -635,7 +635,6 @@ class Mysql extends DboSource { } } - /** * Converts database-layer column types to basic types * diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 4c81bd94f..48535be68 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -507,16 +507,16 @@ class Postgres extends DboSource { $default = isset($col['default']) ? $col['default'] : null; $nullable = isset($col['null']) ? $col['null'] : null; unset($col['default'], $col['null']); - $colList[] = 'ALTER COLUMN '. $fieldName .' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); + $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); if (isset($nullable)) { $nullable = ($nullable) ? 'DROP NOT NULL' : 'SET NOT NULL'; - $colList[] = 'ALTER COLUMN '. $fieldName .' ' . $nullable; + $colList[] = 'ALTER COLUMN ' . $fieldName . ' ' . $nullable; } if (isset($default)) { - $colList[] = 'ALTER COLUMN '. $fieldName .' SET DEFAULT ' . $this->value($default, $col['type']); + $colList[] = 'ALTER COLUMN ' . $fieldName . ' SET DEFAULT ' . $this->value($default, $col['type']); } else { - $colList[] = 'ALTER COLUMN '. $fieldName .' DROP DEFAULT'; + $colList[] = 'ALTER COLUMN ' . $fieldName . ' DROP DEFAULT'; } } @@ -760,14 +760,14 @@ class Postgres extends DboSource { $result = ($data === 'TRUE'); break; default: - $result = (bool) $data; + $result = (bool)$data; break; } if ($quote) { return ($result) ? 'TRUE' : 'FALSE'; } - return (bool) $result; + return (bool)$result; } /** diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index ac1ce299d..3d2be70be 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -169,14 +169,14 @@ class Sqlite extends DboSource { $result = $this->_execute('PRAGMA table_info(' . $table . ')'); foreach ($result as $column) { - $column = (array) $column; + $column = (array)$column; $default = ($column['dflt_value'] === 'NULL') ? null : trim($column['dflt_value'], "'"); $fields[$column['name']] = array( - 'type' => $this->column($column['type']), - 'null' => !$column['notnull'], - 'default' => $default, - 'length' => $this->length($column['type']) + 'type' => $this->column($column['type']), + 'null' => !$column['notnull'], + 'default' => $default, + 'length' => $this->length($column['type']) ); if ($column['pk'] == 1) { $fields[$column['name']]['key'] = $this->index['PRI']; @@ -270,7 +270,7 @@ class Sqlite extends DboSource { public function resultSet($results) { $this->results = $results; $this->map = array(); - $num_fields = $results->columnCount(); + $numFields = $results->columnCount(); $index = 0; $j = 0; @@ -290,7 +290,7 @@ class Sqlite extends DboSource { } elseif (strpos($querystring, 'PRAGMA index_info') === 0) { $selects = array('seqno', 'cid', 'name'); } - while ($j < $num_fields) { + while ($j < $numFields) { if (!isset($selects[$j])) { $j++; continue; @@ -311,7 +311,8 @@ class Sqlite extends DboSource { if (!empty($metaData['sqlite:decl_type'])) { $metaType = trim($metaData['sqlite:decl_type']); } - } catch (Exception $e) {} + } catch (Exception $e) { + } if (strpos($columnName, '.')) { $parts = explode('.', $columnName); @@ -345,7 +346,6 @@ class Sqlite extends DboSource { } } - /** * Returns a limit statement in the correct format for the particular database. * @@ -448,7 +448,7 @@ class Sqlite extends DboSource { $value['column'] = $this->name($value['column']); } $t = trim($table, '"'); - $indexname = $this->name($t . '_' .$name); + $indexname = $this->name($t . '_' . $name); $table = $this->name($table); $out .= "INDEX {$dbname}.{$indexname} ON {$table}({$value['column']});"; $join[] = $out; @@ -469,7 +469,7 @@ class Sqlite extends DboSource { if ($table) { $indexes = $this->query('PRAGMA index_list(' . $table . ')'); - if (is_bool($indexes)) { + if (is_bool($indexes)) { return array(); } foreach ($indexes as $i => $info) { diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 065572dee..392a30ea6 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -256,7 +256,6 @@ class Sqlserver extends DboSource { return $fields; } - /** * Generates the fields list of an SQL query. * @@ -303,14 +302,14 @@ class Sqlserver extends DboSource { $fieldAlias = $this->name($alias . '__' . $fields[$i]); } else { $build = explode('.', $fields[$i]); - $this->_fieldMappings[$build[0] . '__' . $build[1]] = $fields[$i]; - $fieldName = $this->name($build[0] . '.' . $build[1]); + $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]); } if ($model->getColumnType($fields[$i]) == 'datetime') { $fieldName = "CONVERT(VARCHAR(20), {$fieldName}, 20)"; } - $fields[$i] = "{$fieldName} AS {$fieldAlias}"; + $fields[$i] = "{$fieldName} AS {$fieldAlias}"; } $result[] = $prepend . $fields[$i]; } @@ -388,7 +387,7 @@ class Sqlserver extends DboSource { } $rt .= ' ' . $limit; if (is_int($offset) && $offset > 0) { - $rt = ' OFFSET ' . intval($offset) . ' ROWS FETCH FIRST ' . intval($limit) . ' ROWS ONLY'; + $rt = ' OFFSET ' . intval($offset) . ' ROWS FETCH FIRST ' . intval($limit) . ' ROWS ONLY'; } return $rt; } @@ -743,6 +742,7 @@ class Sqlserver extends DboSource { * @param array $prepareOptions Options to be used in the prepare statement * @return mixed PDOStatement if query executes with no problem, true as the result of a successful, false on error * query returning no rows, such as a CREATE statement, false otherwise + * @throws PDOException */ protected function _execute($sql, $params = array(), $prepareOptions = array()) { $this->_lastAffected = false; @@ -781,7 +781,7 @@ class Sqlserver extends DboSource { $out = ''; foreach ($schema->tables as $curTable => $columns) { if (!$table || $table == $curTable) { - $out .= "IF OBJECT_ID('" . $this->fullTableName($curTable, false). "', 'U') IS NOT NULL DROP TABLE " . $this->fullTableName($curTable) . ";\n"; + $out .= "IF OBJECT_ID('" . $this->fullTableName($curTable, false) . "', 'U') IS NOT NULL DROP TABLE " . $this->fullTableName($curTable) . ";\n"; } } return $out; diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 753036911..1e009ff1b 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -228,6 +228,7 @@ class DboSource extends DataSource { * * @param array $config Array of configuration information for the Datasource. * @param boolean $autoConnect Whether or not the datasource should automatically connect. + * @throws MissingConnectionException when a connection cannot be made. */ public function __construct($config = null, $autoConnect = true) { if (!isset($config['prefix'])) { @@ -341,7 +342,6 @@ class DboSource extends DataSource { } } - /** * Returns an object to represent a database identifier in a query. Expression objects * are not sanitized or escaped. @@ -419,6 +419,7 @@ class DboSource extends DataSource { * @param array $prepareOptions Options to be used in the prepare statement * @return mixed PDOStatement if query executes with no problem, true as the result of a successful, false on error * query returning no rows, such as a CREATE statement, false otherwise + * @throws PDOException */ protected function _execute($sql, $params = array(), $prepareOptions = array()) { $sql = trim($sql); @@ -1148,6 +1149,7 @@ class DboSource extends DataSource { * @param integer $recursive Number of levels of association * @param array $stack * @return mixed + * @throws CakeException when results cannot be created. */ public function queryAssociation(Model $model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { @@ -1199,12 +1201,11 @@ class DboSource extends DataSource { if (!empty($ins)) { $ins = array_unique($ins); if (count($ins) > 1) { - $query = str_replace('{$__cakeID__$}', '(' .implode(', ', $ins) .')', $query); + $query = str_replace('{$__cakeID__$}', '(' . implode(', ', $ins) . ')', $query); $query = str_replace('= (', 'IN (', $query); } else { $query = str_replace('{$__cakeID__$}', $ins[0], $query); } - $query = str_replace(' WHERE 1 = 1', '', $query); } @@ -1842,7 +1843,7 @@ class DboSource extends DataSource { } else { $update .= $value; } - $updates[] = $update; + $updates[] = $update; } return $updates; } @@ -2356,7 +2357,7 @@ class DboSource extends DataSource { if ($not) { $out[] = $not . '(' . $value[0] . ')'; } else { - $out[] = $value[0] ; + $out[] = $value[0]; } } else { $out[] = '(' . $not . '(' . implode(') ' . strtoupper($key) . ' (', $value) . '))'; @@ -2612,11 +2613,11 @@ class DboSource extends DataSource { $key = trim($key); if (is_object($model) && $model->isVirtualField($key)) { - $key = '(' . $this->_quoteFields($model->getVirtualField($key)) . ')'; + $key = '(' . $this->_quoteFields($model->getVirtualField($key)) . ')'; } list($alias, $field) = pluginSplit($key); if (is_object($model) && $alias !== $model->alias && is_object($model->{$alias}) && $model->{$alias}->isVirtualField($key)) { - $key = '(' . $this->_quoteFields($model->{$alias}->getVirtualField($key)) . ')'; + $key = '(' . $this->_quoteFields($model->{$alias}->getVirtualField($key)) . ')'; } if (strpos($key, '.')) { diff --git a/lib/Cake/Model/Datasource/Session/CacheSession.php b/lib/Cake/Model/Datasource/Session/CacheSession.php index fc758d838..01abf0b9a 100644 --- a/lib/Cake/Model/Datasource/Session/CacheSession.php +++ b/lib/Cake/Model/Datasource/Session/CacheSession.php @@ -27,6 +27,7 @@ App::uses('CakeSessionHandlerInterface', 'Model/Datasource/Session'); * @see CakeSession for configuration information. */ class CacheSession implements CakeSessionHandlerInterface { + /** * Method called on open of a database session. * @@ -98,4 +99,5 @@ class CacheSession implements CakeSessionHandlerInterface { public function __destruct() { session_write_close(); } -} \ No newline at end of file + +} diff --git a/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php b/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php index 5e62e1053..4220fa75e 100644 --- a/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php +++ b/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php @@ -20,6 +20,7 @@ * @package Cake.Model.Datasource.Session */ interface CakeSessionHandlerInterface { + /** * Method called on open of a session. * @@ -67,4 +68,5 @@ interface CakeSessionHandlerInterface { * @return boolean Success */ public function gc($expires = null); + } diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index 31b625002..c8379e09c 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -152,6 +152,8 @@ class DatabaseSession implements CakeSessionHandlerInterface { public function __destruct() { try { session_write_close(); - } catch (Exception $e) {} + } catch (Exception $e) { + } } + } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 7a5574116..7f316c9e9 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -219,7 +219,6 @@ class Model extends Object implements CakeEventListener { */ public $validationErrors = array(); - /** * Name of the validation string domain to use when translating validation errors. * @@ -790,8 +789,7 @@ class Model extends Object implements CakeEventListener { if (isset($name, $this->{$type}[$name])) { $className = empty($this->{$type}[$name]['className']) ? $name : $this->{$type}[$name]['className']; break; - } - elseif (isset($name, $this->__backAssociation[$type][$name])) { + } elseif (isset($name, $this->__backAssociation[$type][$name])) { $className = empty($this->__backAssociation[$type][$name]['className']) ? $name : $this->__backAssociation[$type][$name]['className']; break; @@ -972,7 +970,7 @@ class Model extends Object implements CakeEventListener { if (strpos($assoc, '.') !== false) { list($plugin, $assoc) = pluginSplit($assoc); - $this->{$type}[$assoc] = array('className' => $plugin. '.' . $assoc); + $this->{$type}[$assoc] = array('className' => $plugin . '.' . $assoc); } else { $this->{$type}[$assoc] = $value; } @@ -1773,7 +1771,7 @@ class Model extends Object implements CakeEventListener { $newData = $newValues = $newJoins = array(); $primaryAdded = false; - $fields = array( + $fields = array( $dbMulti->name($this->hasAndBelongsToMany[$assoc]['foreignKey']), $dbMulti->name($this->hasAndBelongsToMany[$assoc]['associationForeignKey']) ); @@ -1808,7 +1806,7 @@ class Model extends Object implements CakeEventListener { if (!empty($this->hasAndBelongsToMany[$assoc]['conditions'])) { $conditions = array_merge($conditions, (array)$this->hasAndBelongsToMany[$assoc]['conditions']); } - $associationForeignKey = $this->{$join}->alias .'.'. $this->hasAndBelongsToMany[$assoc]['associationForeignKey']; + $associationForeignKey = $this->{$join}->alias . '.' . $this->hasAndBelongsToMany[$assoc]['associationForeignKey']; $links = $this->{$join}->find('all', array( 'conditions' => $conditions, 'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0, @@ -2230,7 +2228,7 @@ class Model extends Object implements CakeEventListener { break; case 'hasMany': foreach ($values as $i => $value) { - $values[$i][$this->{$type}[$association]['foreignKey']] = $this->id; + $values[$i][$this->{$type}[$association]['foreignKey']] = $this->id; } $_return = $this->{$association}->saveMany($values, array_merge($options, array('atomic' => false))); if (in_array(false, $_return, true)) { @@ -2736,7 +2734,7 @@ class Model extends Object implements CakeEventListener { } if (empty($query['fields'])) { $query['fields'] = $db->calculate($this, 'count'); - } elseif (is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) { + } elseif (is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) { $query['fields'] = $db->calculate($this, 'count', array( $db->expression($query['fields']), 'count' )); @@ -2974,7 +2972,7 @@ class Model extends Object implements CakeEventListener { $fields = array('or' => $fields); } if (!empty($this->id)) { - $fields[$this->alias . '.' . $this->primaryKey . ' !='] = $this->id; + $fields[$this->alias . '.' . $this->primaryKey . ' !='] = $this->id; } return ($this->find('count', array('conditions' => $fields, 'recursive' => -1)) == 0); } @@ -3227,7 +3225,7 @@ class Model extends Object implements CakeEventListener { if (!is_array($this->validationErrors)) { $this->validationErrors = array(); } - $this->validationErrors[$field] []= $value; + $this->validationErrors[$field][] = $value; } /** @@ -3551,7 +3549,6 @@ class Model extends Object implements CakeEventListener { * @param string $type If null this deletes cached views if Cache.check is true * Will be used to allow deleting query cache also * @return boolean true on delete - * @todo */ protected function _clearCache($type = null) { if ($type === null) { @@ -3574,4 +3571,5 @@ class Model extends Object implements CakeEventListener { //Will use for query cache deleting } } + } diff --git a/lib/Cake/Model/ModelBehavior.php b/lib/Cake/Model/ModelBehavior.php index 026328100..eb00561ca 100644 --- a/lib/Cake/Model/ModelBehavior.php +++ b/lib/Cake/Model/ModelBehavior.php @@ -92,7 +92,8 @@ class ModelBehavior extends Object { * @param array $config Configuration settings for $model * @return void */ - public function setup(Model $model, $config = array()) { } + public function setup(Model $model, $config = array()) { + } /** * Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically @@ -130,7 +131,8 @@ class ModelBehavior extends Object { * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association) * @return mixed An array value will replace the value of $results - any other value will be ignored. */ - public function afterFind(Model $model, $results, $primary) { } + public function afterFind(Model $model, $results, $primary) { + } /** * beforeValidate is called before a model is validated, you can use this callback to @@ -184,7 +186,8 @@ class ModelBehavior extends Object { * @param Model $model Model using this behavior * @return void */ - public function afterDelete(Model $model) { } + public function afterDelete(Model $model) { + } /** * DataSource error callback @@ -193,7 +196,8 @@ class ModelBehavior extends Object { * @param string $error Error generated in DataSource * @return void */ - public function onError(Model $model, $error) { } + public function onError(Model $model, $error) { + } /** * If $model's whitelist property is non-empty, $field will be added to it. @@ -216,5 +220,6 @@ class ModelBehavior extends Object { $model->whitelist[] = $field; } } + } diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index b8cd9b1b1..e168708a9 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -71,4 +71,5 @@ class Permission extends AppModel { } parent::__construct(); } -} \ No newline at end of file + +}