diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 277563251fd..791427cbcec 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -56,6 +56,7 @@ public function __construct() { * * @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 @@ public function node($ref = null) { } return $result; } + } diff --git a/lib/Cake/Model/Behavior/AclBehavior.php b/lib/Cake/Model/Behavior/AclBehavior.php index 583aa9c04d6..36322c78e57 100644 --- a/lib/Cake/Model/Behavior/AclBehavior.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -137,4 +137,5 @@ public function afterDelete(Model $model) { } } } + } diff --git a/lib/Cake/Model/Behavior/ContainableBehavior.php b/lib/Cake/Model/Behavior/ContainableBehavior.php index 4c9bbf7195c..3506776b1a8 100644 --- a/lib/Cake/Model/Behavior/ContainableBehavior.php +++ b/lib/Cake/Model/Behavior/ContainableBehavior.php @@ -186,7 +186,7 @@ public function beforeFind(Model $Model, $query) { 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 @@ public function containments(Model $Model, $contain, $containments = array(), $t $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 @@ public function containments(Model $Model, $contain, $containments = array(), $t } 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 @@ public function containmentsMap($containments) { } return $map; } + } diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index e6a3deed3d2..7b201295390 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -120,15 +120,15 @@ public function beforeFind(Model $model, $query) { $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 @@ public function beforeFind(Model $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; } } @@ -221,34 +221,34 @@ protected function _addJoin(Model $model, $query, $field, $aliasField, $locale, 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 @@ public function translateModel(Model $model) { * @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 @@ public function unbindTranslation(Model $model, $fields = null) { } return true; } + } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 66f98de6898..22bbf6bf655 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -86,7 +86,7 @@ public function afterSave(Model $Model, $created) { 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 @@ public function beforeFind(Model $Model, $query) { 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 @@ public function beforeSave(Model $Model) { 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 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu 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 @@ public function moveUp(Model $Model, $id = null, $number = 1) { 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 @@ public function verify(Model $Model) { } $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 @@ protected function _setParent(Model $Model, $parentId = null, $created = false) ); $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 @@ protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array() $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 a9edf032415..00287a827c4 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -291,4 +291,5 @@ public function implementedEvents() { 'Model.afterDelete' => 'trigger' ); } + } diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index 49c379a9f2f..7bbf096792d 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -161,13 +161,13 @@ public function load($options = array()) { $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 @@ public function load($options = array()) { $Schema = new $class($options); return $Schema; } - return false; } @@ -207,7 +206,7 @@ public function read($options = array()) { } $tables = array(); - $currentTables = (array) $db->listSources(); + $currentTables = (array)$db->listSources(); $prefix = null; if (isset($db->config['prefix'])) { @@ -703,4 +702,5 @@ protected function _compareIndexes($new, $old) { 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 f53b0b9e88f..0ac20811ca5 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -189,7 +189,7 @@ public static function enumConnectionObjects() { if (empty(self::$_init)) { self::_init(); } - return (array) self::$config; + return (array)self::$config; } /** @@ -262,4 +262,5 @@ protected static function _connectionData($config) { } return compact('package', 'classname', 'plugin'); } + } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index cf3b4081846..7d9239c80ab 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -682,4 +682,5 @@ protected static function _setError($errorNumber, $errorMessage) { self::$error[$errorNumber] = $errorMessage; self::$lastError = $errorNumber; } + } diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index 84127de938b..60daa7f224f 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -428,4 +428,5 @@ public function __destruct() { $this->close(); } } + } diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 4a4811d9d81..2cdcfda55bc 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -444,7 +444,7 @@ public function index($model) { $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 @@ protected function _alterIndexes($table, $indexes) { } } 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 @@ public function listDetailedSources($name = null) { } 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 @@ public function listDetailedSources($name = null) { } } - /** * 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 4c81bd94fc0..48535be6856 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -507,16 +507,16 @@ public function alterSchema($compare, $table = null) { $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 @@ public function boolean($data, $quote = false) { $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 ac1ce299d08..3d2be70be9a 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -169,14 +169,14 @@ public function describe($model) { $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 @@ public function column($real) { 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 @@ public function resultSet($results) { } 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 @@ public function resultSet($results) { 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 @@ public function fetchResult() { } } - /** * Returns a limit statement in the correct format for the particular database. * @@ -448,7 +448,7 @@ public function buildIndex($indexes, $table = null) { $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 @@ public function index($model) { 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 065572dee2a..392a30ea629 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -256,7 +256,6 @@ public function describe($model) { return $fields; } - /** * Generates the fields list of an SQL query. * @@ -303,14 +302,14 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = $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 @@ public function limit($limit, $offset = null) { } $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 @@ public function lastAffected($source = null) { * @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 @@ public function dropSchema(CakeSchema $schema, $table = null) { $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 7530369118e..1e009ff1bf6 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 @@ public function value($data, $column = null) { } } - /** * Returns an object to represent a database identifier in a query. Expression objects * are not sanitized or escaped. @@ -419,6 +419,7 @@ public function execute($sql, $options = array(), $params = array()) { * @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 @@ protected function _filterResults(&$results, Model $model, $filtered = array()) * @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 @@ public function queryAssociation(Model $model, &$linkModel, $type, $association, 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 @@ protected function _prepareUpdateFields(Model $model, $fields, $quoteValues = tr } else { $update .= $value; } - $updates[] = $update; + $updates[] = $update; } return $updates; } @@ -2356,7 +2357,7 @@ public function conditionKeysToString($conditions, $quoteValues = true, $model = if ($not) { $out[] = $not . '(' . $value[0] . ')'; } else { - $out[] = $value[0] ; + $out[] = $value[0]; } } else { $out[] = '(' . $not . '(' . implode(') ' . strtoupper($key) . ' (', $value) . '))'; @@ -2612,11 +2613,11 @@ public function order($keys, $direction = 'ASC', $model = null) { $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 fc758d8383c..01abf0b9a14 100644 --- a/lib/Cake/Model/Datasource/Session/CacheSession.php +++ b/lib/Cake/Model/Datasource/Session/CacheSession.php @@ -27,6 +27,7 @@ * @see CakeSession for configuration information. */ class CacheSession implements CakeSessionHandlerInterface { + /** * Method called on open of a database session. * @@ -98,4 +99,5 @@ public function gc($expires = null) { 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 5e62e105341..4220fa75e70 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 @@ public function destroy($id); * @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 31b62500290..c8379e09cf2 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -152,6 +152,8 @@ public function gc($expires = null) { 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 7a5574116ee..7f316c9e946 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 @@ public function __isset($name) { 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 @@ protected function _createLinks() { 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 @@ protected function _saveMulti($joined, $id, $db) { $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 @@ protected function _saveMulti($joined, $id, $db) { 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 @@ public function saveAssociated($data = null, $options = array()) { 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 @@ protected function _findCount($state, $query, $results = array()) { } 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 @@ public function isUnique($fields, $or = true) { $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 @@ public function invalidate($field, $value = true) { if (!is_array($this->validationErrors)) { $this->validationErrors = array(); } - $this->validationErrors[$field] []= $value; + $this->validationErrors[$field][] = $value; } /** @@ -3551,7 +3549,6 @@ public function onError() { * @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 @@ protected function _clearCache($type = null) { //Will use for query cache deleting } } + } diff --git a/lib/Cake/Model/ModelBehavior.php b/lib/Cake/Model/ModelBehavior.php index 02632810074..eb00561ca14 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 @@ public function beforeFind(Model $model, $query) { * @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 @@ public function beforeDelete(Model $model, $cascade = true) { * @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 @@ public function afterDelete(Model $model) { } * @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 @@ protected function _addToWhitelist(Model $model, $field) { $model->whitelist[] = $field; } } + } diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index b8cd9b1b16a..e168708a919 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -71,4 +71,5 @@ public function __construct() { } parent::__construct(); } -} \ No newline at end of file + +}