@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * Converts column types to basic types |
173 | 173 | * |
174 | 174 | * @param string $real Real column type (i.e. "varchar(255)") |
175 | - * @return string Abstract column type (i.e. "string") |
|
175 | + * @return boolean Abstract column type (i.e. "string") |
|
176 | 176 | */ |
177 | 177 | public function column($real) { |
178 | 178 | return false; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * Returns the ID generated from the previous INSERT operation. |
239 | 239 | * |
240 | 240 | * @param mixed $source |
241 | - * @return mixed Last ID key generated in previous INSERT |
|
241 | + * @return boolean Last ID key generated in previous INSERT |
|
242 | 242 | */ |
243 | 243 | public function lastInsertId($source = null) { |
244 | 244 | return false; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * Returns the number of rows returned by last operation. |
249 | 249 | * |
250 | 250 | * @param mixed $source |
251 | - * @return integer Number of rows returned by last operation |
|
251 | + * @return boolean Number of rows returned by last operation |
|
252 | 252 | */ |
253 | 253 | public function lastNumRows($source = null) { |
254 | 254 | return false; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * Returns the number of rows affected by last query. |
259 | 259 | * |
260 | 260 | * @param mixed $source |
261 | - * @return integer Number of rows affected by last query. |
|
261 | + * @return boolean Number of rows affected by last query. |
|
262 | 262 | */ |
263 | 263 | public function lastAffected($source = null) { |
264 | 264 | return false; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | return $this->_sources; |
102 | 102 | } |
103 | 103 | |
104 | - $key = ConnectionManager::getSourceName($this) . '_' . $this->config['database'] . '_list'; |
|
104 | + $key = ConnectionManager::getSourceName($this).'_'.$this->config['database'].'_list'; |
|
105 | 105 | $key = preg_replace('/[^A-Za-z0-9_\-.+]/', '_', $key); |
106 | 106 | $sources = Cache::read($key, '_cake_model_'); |
107 | 107 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | if (is_string($model)) { |
127 | 127 | $table = $model; |
128 | 128 | } else { |
129 | - $table = $model->tablePrefix . $model->table; |
|
129 | + $table = $model->tablePrefix.$model->table; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | if (isset($this->_descriptions[$table])) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $cache = $this->_cacheDescription($table); |
136 | 136 | |
137 | 137 | if ($cache !== null) { |
138 | - $this->_descriptions[$table] =& $cache; |
|
138 | + $this->_descriptions[$table] = & $cache; |
|
139 | 139 | return $cache; |
140 | 140 | } |
141 | 141 | return null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return boolean Returns true if a transaction is not in progress |
148 | 148 | */ |
149 | 149 | public function begin() { |
150 | - return !$this->_transactionStarted; |
|
150 | + return ! $this->_transactionStarted; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | if ($data !== null) { |
302 | - $this->_descriptions[$object] =& $data; |
|
302 | + $this->_descriptions[$object] = & $data; |
|
303 | 303 | } |
304 | 304 | |
305 | - $key = ConnectionManager::getSourceName($this) . '_' . $object; |
|
305 | + $key = ConnectionManager::getSourceName($this).'_'.$object; |
|
306 | 306 | $cache = Cache::read($key, '_cake_model_'); |
307 | 307 | |
308 | 308 | if (empty($cache)) { |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | break; |
351 | 351 | } |
352 | 352 | } |
353 | - if (!$found) { |
|
353 | + if ( ! $found) { |
|
354 | 354 | $val = ''; |
355 | 355 | } |
356 | 356 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | break; |
379 | 379 | } |
380 | 380 | } |
381 | - if (!$found) { |
|
381 | + if ( ! $found) { |
|
382 | 382 | $val = ''; |
383 | 383 | } |
384 | 384 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @return string Key name for model. |
407 | 407 | */ |
408 | 408 | public function resolveKey(Model $model, $key) { |
409 | - return $model->alias . $key; |
|
409 | + return $model->alias.$key; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | /** |
704 | 704 | * Modifies $result array to place virtual fields in model entry where they belongs to |
705 | 705 | * |
706 | - * @param array $result Reference to the fetched row |
|
706 | + * @param boolean $result Reference to the fetched row |
|
707 | 707 | * @return void |
708 | 708 | */ |
709 | 709 | public function fetchVirtualField(&$result) { |
@@ -1919,7 +1919,7 @@ discard block |
||
1919 | 1919 | * |
1920 | 1920 | * @param Model $model |
1921 | 1921 | * @param mixed $conditions |
1922 | - * @return array List of record IDs |
|
1922 | + * @return string|false List of record IDs |
|
1923 | 1923 | */ |
1924 | 1924 | protected function _matchRecords(Model $model, $conditions = null) { |
1925 | 1925 | if ($conditions === true) { |
@@ -2032,7 +2032,7 @@ discard block |
||
2032 | 2032 | * Deletes all the records in a table and resets the count of the auto-incrementing |
2033 | 2033 | * primary key, where applicable. |
2034 | 2034 | * |
2035 | - * @param Model|string $table A string or model class representing the table to be truncated |
|
2035 | + * @param string $table A string or model class representing the table to be truncated |
|
2036 | 2036 | * @return boolean SQL TRUNCATE TABLE statement, false if not applicable. |
2037 | 2037 | */ |
2038 | 2038 | public function truncate($table) { |
@@ -2172,7 +2172,7 @@ discard block |
||
2172 | 2172 | /** |
2173 | 2173 | * Returns the ID generated from the previous INSERT operation. |
2174 | 2174 | * |
2175 | - * @param mixed $source |
|
2175 | + * @param string $source |
|
2176 | 2176 | * @return mixed |
2177 | 2177 | */ |
2178 | 2178 | public function lastInsertId($source = null) { |
@@ -3221,7 +3221,7 @@ discard block |
||
3221 | 3221 | * Guesses the data type of an array |
3222 | 3222 | * |
3223 | 3223 | * @param string $value |
3224 | - * @return void |
|
3224 | + * @return string |
|
3225 | 3225 | */ |
3226 | 3226 | public function introspectType($value) { |
3227 | 3227 | if (!is_array($value)) { |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * @throws MissingConnectionException when a connection cannot be made. |
245 | 245 | */ |
246 | 246 | public function __construct($config = null, $autoConnect = true) { |
247 | - if (!isset($config['prefix'])) { |
|
247 | + if ( ! isset($config['prefix'])) { |
|
248 | 248 | $config['prefix'] = ''; |
249 | 249 | } |
250 | 250 | parent::__construct($config); |
251 | 251 | $this->fullDebug = Configure::read('debug') > 1; |
252 | - if (!$this->enabled()) { |
|
252 | + if ( ! $this->enabled()) { |
|
253 | 253 | throw new MissingConnectionException(array( |
254 | 254 | 'class' => get_class($this), |
255 | 255 | 'message' => __d('cake_dev', 'Selected driver is not enabled'), |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return string Quoted and escaped data |
316 | 316 | */ |
317 | 317 | public function value($data, $column = null) { |
318 | - if (is_array($data) && !empty($data)) { |
|
318 | + if (is_array($data) && ! empty($data)) { |
|
319 | 319 | return array_map( |
320 | 320 | array(&$this, 'value'), |
321 | 321 | $data, array_fill(0, count($data), $column) |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | try { |
456 | 456 | $query = $this->_connection->prepare($sql, $prepareOptions); |
457 | 457 | $query->setFetchMode(PDO::FETCH_LAZY); |
458 | - if (!$query->execute($params)) { |
|
458 | + if ( ! $query->execute($params)) { |
|
459 | 459 | $this->_results = $query; |
460 | 460 | $query->closeCursor(); |
461 | 461 | return false; |
462 | 462 | } |
463 | - if (!$query->columnCount()) { |
|
463 | + if ( ! $query->columnCount()) { |
|
464 | 464 | $query->closeCursor(); |
465 | - if (!$query->rowCount()) { |
|
465 | + if ( ! $query->rowCount()) { |
|
466 | 466 | return true; |
467 | 467 | } |
468 | 468 | } |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | if (empty($error[2])) { |
493 | 493 | return null; |
494 | 494 | } |
495 | - return $error[1] . ': ' . $error[2]; |
|
495 | + return $error[1].': '.$error[2]; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $order = $params[2 + $off]; |
563 | 563 | } |
564 | 564 | |
565 | - if (!array_key_exists(0, $params)) { |
|
565 | + if ( ! array_key_exists(0, $params)) { |
|
566 | 566 | return false; |
567 | 567 | } |
568 | 568 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $conditions = array(); |
571 | 571 | |
572 | 572 | foreach ($field as $f) { |
573 | - $conditions[$args[2]->alias . '.' . $f] = $params[$c++]; |
|
573 | + $conditions[$args[2]->alias.'.'.$f] = $params[$c++]; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | if ($or) { |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | } |
599 | 599 | if (isset($args[1]) && $args[1] === true) { |
600 | 600 | return $this->fetchAll($args[0], true); |
601 | - } elseif (isset($args[1]) && !is_array($args[1])) { |
|
601 | + } elseif (isset($args[1]) && ! is_array($args[1])) { |
|
602 | 602 | return $this->fetchAll($args[0], false); |
603 | 603 | } elseif (isset($args[1]) && is_array($args[1])) { |
604 | 604 | if (isset($args[2])) { |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | * @return array The fetched row as an array |
618 | 618 | */ |
619 | 619 | public function fetchRow($sql = null) { |
620 | - if (is_string($sql) && strlen($sql) > 5 && !$this->execute($sql)) { |
|
620 | + if (is_string($sql) && strlen($sql) > 5 && ! $this->execute($sql)) { |
|
621 | 621 | return null; |
622 | 622 | } |
623 | 623 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
682 | - if (!is_bool($result) && $cache) { |
|
682 | + if ( ! is_bool($result) && $cache) { |
|
683 | 683 | $this->_writeQueryCache($sql, $out, $params); |
684 | 684 | } |
685 | 685 | |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | } |
715 | 715 | list($alias, $virtual) = explode($this->virtualFieldSeparator, $field); |
716 | 716 | |
717 | - if (!ClassRegistry::isKeySet($alias)) { |
|
717 | + if ( ! ClassRegistry::isKeySet($alias)) { |
|
718 | 718 | return; |
719 | 719 | } |
720 | 720 | $model = ClassRegistry::getObject($alias); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | if ($this->cacheMethods === false) { |
772 | 772 | return $value; |
773 | 773 | } |
774 | - if (!$this->_methodCacheChange && empty(self::$methodCache)) { |
|
774 | + if ( ! $this->_methodCacheChange && empty(self::$methodCache)) { |
|
775 | 775 | self::$methodCache = Cache::read('method_cache', '_cake_core_'); |
776 | 776 | } |
777 | 777 | if ($value === null) { |
@@ -806,42 +806,42 @@ discard block |
||
806 | 806 | } |
807 | 807 | return $data; |
808 | 808 | } |
809 | - $cacheKey = md5($this->startQuote . $data . $this->endQuote); |
|
809 | + $cacheKey = md5($this->startQuote.$data.$this->endQuote); |
|
810 | 810 | if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) { |
811 | 811 | return $return; |
812 | 812 | } |
813 | 813 | $data = trim($data); |
814 | 814 | if (preg_match('/^[\w-]+(?:\.[^ \*]*)*$/', $data)) { // string, string.string |
815 | 815 | if (strpos($data, '.') === false) { // string |
816 | - return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote); |
|
816 | + return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote.$data.$this->endQuote); |
|
817 | 817 | } |
818 | 818 | $items = explode('.', $data); |
819 | 819 | return $this->cacheMethod(__FUNCTION__, $cacheKey, |
820 | - $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote |
|
820 | + $this->startQuote.implode($this->endQuote.'.'.$this->startQuote, $items).$this->endQuote |
|
821 | 821 | ); |
822 | 822 | } |
823 | 823 | if (preg_match('/^[\w-]+\.\*$/', $data)) { // string.* |
824 | 824 | return $this->cacheMethod(__FUNCTION__, $cacheKey, |
825 | - $this->startQuote . str_replace('.*', $this->endQuote . '.*', $data) |
|
825 | + $this->startQuote.str_replace('.*', $this->endQuote.'.*', $data) |
|
826 | 826 | ); |
827 | 827 | } |
828 | 828 | if (preg_match('/^([\w-]+)\((.*)\)$/', $data, $matches)) { // Functions |
829 | 829 | return $this->cacheMethod(__FUNCTION__, $cacheKey, |
830 | - $matches[1] . '(' . $this->name($matches[2]) . ')' |
|
830 | + $matches[1].'('.$this->name($matches[2]).')' |
|
831 | 831 | ); |
832 | 832 | } |
833 | 833 | if ( |
834 | - preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/i', $data, $matches |
|
834 | + preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+'.preg_quote($this->alias).'\s*([\w-]+)$/i', $data, $matches |
|
835 | 835 | )) { |
836 | 836 | return $this->cacheMethod( |
837 | 837 | __FUNCTION__, $cacheKey, |
838 | 838 | preg_replace( |
839 | - '/\s{2,}/', ' ', $this->name($matches[1]) . ' ' . $this->alias . ' ' . $this->name($matches[3]) |
|
839 | + '/\s{2,}/', ' ', $this->name($matches[1]).' '.$this->alias.' '.$this->name($matches[3]) |
|
840 | 840 | ) |
841 | 841 | ); |
842 | 842 | } |
843 | 843 | if (preg_match('/^[\w-_\s]*[\w-_]+/', $data)) { |
844 | - return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote); |
|
844 | + return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote.$data.$this->endQuote); |
|
845 | 845 | } |
846 | 846 | return $this->cacheMethod(__FUNCTION__, $cacheKey, $data); |
847 | 847 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | echo $View->element('sql_dump', array('_forced_from_dbo_' => true)); |
903 | 903 | } else { |
904 | 904 | foreach ($log['log'] as $k => $i) { |
905 | - print (($k + 1) . ". {$i['query']}\n"); |
|
905 | + print (($k + 1).". {$i['query']}\n"); |
|
906 | 906 | } |
907 | 907 | } |
908 | 908 | } |
@@ -940,27 +940,27 @@ discard block |
||
940 | 940 | public function fullTableName($model, $quote = true, $schema = true) { |
941 | 941 | if (is_object($model)) { |
942 | 942 | $schemaName = $model->schemaName; |
943 | - $table = $model->tablePrefix . $model->table; |
|
944 | - } elseif (!empty($this->config['prefix']) && strpos($model, $this->config['prefix']) !== 0) { |
|
945 | - $table = $this->config['prefix'] . strval($model); |
|
943 | + $table = $model->tablePrefix.$model->table; |
|
944 | + } elseif ( ! empty($this->config['prefix']) && strpos($model, $this->config['prefix']) !== 0) { |
|
945 | + $table = $this->config['prefix'].strval($model); |
|
946 | 946 | } else { |
947 | 947 | $table = strval($model); |
948 | 948 | } |
949 | - if ($schema && !isset($schemaName)) { |
|
949 | + if ($schema && ! isset($schemaName)) { |
|
950 | 950 | $schemaName = $this->getSchemaName(); |
951 | 951 | } |
952 | 952 | |
953 | 953 | if ($quote) { |
954 | - if ($schema && !empty($schemaName)) { |
|
954 | + if ($schema && ! empty($schemaName)) { |
|
955 | 955 | if (strstr($table, '.') === false) { |
956 | - return $this->name($schemaName) . '.' . $this->name($table); |
|
956 | + return $this->name($schemaName).'.'.$this->name($table); |
|
957 | 957 | } |
958 | 958 | } |
959 | 959 | return $this->name($table); |
960 | 960 | } |
961 | - if ($schema && !empty($schemaName)) { |
|
961 | + if ($schema && ! empty($schemaName)) { |
|
962 | 962 | if (strstr($table, '.') === false) { |
963 | - return $schemaName . '.' . $table; |
|
963 | + return $schemaName.'.'.$table; |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 | return $table; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | public function create(Model $model, $fields = null, $values = null) { |
982 | 982 | $id = null; |
983 | 983 | |
984 | - if (!$fields) { |
|
984 | + if ( ! $fields) { |
|
985 | 985 | unset($fields, $values); |
986 | 986 | $fields = array_keys($model->data); |
987 | 987 | $values = array_values($model->data); |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | $model->recursive = $recursive; |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - if (!empty($queryData['fields'])) { |
|
1043 | + if ( ! empty($queryData['fields'])) { |
|
1044 | 1044 | $bypass = true; |
1045 | 1045 | $queryData['fields'] = $this->fields($model, null, $queryData['fields']); |
1046 | 1046 | } else { |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | $assocData['fields'] = false; |
1067 | 1067 | } |
1068 | 1068 | if ($this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null) === true) { |
1069 | - $linkedModels[$type . '/' . $assoc] = true; |
|
1069 | + $linkedModels[$type.'/'.$assoc] = true; |
|
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | } |
@@ -1090,13 +1090,13 @@ discard block |
||
1090 | 1090 | if ($model->recursive > -1) { |
1091 | 1091 | $joined = array(); |
1092 | 1092 | if (isset($queryData['joins'][0]['alias'])) { |
1093 | - $joined[$model->alias] = (array)Hash::extract($queryData['joins'], '{n}.alias'); |
|
1093 | + $joined[$model->alias] = (array) Hash::extract($queryData['joins'], '{n}.alias'); |
|
1094 | 1094 | } |
1095 | 1095 | foreach ($_associations as $type) { |
1096 | 1096 | foreach ($model->{$type} as $assoc => $assocData) { |
1097 | 1097 | $linkModel = $model->{$assoc}; |
1098 | 1098 | |
1099 | - if (!isset($linkedModels[$type . '/' . $assoc])) { |
|
1099 | + if ( ! isset($linkedModels[$type.'/'.$assoc])) { |
|
1100 | 1100 | if ($model->useDbConfig === $linkModel->useDbConfig) { |
1101 | 1101 | $db = $this; |
1102 | 1102 | } else { |
@@ -1139,13 +1139,13 @@ discard block |
||
1139 | 1139 | */ |
1140 | 1140 | protected function _filterResults(&$results, Model $model, $filtered = array()) { |
1141 | 1141 | $current = reset($results); |
1142 | - if (!is_array($current)) { |
|
1142 | + if ( ! is_array($current)) { |
|
1143 | 1143 | return array(); |
1144 | 1144 | } |
1145 | 1145 | $keys = array_diff(array_keys($current), $filtered, array($model->alias)); |
1146 | 1146 | $filtering = array(); |
1147 | 1147 | foreach ($keys as $className) { |
1148 | - if (!isset($model->{$className}) || !is_object($model->{$className})) { |
|
1148 | + if ( ! isset($model->{$className}) || ! is_object($model->{$className})) { |
|
1149 | 1149 | continue; |
1150 | 1150 | } |
1151 | 1151 | $linkedModel = $model->{$className}; |
@@ -1185,10 +1185,10 @@ discard block |
||
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { |
1188 | - if (!is_array($resultSet)) { |
|
1188 | + if ( ! is_array($resultSet)) { |
|
1189 | 1189 | throw new CakeException(__d('cake_dev', 'Error in Model %s', get_class($model))); |
1190 | 1190 | } |
1191 | - if ($type === 'hasMany' && empty($assocData['limit']) && !empty($assocData['foreignKey'])) { |
|
1191 | + if ($type === 'hasMany' && empty($assocData['limit']) && ! empty($assocData['foreignKey'])) { |
|
1192 | 1192 | $ins = $fetch = array(); |
1193 | 1193 | foreach ($resultSet as &$result) { |
1194 | 1194 | if ($in = $this->insertQueryData('{$__cakeID__$}', $result, $association, $assocData, $model, $linkModel, $stack)) { |
@@ -1196,12 +1196,12 @@ discard block |
||
1196 | 1196 | } |
1197 | 1197 | } |
1198 | 1198 | |
1199 | - if (!empty($ins)) { |
|
1199 | + if ( ! empty($ins)) { |
|
1200 | 1200 | $ins = array_unique($ins); |
1201 | 1201 | $fetch = $this->fetchAssociated($model, $query, $ins); |
1202 | 1202 | } |
1203 | 1203 | |
1204 | - if (!empty($fetch) && is_array($fetch)) { |
|
1204 | + if ( ! empty($fetch) && is_array($fetch)) { |
|
1205 | 1205 | if ($recursive > 0) { |
1206 | 1206 | foreach ($linkModel->associations() as $type1) { |
1207 | 1207 | foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { |
@@ -1230,10 +1230,10 @@ discard block |
||
1230 | 1230 | $ins[] = $in; |
1231 | 1231 | } |
1232 | 1232 | } |
1233 | - if (!empty($ins)) { |
|
1233 | + if ( ! empty($ins)) { |
|
1234 | 1234 | $ins = array_unique($ins); |
1235 | 1235 | if (count($ins) > 1) { |
1236 | - $query = str_replace('{$__cakeID__$}', '(' . implode(', ', $ins) . ')', $query); |
|
1236 | + $query = str_replace('{$__cakeID__$}', '('.implode(', ', $ins).')', $query); |
|
1237 | 1237 | $query = str_replace('= (', 'IN (', $query); |
1238 | 1238 | } else { |
1239 | 1239 | $query = str_replace('{$__cakeID__$}', $ins[0], $query); |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | $joinedData = array(); |
1265 | 1265 | if (($type === 'belongsTo' || $type === 'hasOne') && isset($row[$linkModel->alias], $joined[$model->alias]) && in_array($linkModel->alias, $joined[$model->alias])) { |
1266 | 1266 | $joinedData = Hash::filter($row[$linkModel->alias]); |
1267 | - if (!empty($joinedData)) { |
|
1267 | + if ( ! empty($joinedData)) { |
|
1268 | 1268 | $fetch[0] = array($linkModel->alias => $row[$linkModel->alias]); |
1269 | 1269 | } |
1270 | 1270 | } else { |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | } |
1275 | 1275 | $selfJoin = $linkModel->name === $model->name; |
1276 | 1276 | |
1277 | - if (!empty($fetch) && is_array($fetch)) { |
|
1277 | + if ( ! empty($fetch) && is_array($fetch)) { |
|
1278 | 1278 | if ($recursive > 0) { |
1279 | 1279 | foreach ($linkModel->associations() as $type1) { |
1280 | 1280 | foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | $merge[] = $data; |
1305 | 1305 | } |
1306 | 1306 | } |
1307 | - if (empty($merge) && !isset($row[$association])) { |
|
1307 | + if (empty($merge) && ! isset($row[$association])) { |
|
1308 | 1308 | $row[$association] = $merge; |
1309 | 1309 | } else { |
1310 | 1310 | $this->_mergeAssociation($row, $merge, $association, $type); |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | $modelPK = $model->primaryKey; |
1355 | 1355 | $modelFK = $model->hasMany[$association]['foreignKey']; |
1356 | 1356 | foreach ($resultSet as &$result) { |
1357 | - if (!isset($result[$modelAlias])) { |
|
1357 | + if ( ! isset($result[$modelAlias])) { |
|
1358 | 1358 | continue; |
1359 | 1359 | } |
1360 | 1360 | $merged = array(); |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | * @return void |
1391 | 1391 | */ |
1392 | 1392 | protected function _mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) { |
1393 | - if (isset($merge[0]) && !isset($merge[0][$association])) { |
|
1393 | + if (isset($merge[0]) && ! isset($merge[0][$association])) { |
|
1394 | 1394 | $association = Inflector::pluralize($association); |
1395 | 1395 | } |
1396 | 1396 | |
@@ -1398,14 +1398,14 @@ discard block |
||
1398 | 1398 | if (isset($merge[$association])) { |
1399 | 1399 | $data[$association] = $merge[$association][0]; |
1400 | 1400 | } else { |
1401 | - if (!empty($merge[0][$association])) { |
|
1401 | + if ( ! empty($merge[0][$association])) { |
|
1402 | 1402 | foreach ($merge[0] as $assoc => $data2) { |
1403 | 1403 | if ($assoc !== $association) { |
1404 | 1404 | $merge[0][$association][$assoc] = $data2; |
1405 | 1405 | } |
1406 | 1406 | } |
1407 | 1407 | } |
1408 | - if (!isset($data[$association])) { |
|
1408 | + if ( ! isset($data[$association])) { |
|
1409 | 1409 | $data[$association] = array(); |
1410 | 1410 | if ($merge[0][$association]) { |
1411 | 1411 | $data[$association] = $merge[0][$association]; |
@@ -1413,13 +1413,13 @@ discard block |
||
1413 | 1413 | } else { |
1414 | 1414 | if (is_array($merge[0][$association])) { |
1415 | 1415 | foreach ($data[$association] as $k => $v) { |
1416 | - if (!is_array($v)) { |
|
1416 | + if ( ! is_array($v)) { |
|
1417 | 1417 | $dataAssocTmp[$k] = $v; |
1418 | 1418 | } |
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | foreach ($merge[0][$association] as $k => $v) { |
1422 | - if (!is_array($v)) { |
|
1422 | + if ( ! is_array($v)) { |
|
1423 | 1423 | $mergeAssocTmp[$k] = $v; |
1424 | 1424 | } |
1425 | 1425 | } |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | } |
1440 | 1440 | } else { |
1441 | 1441 | if (isset($merge[0][$association]) && $merge[0][$association] === false) { |
1442 | - if (!isset($data[$association])) { |
|
1442 | + if ( ! isset($data[$association])) { |
|
1443 | 1443 | $data[$association] = array(); |
1444 | 1444 | } |
1445 | 1445 | } else { |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | unset($insert[$association]); |
1453 | 1453 | } |
1454 | 1454 | |
1455 | - if (empty($data[$association]) || (isset($data[$association]) && !in_array($insert, $data[$association], true))) { |
|
1455 | + if (empty($data[$association]) || (isset($data[$association]) && ! in_array($insert, $data[$association], true))) { |
|
1456 | 1456 | $data[$association][] = $insert; |
1457 | 1457 | } |
1458 | 1458 | } |
@@ -1480,11 +1480,11 @@ discard block |
||
1480 | 1480 | |
1481 | 1481 | if (empty($queryData['fields'])) { |
1482 | 1482 | $queryData['fields'] = $this->fields($model, $modelAlias); |
1483 | - } elseif (!empty($model->hasMany) && $model->recursive > -1) { |
|
1483 | + } elseif ( ! empty($model->hasMany) && $model->recursive > -1) { |
|
1484 | 1484 | $assocFields = $this->fields($model, $modelAlias, array("{$modelAlias}.{$model->primaryKey}")); |
1485 | 1485 | $passedFields = $queryData['fields']; |
1486 | 1486 | if (count($passedFields) === 1) { |
1487 | - if (strpos($passedFields[0], $assocFields[0]) === false && !preg_match('/^[a-z]+\(/i', $passedFields[0])) { |
|
1487 | + if (strpos($passedFields[0], $assocFields[0]) === false && ! preg_match('/^[a-z]+\(/i', $passedFields[0])) { |
|
1488 | 1488 | $queryData['fields'] = array_merge($passedFields, $assocFields); |
1489 | 1489 | } else { |
1490 | 1490 | $queryData['fields'] = $passedFields; |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | $model |
1512 | 1512 | ); |
1513 | 1513 | } |
1514 | - if ($external && !empty($assocData['finderQuery'])) { |
|
1514 | + if ($external && ! empty($assocData['finderQuery'])) { |
|
1515 | 1515 | return $assocData['finderQuery']; |
1516 | 1516 | } |
1517 | 1517 | |
@@ -1521,7 +1521,7 @@ discard block |
||
1521 | 1521 | if ($external || (in_array($type, array('hasOne', 'belongsTo')) && $assocData['fields'] !== false)) { |
1522 | 1522 | $fields = $this->fields($linkModel, $association, $assocData['fields']); |
1523 | 1523 | } |
1524 | - if (empty($assocData['offset']) && !empty($assocData['page'])) { |
|
1524 | + if (empty($assocData['offset']) && ! empty($assocData['page'])) { |
|
1525 | 1525 | $assocData['offset'] = ($assocData['page'] - 1) * $assocData['limit']; |
1526 | 1526 | } |
1527 | 1527 | |
@@ -1533,9 +1533,9 @@ discard block |
||
1533 | 1533 | $this->getConstraint($type, $model, $linkModel, $association, array_merge($assocData, compact('external', 'self'))) |
1534 | 1534 | ); |
1535 | 1535 | |
1536 | - if (!$self && $external) { |
|
1536 | + if ( ! $self && $external) { |
|
1537 | 1537 | foreach ($conditions as $key => $condition) { |
1538 | - if (is_numeric($key) && strpos($condition, $modelAlias . '.') !== false) { |
|
1538 | + if (is_numeric($key) && strpos($condition, $modelAlias.'.') !== false) { |
|
1539 | 1539 | unset($conditions[$key]); |
1540 | 1540 | } |
1541 | 1541 | } |
@@ -1558,10 +1558,10 @@ discard block |
||
1558 | 1558 | ); |
1559 | 1559 | $queryData['fields'] = array_merge($queryData['fields'], $fields); |
1560 | 1560 | |
1561 | - if (!empty($assocData['order'])) { |
|
1561 | + if ( ! empty($assocData['order'])) { |
|
1562 | 1562 | $queryData['order'][] = $assocData['order']; |
1563 | 1563 | } |
1564 | - if (!in_array($join, $queryData['joins'], true)) { |
|
1564 | + if ( ! in_array($join, $queryData['joins'], true)) { |
|
1565 | 1565 | $queryData['joins'][] = $join; |
1566 | 1566 | } |
1567 | 1567 | return true; |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | break; |
1570 | 1570 | case 'hasMany': |
1571 | 1571 | $assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']); |
1572 | - if (!empty($assocData['foreignKey'])) { |
|
1572 | + if ( ! empty($assocData['foreignKey'])) { |
|
1573 | 1573 | $assocData['fields'] = array_merge($assocData['fields'], $this->fields($linkModel, $association, array("{$association}.{$assocData['foreignKey']}"))); |
1574 | 1574 | } |
1575 | 1575 | $query = array( |
@@ -1587,14 +1587,14 @@ discard block |
||
1587 | 1587 | $joinFields = array(); |
1588 | 1588 | $joinAssoc = null; |
1589 | 1589 | |
1590 | - if (isset($assocData['with']) && !empty($assocData['with'])) { |
|
1590 | + if (isset($assocData['with']) && ! empty($assocData['with'])) { |
|
1591 | 1591 | $joinKeys = array($assocData['foreignKey'], $assocData['associationForeignKey']); |
1592 | 1592 | list($with, $joinFields) = $model->joinModel($assocData['with'], $joinKeys); |
1593 | 1593 | |
1594 | 1594 | $joinTbl = $model->{$with}; |
1595 | 1595 | $joinAlias = $joinTbl; |
1596 | 1596 | |
1597 | - if (is_array($joinFields) && !empty($joinFields)) { |
|
1597 | + if (is_array($joinFields) && ! empty($joinFields)) { |
|
1598 | 1598 | $joinAssoc = $joinAlias = $model->{$with}->alias; |
1599 | 1599 | $joinFields = $this->fields($model->{$with}, $joinAlias, $joinFields); |
1600 | 1600 | } else { |
@@ -1650,9 +1650,9 @@ discard block |
||
1650 | 1650 | return array("{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}'); |
1651 | 1651 | case ($assoc['external'] && $type === 'belongsTo'): |
1652 | 1652 | return array("{$alias}.{$linkModel->primaryKey}" => '{$__cakeForeignKey__$}'); |
1653 | - case (!$assoc['external'] && $type === 'hasOne'): |
|
1653 | + case ( ! $assoc['external'] && $type === 'hasOne'): |
|
1654 | 1654 | return array("{$alias}.{$assoc['foreignKey']}" => $this->identifier("{$model->alias}.{$model->primaryKey}")); |
1655 | - case (!$assoc['external'] && $type === 'belongsTo'): |
|
1655 | + case ( ! $assoc['external'] && $type === 'belongsTo'): |
|
1656 | 1656 | return array("{$model->alias}.{$assoc['foreignKey']}" => $this->identifier("{$alias}.{$linkModel->primaryKey}")); |
1657 | 1657 | case ($type === 'hasMany'): |
1658 | 1658 | return array("{$alias}.{$assoc['foreignKey']}" => array('{$__cakeID__$}')); |
@@ -1681,13 +1681,13 @@ discard block |
||
1681 | 1681 | 'conditions' => array() |
1682 | 1682 | ), $join); |
1683 | 1683 | |
1684 | - if (!empty($data['alias'])) { |
|
1685 | - $data['alias'] = $this->alias . $this->name($data['alias']); |
|
1684 | + if ( ! empty($data['alias'])) { |
|
1685 | + $data['alias'] = $this->alias.$this->name($data['alias']); |
|
1686 | 1686 | } |
1687 | - if (!empty($data['conditions'])) { |
|
1687 | + if ( ! empty($data['conditions'])) { |
|
1688 | 1688 | $data['conditions'] = trim($this->conditions($data['conditions'], true, false)); |
1689 | 1689 | } |
1690 | - if (!empty($data['table']) && (!is_string($data['table']) || strpos($data['table'], '(') !== 0)) { |
|
1690 | + if ( ! empty($data['table']) && ( ! is_string($data['table']) || strpos($data['table'], '(') !== 0)) { |
|
1691 | 1691 | $data['table'] = $this->fullTableName($data['table']); |
1692 | 1692 | } |
1693 | 1693 | return $this->renderJoinStatement($data); |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | */ |
1704 | 1704 | public function buildStatement($query, $model) { |
1705 | 1705 | $query = array_merge($this->_queryDefaults, $query); |
1706 | - if (!empty($query['joins'])) { |
|
1706 | + if ( ! empty($query['joins'])) { |
|
1707 | 1707 | $count = count($query['joins']); |
1708 | 1708 | for ($i = 0; $i < $count; $i++) { |
1709 | 1709 | if (is_array($query['joins'][$i])) { |
@@ -1715,7 +1715,7 @@ discard block |
||
1715 | 1715 | 'conditions' => $this->conditions($query['conditions'], true, true, $model), |
1716 | 1716 | 'fields' => implode(', ', $query['fields']), |
1717 | 1717 | 'table' => $query['table'], |
1718 | - 'alias' => $this->alias . $this->name($query['alias']), |
|
1718 | + 'alias' => $this->alias.$this->name($query['alias']), |
|
1719 | 1719 | 'order' => $this->order($query['order'], 'ASC', $model), |
1720 | 1720 | 'limit' => $this->limit($query['limit'], $query['offset']), |
1721 | 1721 | 'joins' => implode(' ', $query['joins']), |
@@ -1753,19 +1753,19 @@ discard block |
||
1753 | 1753 | case 'create': |
1754 | 1754 | return "INSERT INTO {$table} ({$fields}) VALUES ({$values})"; |
1755 | 1755 | case 'update': |
1756 | - if (!empty($alias)) { |
|
1756 | + if ( ! empty($alias)) { |
|
1757 | 1757 | $aliases = "{$this->alias}{$alias} {$joins} "; |
1758 | 1758 | } |
1759 | 1759 | return trim("UPDATE {$table} {$aliases}SET {$fields} {$conditions}"); |
1760 | 1760 | case 'delete': |
1761 | - if (!empty($alias)) { |
|
1761 | + if ( ! empty($alias)) { |
|
1762 | 1762 | $aliases = "{$this->alias}{$alias} {$joins} "; |
1763 | 1763 | } |
1764 | 1764 | return trim("DELETE {$alias} FROM {$table} {$aliases}{$conditions}"); |
1765 | 1765 | case 'schema': |
1766 | 1766 | foreach (array('columns', 'indexes', 'tableParameters') as $var) { |
1767 | 1767 | if (is_array(${$var})) { |
1768 | - ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); |
|
1768 | + ${$var} = "\t".implode(",\n\t", array_filter(${$var})); |
|
1769 | 1769 | } else { |
1770 | 1770 | ${$var} = ''; |
1771 | 1771 | } |
@@ -1792,10 +1792,10 @@ discard block |
||
1792 | 1792 | } |
1793 | 1793 | |
1794 | 1794 | if (is_array($query)) { |
1795 | - return array_merge((array)$assoc, $query); |
|
1795 | + return array_merge((array) $assoc, $query); |
|
1796 | 1796 | } |
1797 | 1797 | |
1798 | - if (!empty($query)) { |
|
1798 | + if ( ! empty($query)) { |
|
1799 | 1799 | $query = array($query); |
1800 | 1800 | if (is_array($assoc)) { |
1801 | 1801 | $query = array_merge($query, $assoc); |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | * @return boolean Success |
1820 | 1820 | */ |
1821 | 1821 | public function update(Model $model, $fields = array(), $values = null, $conditions = null) { |
1822 | - if (!$values) { |
|
1822 | + if ( ! $values) { |
|
1823 | 1823 | $combined = $fields; |
1824 | 1824 | } else { |
1825 | 1825 | $combined = array_combine($fields, $values); |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | } |
1837 | 1837 | $query = compact('table', 'alias', 'joins', 'fields', 'conditions'); |
1838 | 1838 | |
1839 | - if (!$this->execute($this->renderStatement('update', $query))) { |
|
1839 | + if ( ! $this->execute($this->renderStatement('update', $query))) { |
|
1840 | 1840 | $model->onError(); |
1841 | 1841 | return false; |
1842 | 1842 | } |
@@ -1853,33 +1853,33 @@ discard block |
||
1853 | 1853 | * @return array Fields and values, quoted and prepared |
1854 | 1854 | */ |
1855 | 1855 | protected function _prepareUpdateFields(Model $model, $fields, $quoteValues = true, $alias = false) { |
1856 | - $quotedAlias = $this->startQuote . $model->alias . $this->endQuote; |
|
1856 | + $quotedAlias = $this->startQuote.$model->alias.$this->endQuote; |
|
1857 | 1857 | |
1858 | 1858 | $updates = array(); |
1859 | 1859 | foreach ($fields as $field => $value) { |
1860 | 1860 | if ($alias && strpos($field, '.') === false) { |
1861 | 1861 | $quoted = $model->escapeField($field); |
1862 | - } elseif (!$alias && strpos($field, '.') !== false) { |
|
1863 | - $quoted = $this->name(str_replace($quotedAlias . '.', '', str_replace( |
|
1864 | - $model->alias . '.', '', $field |
|
1862 | + } elseif ( ! $alias && strpos($field, '.') !== false) { |
|
1863 | + $quoted = $this->name(str_replace($quotedAlias.'.', '', str_replace( |
|
1864 | + $model->alias.'.', '', $field |
|
1865 | 1865 | ))); |
1866 | 1866 | } else { |
1867 | 1867 | $quoted = $this->name($field); |
1868 | 1868 | } |
1869 | 1869 | |
1870 | 1870 | if ($value === null) { |
1871 | - $updates[] = $quoted . ' = NULL'; |
|
1871 | + $updates[] = $quoted.' = NULL'; |
|
1872 | 1872 | continue; |
1873 | 1873 | } |
1874 | - $update = $quoted . ' = '; |
|
1874 | + $update = $quoted.' = '; |
|
1875 | 1875 | |
1876 | 1876 | if ($quoteValues) { |
1877 | 1877 | $update .= $this->value($value, $model->getColumnType($field)); |
1878 | 1878 | } elseif ($model->getColumnType($field) === 'boolean' && (is_int($value) || is_bool($value))) { |
1879 | 1879 | $update .= $this->boolean($value, true); |
1880 | - } elseif (!$alias) { |
|
1881 | - $update .= str_replace($quotedAlias . '.', '', str_replace( |
|
1882 | - $model->alias . '.', '', $value |
|
1880 | + } elseif ( ! $alias) { |
|
1881 | + $update .= str_replace($quotedAlias.'.', '', str_replace( |
|
1882 | + $model->alias.'.', '', $value |
|
1883 | 1883 | )); |
1884 | 1884 | } else { |
1885 | 1885 | $update .= $value; |
@@ -1935,7 +1935,7 @@ discard block |
||
1935 | 1935 | $field = ltrim($field, $this->startQuote); |
1936 | 1936 | $field = rtrim($field, $this->endQuote); |
1937 | 1937 | } |
1938 | - if (!$model->hasField($field)) { |
|
1938 | + if ( ! $model->hasField($field)) { |
|
1939 | 1939 | $noJoin = false; |
1940 | 1940 | break; |
1941 | 1941 | } |
@@ -1998,14 +1998,14 @@ discard block |
||
1998 | 1998 | * @return string An SQL calculation function |
1999 | 1999 | */ |
2000 | 2000 | public function calculate(Model $model, $func, $params = array()) { |
2001 | - $params = (array)$params; |
|
2001 | + $params = (array) $params; |
|
2002 | 2002 | |
2003 | 2003 | switch (strtolower($func)) { |
2004 | 2004 | case 'count': |
2005 | - if (!isset($params[0])) { |
|
2005 | + if ( ! isset($params[0])) { |
|
2006 | 2006 | $params[0] = '*'; |
2007 | 2007 | } |
2008 | - if (!isset($params[1])) { |
|
2008 | + if ( ! isset($params[1])) { |
|
2009 | 2009 | $params[1] = 'count'; |
2010 | 2010 | } |
2011 | 2011 | if (is_object($model) && $model->isVirtualField($params[0])) { |
@@ -2013,10 +2013,10 @@ discard block |
||
2013 | 2013 | } else { |
2014 | 2014 | $arg = $this->name($params[0]); |
2015 | 2015 | } |
2016 | - return 'COUNT(' . $arg . ') AS ' . $this->name($params[1]); |
|
2016 | + return 'COUNT('.$arg.') AS '.$this->name($params[1]); |
|
2017 | 2017 | case 'max': |
2018 | 2018 | case 'min': |
2019 | - if (!isset($params[1])) { |
|
2019 | + if ( ! isset($params[1])) { |
|
2020 | 2020 | $params[1] = $params[0]; |
2021 | 2021 | } |
2022 | 2022 | if (is_object($model) && $model->isVirtualField($params[0])) { |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | } else { |
2025 | 2025 | $arg = $this->name($params[0]); |
2026 | 2026 | } |
2027 | - return strtoupper($func) . '(' . $arg . ') AS ' . $this->name($params[1]); |
|
2027 | + return strtoupper($func).'('.$arg.') AS '.$this->name($params[1]); |
|
2028 | 2028 | } |
2029 | 2029 | } |
2030 | 2030 | |
@@ -2036,7 +2036,7 @@ discard block |
||
2036 | 2036 | * @return boolean SQL TRUNCATE TABLE statement, false if not applicable. |
2037 | 2037 | */ |
2038 | 2038 | public function truncate($table) { |
2039 | - return $this->execute('TRUNCATE TABLE ' . $this->fullTableName($table)); |
|
2039 | + return $this->execute('TRUNCATE TABLE '.$this->fullTableName($table)); |
|
2040 | 2040 | } |
2041 | 2041 | |
2042 | 2042 | /** |
@@ -2077,7 +2077,7 @@ discard block |
||
2077 | 2077 | * @return boolean |
2078 | 2078 | */ |
2079 | 2079 | protected function _beginNested() { |
2080 | - $query = 'SAVEPOINT LEVEL' . ++$this->_transactionNesting; |
|
2080 | + $query = 'SAVEPOINT LEVEL'.++$this->_transactionNesting; |
|
2081 | 2081 | if ($this->fullDebug) { |
2082 | 2082 | $this->logQuery($query); |
2083 | 2083 | } |
@@ -2093,7 +2093,7 @@ discard block |
||
2093 | 2093 | * or a transaction has not started). |
2094 | 2094 | */ |
2095 | 2095 | public function commit() { |
2096 | - if (!$this->_transactionStarted) { |
|
2096 | + if ( ! $this->_transactionStarted) { |
|
2097 | 2097 | return false; |
2098 | 2098 | } |
2099 | 2099 | |
@@ -2119,7 +2119,7 @@ discard block |
||
2119 | 2119 | * @return boolean |
2120 | 2120 | */ |
2121 | 2121 | protected function _commitNested() { |
2122 | - $query = 'RELEASE SAVEPOINT LEVEL' . $this->_transactionNesting--; |
|
2122 | + $query = 'RELEASE SAVEPOINT LEVEL'.$this->_transactionNesting--; |
|
2123 | 2123 | if ($this->fullDebug) { |
2124 | 2124 | $this->logQuery($query); |
2125 | 2125 | } |
@@ -2135,7 +2135,7 @@ discard block |
||
2135 | 2135 | * or a transaction has not started). |
2136 | 2136 | */ |
2137 | 2137 | public function rollback() { |
2138 | - if (!$this->_transactionStarted) { |
|
2138 | + if ( ! $this->_transactionStarted) { |
|
2139 | 2139 | return false; |
2140 | 2140 | } |
2141 | 2141 | |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | * @return boolean |
2162 | 2162 | */ |
2163 | 2163 | protected function _rollbackNested() { |
2164 | - $query = 'ROLLBACK TO SAVEPOINT LEVEL' . $this->_transactionNesting--; |
|
2164 | + $query = 'ROLLBACK TO SAVEPOINT LEVEL'.$this->_transactionNesting--; |
|
2165 | 2165 | if ($this->fullDebug) { |
2166 | 2166 | $this->logQuery($query); |
2167 | 2167 | } |
@@ -2194,18 +2194,18 @@ discard block |
||
2194 | 2194 | * @see DboSource::conditions() |
2195 | 2195 | */ |
2196 | 2196 | public function defaultConditions(Model $model, $conditions, $useAlias = true) { |
2197 | - if (!empty($conditions)) { |
|
2197 | + if ( ! empty($conditions)) { |
|
2198 | 2198 | return $conditions; |
2199 | 2199 | } |
2200 | 2200 | $exists = $model->exists(); |
2201 | - if (!$exists && $conditions !== null) { |
|
2201 | + if ( ! $exists && $conditions !== null) { |
|
2202 | 2202 | return false; |
2203 | - } elseif (!$exists) { |
|
2203 | + } elseif ( ! $exists) { |
|
2204 | 2204 | return null; |
2205 | 2205 | } |
2206 | 2206 | $alias = $model->alias; |
2207 | 2207 | |
2208 | - if (!$useAlias) { |
|
2208 | + if ( ! $useAlias) { |
|
2209 | 2209 | $alias = $this->fullTableName($model, false); |
2210 | 2210 | } |
2211 | 2211 | return array("{$alias}.{$model->primaryKey}" => $model->getID()); |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | */ |
2222 | 2222 | public function resolveKey(Model $model, $key, $assoc = null) { |
2223 | 2223 | if (strpos('.', $key) !== false) { |
2224 | - return $this->name($model->alias) . '.' . $this->name($key); |
|
2224 | + return $this->name($model->alias).'.'.$this->name($key); |
|
2225 | 2225 | } |
2226 | 2226 | return $key; |
2227 | 2227 | } |
@@ -2238,7 +2238,7 @@ discard block |
||
2238 | 2238 | $base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array()); |
2239 | 2239 | $base['callbacks'] = null; |
2240 | 2240 | } |
2241 | - return (array)$data + $base; |
|
2241 | + return (array) $data + $base; |
|
2242 | 2242 | } |
2243 | 2243 | |
2244 | 2244 | /** |
@@ -2252,9 +2252,9 @@ discard block |
||
2252 | 2252 | protected function _constructVirtualFields(Model $model, $alias, $fields) { |
2253 | 2253 | $virtual = array(); |
2254 | 2254 | foreach ($fields as $field) { |
2255 | - $virtualField = $this->name($alias . $this->virtualFieldSeparator . $field); |
|
2255 | + $virtualField = $this->name($alias.$this->virtualFieldSeparator.$field); |
|
2256 | 2256 | $expression = $this->_quoteFields($model->getVirtualField($field)); |
2257 | - $virtual[] = '(' . $expression . ") {$this->alias} {$virtualField}"; |
|
2257 | + $virtual[] = '('.$expression.") {$this->alias} {$virtualField}"; |
|
2258 | 2258 | } |
2259 | 2259 | return $virtual; |
2260 | 2260 | } |
@@ -2291,36 +2291,36 @@ discard block |
||
2291 | 2291 | $allFields = empty($fields); |
2292 | 2292 | if ($allFields) { |
2293 | 2293 | $fields = array_keys($model->schema()); |
2294 | - } elseif (!is_array($fields)) { |
|
2294 | + } elseif ( ! is_array($fields)) { |
|
2295 | 2295 | $fields = String::tokenize($fields); |
2296 | 2296 | } |
2297 | 2297 | $fields = array_values(array_filter($fields)); |
2298 | - $allFields = $allFields || in_array('*', $fields) || in_array($model->alias . '.*', $fields); |
|
2298 | + $allFields = $allFields || in_array('*', $fields) || in_array($model->alias.'.*', $fields); |
|
2299 | 2299 | |
2300 | 2300 | $virtual = array(); |
2301 | - if (!empty($virtualFields)) { |
|
2301 | + if ( ! empty($virtualFields)) { |
|
2302 | 2302 | $virtualKeys = array_keys($virtualFields); |
2303 | 2303 | foreach ($virtualKeys as $field) { |
2304 | - $virtualKeys[] = $model->alias . '.' . $field; |
|
2304 | + $virtualKeys[] = $model->alias.'.'.$field; |
|
2305 | 2305 | } |
2306 | 2306 | $virtual = ($allFields) ? $virtualKeys : array_intersect($virtualKeys, $fields); |
2307 | 2307 | foreach ($virtual as $i => $field) { |
2308 | 2308 | if (strpos($field, '.') !== false) { |
2309 | - $virtual[$i] = str_replace($model->alias . '.', '', $field); |
|
2309 | + $virtual[$i] = str_replace($model->alias.'.', '', $field); |
|
2310 | 2310 | } |
2311 | 2311 | $fields = array_diff($fields, array($field)); |
2312 | 2312 | } |
2313 | 2313 | $fields = array_values($fields); |
2314 | 2314 | } |
2315 | - if (!$quote) { |
|
2316 | - if (!empty($virtual)) { |
|
2315 | + if ( ! $quote) { |
|
2316 | + if ( ! empty($virtual)) { |
|
2317 | 2317 | $fields = array_merge($fields, $this->_constructVirtualFields($model, $alias, $virtual)); |
2318 | 2318 | } |
2319 | 2319 | return $fields; |
2320 | 2320 | } |
2321 | 2321 | $count = count($fields); |
2322 | 2322 | |
2323 | - if ($count >= 1 && !in_array($fields[0], array('*', 'COUNT(*)'))) { |
|
2323 | + if ($count >= 1 && ! in_array($fields[0], array('*', 'COUNT(*)'))) { |
|
2324 | 2324 | for ($i = 0; $i < $count; $i++) { |
2325 | 2325 | if (is_string($fields[$i]) && in_array($fields[$i], $virtual)) { |
2326 | 2326 | unset($fields[$i]); |
@@ -2328,9 +2328,9 @@ discard block |
||
2328 | 2328 | } |
2329 | 2329 | if (is_object($fields[$i]) && isset($fields[$i]->type) && $fields[$i]->type === 'expression') { |
2330 | 2330 | $fields[$i] = $fields[$i]->value; |
2331 | - } elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])) { |
|
2331 | + } elseif (preg_match('/^\(.*\)\s'.$this->alias.'.*/i', $fields[$i])) { |
|
2332 | 2332 | continue; |
2333 | - } elseif (!preg_match('/^.+\\(.*\\)/', $fields[$i])) { |
|
2333 | + } elseif ( ! preg_match('/^.+\\(.*\\)/', $fields[$i])) { |
|
2334 | 2334 | $prepend = ''; |
2335 | 2335 | |
2336 | 2336 | if (strpos($fields[$i], 'DISTINCT') !== false) { |
@@ -2340,36 +2340,36 @@ discard block |
||
2340 | 2340 | $dot = strpos($fields[$i], '.'); |
2341 | 2341 | |
2342 | 2342 | if ($dot === false) { |
2343 | - $prefix = !( |
|
2343 | + $prefix = ! ( |
|
2344 | 2344 | strpos($fields[$i], ' ') !== false || |
2345 | 2345 | strpos($fields[$i], '(') !== false |
2346 | 2346 | ); |
2347 | - $fields[$i] = $this->name(($prefix ? $alias . '.' : '') . $fields[$i]); |
|
2347 | + $fields[$i] = $this->name(($prefix ? $alias.'.' : '').$fields[$i]); |
|
2348 | 2348 | } else { |
2349 | 2349 | if (strpos($fields[$i], ',') === false) { |
2350 | 2350 | $build = explode('.', $fields[$i]); |
2351 | - if (!Hash::numeric($build)) { |
|
2351 | + if ( ! Hash::numeric($build)) { |
|
2352 | 2352 | $fields[$i] = $this->name(implode('.', $build)); |
2353 | 2353 | } |
2354 | 2354 | } |
2355 | 2355 | } |
2356 | - $fields[$i] = $prepend . $fields[$i]; |
|
2356 | + $fields[$i] = $prepend.$fields[$i]; |
|
2357 | 2357 | } elseif (preg_match('/\(([\.\w]+)\)/', $fields[$i], $field)) { |
2358 | 2358 | if (isset($field[1])) { |
2359 | 2359 | if (strpos($field[1], '.') === false) { |
2360 | - $field[1] = $this->name($alias . '.' . $field[1]); |
|
2360 | + $field[1] = $this->name($alias.'.'.$field[1]); |
|
2361 | 2361 | } else { |
2362 | 2362 | $field[0] = explode('.', $field[1]); |
2363 | - if (!Hash::numeric($field[0])) { |
|
2363 | + if ( ! Hash::numeric($field[0])) { |
|
2364 | 2364 | $field[0] = implode('.', array_map(array(&$this, 'name'), $field[0])); |
2365 | - $fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1); |
|
2365 | + $fields[$i] = preg_replace('/\('.$field[1].'\)/', '('.$field[0].')', $fields[$i], 1); |
|
2366 | 2366 | } |
2367 | 2367 | } |
2368 | 2368 | } |
2369 | 2369 | } |
2370 | 2370 | } |
2371 | 2371 | } |
2372 | - if (!empty($virtual)) { |
|
2372 | + if ( ! empty($virtual)) { |
|
2373 | 2373 | $fields = array_merge($fields, $this->_constructVirtualFields($model, $alias, $virtual)); |
2374 | 2374 | } |
2375 | 2375 | return $this->cacheMethod(__FUNCTION__, $cacheKey, array_unique($fields)); |
@@ -2397,20 +2397,20 @@ discard block |
||
2397 | 2397 | $clause = ' WHERE '; |
2398 | 2398 | } |
2399 | 2399 | |
2400 | - if (is_array($conditions) && !empty($conditions)) { |
|
2400 | + if (is_array($conditions) && ! empty($conditions)) { |
|
2401 | 2401 | $out = $this->conditionKeysToString($conditions, $quoteValues, $model); |
2402 | 2402 | |
2403 | 2403 | if (empty($out)) { |
2404 | - return $clause . ' 1 = 1'; |
|
2404 | + return $clause.' 1 = 1'; |
|
2405 | 2405 | } |
2406 | - return $clause . implode(' AND ', $out); |
|
2406 | + return $clause.implode(' AND ', $out); |
|
2407 | 2407 | } |
2408 | 2408 | if (is_bool($conditions)) { |
2409 | - return $clause . (int)$conditions . ' = 1'; |
|
2409 | + return $clause.(int) $conditions.' = 1'; |
|
2410 | 2410 | } |
2411 | 2411 | |
2412 | 2412 | if (empty($conditions) || trim($conditions) === '') { |
2413 | - return $clause . '1 = 1'; |
|
2413 | + return $clause.'1 = 1'; |
|
2414 | 2414 | } |
2415 | 2415 | $clauses = '/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i'; |
2416 | 2416 | |
@@ -2418,7 +2418,7 @@ discard block |
||
2418 | 2418 | $clause = ''; |
2419 | 2419 | } |
2420 | 2420 | $conditions = $this->_quoteFields($conditions); |
2421 | - return $clause . $conditions; |
|
2421 | + return $clause.$conditions; |
|
2422 | 2422 | } |
2423 | 2423 | |
2424 | 2424 | /** |
@@ -2440,7 +2440,7 @@ discard block |
||
2440 | 2440 | |
2441 | 2441 | if (is_array($value)) { |
2442 | 2442 | $valueInsert = ( |
2443 | - !empty($value) && |
|
2443 | + ! empty($value) && |
|
2444 | 2444 | (substr_count($key, '?') === count($value) || substr_count($key, ':') === count($value)) |
2445 | 2445 | ); |
2446 | 2446 | } |
@@ -2451,7 +2451,7 @@ discard block |
||
2451 | 2451 | $out[] = $this->_quoteFields($value); |
2452 | 2452 | } elseif ((is_numeric($key) && is_array($value)) || in_array(strtolower(trim($key)), $bool)) { |
2453 | 2453 | if (in_array(strtolower(trim($key)), $bool)) { |
2454 | - $join = ' ' . strtoupper($key) . ' '; |
|
2454 | + $join = ' '.strtoupper($key).' '; |
|
2455 | 2455 | } else { |
2456 | 2456 | $key = $join; |
2457 | 2457 | } |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | |
2460 | 2460 | if (strpos($join, 'NOT') !== false) { |
2461 | 2461 | if (strtoupper(trim($key)) === 'NOT') { |
2462 | - $key = 'AND ' . trim($key); |
|
2462 | + $key = 'AND '.trim($key); |
|
2463 | 2463 | } |
2464 | 2464 | $not = 'NOT '; |
2465 | 2465 | } |
@@ -2470,30 +2470,30 @@ discard block |
||
2470 | 2470 | |
2471 | 2471 | if (empty($value[1])) { |
2472 | 2472 | if ($not) { |
2473 | - $out[] = $not . '(' . $value[0] . ')'; |
|
2473 | + $out[] = $not.'('.$value[0].')'; |
|
2474 | 2474 | } else { |
2475 | 2475 | $out[] = $value[0]; |
2476 | 2476 | } |
2477 | 2477 | } else { |
2478 | - $out[] = '(' . $not . '(' . implode(') ' . strtoupper($key) . ' (', $value) . '))'; |
|
2478 | + $out[] = '('.$not.'('.implode(') '.strtoupper($key).' (', $value).'))'; |
|
2479 | 2479 | } |
2480 | 2480 | } else { |
2481 | 2481 | if (is_object($value) && isset($value->type)) { |
2482 | 2482 | if ($value->type === 'identifier') { |
2483 | - $data .= $this->name($key) . ' = ' . $this->name($value->value); |
|
2483 | + $data .= $this->name($key).' = '.$this->name($value->value); |
|
2484 | 2484 | } elseif ($value->type === 'expression') { |
2485 | 2485 | if (is_numeric($key)) { |
2486 | 2486 | $data .= $value->value; |
2487 | 2487 | } else { |
2488 | - $data .= $this->name($key) . ' = ' . $value->value; |
|
2488 | + $data .= $this->name($key).' = '.$value->value; |
|
2489 | 2489 | } |
2490 | 2490 | } |
2491 | - } elseif (is_array($value) && !empty($value) && !$valueInsert) { |
|
2491 | + } elseif (is_array($value) && ! empty($value) && ! $valueInsert) { |
|
2492 | 2492 | $keys = array_keys($value); |
2493 | 2493 | if ($keys === array_values($keys)) { |
2494 | 2494 | $count = count($value); |
2495 | - if ($count === 1 && !preg_match('/\s+(?:NOT|\!=)$/', $key)) { |
|
2496 | - $data = $this->_quoteFields($key) . ' = ('; |
|
2495 | + if ($count === 1 && ! preg_match('/\s+(?:NOT|\!=)$/', $key)) { |
|
2496 | + $data = $this->_quoteFields($key).' = ('; |
|
2497 | 2497 | if ($quoteValues) { |
2498 | 2498 | if (is_object($model)) { |
2499 | 2499 | $columnType = $model->getColumnType($key); |
@@ -2507,12 +2507,12 @@ discard block |
||
2507 | 2507 | } else { |
2508 | 2508 | $ret = $this->conditionKeysToString($value, $quoteValues, $model); |
2509 | 2509 | if (count($ret) > 1) { |
2510 | - $data = '(' . implode(') AND (', $ret) . ')'; |
|
2510 | + $data = '('.implode(') AND (', $ret).')'; |
|
2511 | 2511 | } elseif (isset($ret[0])) { |
2512 | 2512 | $data = $ret[0]; |
2513 | 2513 | } |
2514 | 2514 | } |
2515 | - } elseif (is_numeric($key) && !empty($value)) { |
|
2515 | + } elseif (is_numeric($key) && ! empty($value)) { |
|
2516 | 2516 | $data = $this->_quoteFields($value); |
2517 | 2517 | } else { |
2518 | 2518 | $data = $this->_parseKey($model, trim($key), $value); |
@@ -2537,7 +2537,7 @@ discard block |
||
2537 | 2537 | * @return string |
2538 | 2538 | */ |
2539 | 2539 | protected function _parseKey($model, $key, $value) { |
2540 | - $operatorMatch = '/^(((' . implode(')|(', $this->_sqlOps); |
|
2540 | + $operatorMatch = '/^((('.implode(')|(', $this->_sqlOps); |
|
2541 | 2541 | $operatorMatch .= ')\\x20?)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; |
2542 | 2542 | $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); |
2543 | 2543 | |
@@ -2546,8 +2546,8 @@ discard block |
||
2546 | 2546 | } else { |
2547 | 2547 | list($key, $operator) = explode(' ', trim($key), 2); |
2548 | 2548 | |
2549 | - if (!preg_match($operatorMatch, trim($operator)) && strpos($operator, ' ') !== false) { |
|
2550 | - $key = $key . ' ' . $operator; |
|
2549 | + if ( ! preg_match($operatorMatch, trim($operator)) && strpos($operator, ' ') !== false) { |
|
2550 | + $key = $key.' '.$operator; |
|
2551 | 2551 | $split = strrpos($key, ' '); |
2552 | 2552 | $operator = substr($key, $split); |
2553 | 2553 | $key = substr($key, 0, $split); |
@@ -2572,7 +2572,7 @@ discard block |
||
2572 | 2572 | |
2573 | 2573 | $value = $this->value($value, $type); |
2574 | 2574 | |
2575 | - if (!$virtual && $key !== '?') { |
|
2575 | + if ( ! $virtual && $key !== '?') { |
|
2576 | 2576 | $isKey = ( |
2577 | 2577 | strpos($key, '(') !== false || |
2578 | 2578 | strpos($key, ')') !== false || |
@@ -2582,10 +2582,10 @@ discard block |
||
2582 | 2582 | } |
2583 | 2583 | |
2584 | 2584 | if ($bound) { |
2585 | - return String::insert($key . ' ' . trim($operator), $value); |
|
2585 | + return String::insert($key.' '.trim($operator), $value); |
|
2586 | 2586 | } |
2587 | 2587 | |
2588 | - if (!preg_match($operatorMatch, trim($operator))) { |
|
2588 | + if ( ! preg_match($operatorMatch, trim($operator))) { |
|
2589 | 2589 | $operator .= is_array($value) ? ' IN' : ' ='; |
2590 | 2590 | } |
2591 | 2591 | $operator = trim($operator); |
@@ -2630,10 +2630,10 @@ discard block |
||
2630 | 2630 | $start = $end = null; |
2631 | 2631 | $original = $conditions; |
2632 | 2632 | |
2633 | - if (!empty($this->startQuote)) { |
|
2633 | + if ( ! empty($this->startQuote)) { |
|
2634 | 2634 | $start = preg_quote($this->startQuote); |
2635 | 2635 | } |
2636 | - if (!empty($this->endQuote)) { |
|
2636 | + if ( ! empty($this->endQuote)) { |
|
2637 | 2637 | $end = preg_quote($this->endQuote); |
2638 | 2638 | } |
2639 | 2639 | $conditions = str_replace(array($start, $end), '', $conditions); |
@@ -2691,12 +2691,12 @@ discard block |
||
2691 | 2691 | * @return string ORDER BY clause |
2692 | 2692 | */ |
2693 | 2693 | public function order($keys, $direction = 'ASC', $model = null) { |
2694 | - if (!is_array($keys)) { |
|
2694 | + if ( ! is_array($keys)) { |
|
2695 | 2695 | $keys = array($keys); |
2696 | 2696 | } |
2697 | 2697 | $keys = array_filter($keys); |
2698 | 2698 | $result = array(); |
2699 | - while (!empty($keys)) { |
|
2699 | + while ( ! empty($keys)) { |
|
2700 | 2700 | list($key, $dir) = each($keys); |
2701 | 2701 | array_shift($keys); |
2702 | 2702 | |
@@ -2705,7 +2705,7 @@ discard block |
||
2705 | 2705 | $dir = $direction; |
2706 | 2706 | } |
2707 | 2707 | |
2708 | - if (is_string($key) && strpos($key, ',') !== false && !preg_match('/\(.+\,.+\)/', $key)) { |
|
2708 | + if (is_string($key) && strpos($key, ',') !== false && ! preg_match('/\(.+\,.+\)/', $key)) { |
|
2709 | 2709 | $key = array_map('trim', explode(',', $key)); |
2710 | 2710 | } |
2711 | 2711 | if (is_array($key)) { |
@@ -2732,24 +2732,24 @@ discard block |
||
2732 | 2732 | $key = trim($key); |
2733 | 2733 | |
2734 | 2734 | if (is_object($model) && $model->isVirtualField($key)) { |
2735 | - $key = '(' . $this->_quoteFields($model->getVirtualField($key)) . ')'; |
|
2735 | + $key = '('.$this->_quoteFields($model->getVirtualField($key)).')'; |
|
2736 | 2736 | } |
2737 | 2737 | list($alias) = pluginSplit($key); |
2738 | 2738 | if (is_object($model) && $alias !== $model->alias && is_object($model->{$alias}) && $model->{$alias}->isVirtualField($key)) { |
2739 | - $key = '(' . $this->_quoteFields($model->{$alias}->getVirtualField($key)) . ')'; |
|
2739 | + $key = '('.$this->_quoteFields($model->{$alias}->getVirtualField($key)).')'; |
|
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | if (strpos($key, '.')) { |
2743 | 2743 | $key = preg_replace_callback('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', array(&$this, '_quoteMatchedField'), $key); |
2744 | 2744 | } |
2745 | - if (!preg_match('/\s/', $key) && strpos($key, '.') === false) { |
|
2745 | + if ( ! preg_match('/\s/', $key) && strpos($key, '.') === false) { |
|
2746 | 2746 | $key = $this->name($key); |
2747 | 2747 | } |
2748 | - $key .= ' ' . trim($dir); |
|
2748 | + $key .= ' '.trim($dir); |
|
2749 | 2749 | $result[] = $key; |
2750 | 2750 | } |
2751 | - if (!empty($result)) { |
|
2752 | - return ' ORDER BY ' . implode(', ', $result); |
|
2751 | + if ( ! empty($result)) { |
|
2752 | + return ' ORDER BY '.implode(', ', $result); |
|
2753 | 2753 | } |
2754 | 2754 | return ''; |
2755 | 2755 | } |
@@ -2763,16 +2763,16 @@ discard block |
||
2763 | 2763 | */ |
2764 | 2764 | public function group($group, $model = null) { |
2765 | 2765 | if ($group) { |
2766 | - if (!is_array($group)) { |
|
2766 | + if ( ! is_array($group)) { |
|
2767 | 2767 | $group = array($group); |
2768 | 2768 | } |
2769 | 2769 | foreach ($group as $index => $key) { |
2770 | 2770 | if (is_object($model) && $model->isVirtualField($key)) { |
2771 | - $group[$index] = '(' . $model->getVirtualField($key) . ')'; |
|
2771 | + $group[$index] = '('.$model->getVirtualField($key).')'; |
|
2772 | 2772 | } |
2773 | 2773 | } |
2774 | 2774 | $group = implode(', ', $group); |
2775 | - return ' GROUP BY ' . $this->_quoteFields($group); |
|
2775 | + return ' GROUP BY '.$this->_quoteFields($group); |
|
2776 | 2776 | } |
2777 | 2777 | return null; |
2778 | 2778 | } |
@@ -2796,7 +2796,7 @@ discard block |
||
2796 | 2796 | public function hasAny(Model $Model, $sql) { |
2797 | 2797 | $sql = $this->conditions($sql); |
2798 | 2798 | $table = $this->fullTableName($Model); |
2799 | - $alias = $this->alias . $this->name($Model->alias); |
|
2799 | + $alias = $this->alias.$this->name($Model->alias); |
|
2800 | 2800 | $where = $sql ? "{$sql}" : ' WHERE 1 = 1'; |
2801 | 2801 | $id = $Model->escapeField(); |
2802 | 2802 | |
@@ -2815,7 +2815,7 @@ discard block |
||
2815 | 2815 | * @return mixed An integer or string representing the length of the column, or null for unknown length. |
2816 | 2816 | */ |
2817 | 2817 | public function length($real) { |
2818 | - if (!preg_match_all('/([\w\s]+)(?:\((\d+)(?:,(\d+))?\))?(\sunsigned)?(\szerofill)?/', $real, $result)) { |
|
2818 | + if ( ! preg_match_all('/([\w\s]+)(?:\((\d+)(?:,(\d+))?\))?(\sunsigned)?(\szerofill)?/', $real, $result)) { |
|
2819 | 2819 | $col = str_replace(array(')', 'unsigned'), '', $real); |
2820 | 2820 | $limit = null; |
2821 | 2821 | |
@@ -2840,7 +2840,7 @@ discard block |
||
2840 | 2840 | |
2841 | 2841 | $isFloat = in_array($type, array('dec', 'decimal', 'float', 'numeric', 'double')); |
2842 | 2842 | if ($isFloat && $offset) { |
2843 | - return $length . ',' . $offset; |
|
2843 | + return $length.','.$offset; |
|
2844 | 2844 | } |
2845 | 2845 | |
2846 | 2846 | if (($real[0] == $type) && (count($real) === 1)) { |
@@ -2849,7 +2849,7 @@ discard block |
||
2849 | 2849 | |
2850 | 2850 | if (isset($types[$type])) { |
2851 | 2851 | $length += $types[$type]; |
2852 | - if (!empty($sign)) { |
|
2852 | + if ( ! empty($sign)) { |
|
2853 | 2853 | $length--; |
2854 | 2854 | } |
2855 | 2855 | } elseif (in_array($type, array('enum', 'set'))) { |
@@ -2876,9 +2876,9 @@ discard block |
||
2876 | 2876 | */ |
2877 | 2877 | public function boolean($data, $quote = false) { |
2878 | 2878 | if ($quote) { |
2879 | - return !empty($data) ? '1' : '0'; |
|
2879 | + return ! empty($data) ? '1' : '0'; |
|
2880 | 2880 | } |
2881 | - return !empty($data); |
|
2881 | + return ! empty($data); |
|
2882 | 2882 | } |
2883 | 2883 | |
2884 | 2884 | /** |
@@ -2962,14 +2962,14 @@ discard block |
||
2962 | 2962 | * @return string |
2963 | 2963 | */ |
2964 | 2964 | public function createSchema($schema, $tableName = null) { |
2965 | - if (!$schema instanceof CakeSchema) { |
|
2965 | + if ( ! $schema instanceof CakeSchema) { |
|
2966 | 2966 | trigger_error(__d('cake_dev', 'Invalid schema object'), E_USER_WARNING); |
2967 | 2967 | return null; |
2968 | 2968 | } |
2969 | 2969 | $out = ''; |
2970 | 2970 | |
2971 | 2971 | foreach ($schema->tables as $curTable => $columns) { |
2972 | - if (!$tableName || $tableName === $curTable) { |
|
2972 | + if ( ! $tableName || $tableName === $curTable) { |
|
2973 | 2973 | $cols = $indexes = $tableParameters = array(); |
2974 | 2974 | $primary = null; |
2975 | 2975 | $table = $this->fullTableName($curTable); |
@@ -2996,7 +2996,7 @@ discard block |
||
2996 | 2996 | } |
2997 | 2997 | if ($name !== 'indexes' && $name !== 'tableParameters') { |
2998 | 2998 | $col['name'] = $name; |
2999 | - if (!isset($col['type'])) { |
|
2999 | + if ( ! isset($col['type'])) { |
|
3000 | 3000 | $col['type'] = 'string'; |
3001 | 3001 | } |
3002 | 3002 | $cols[] = $this->buildColumn($col); |
@@ -3006,12 +3006,12 @@ discard block |
||
3006 | 3006 | $tableParameters = array_merge($tableParameters, $this->buildTableParameters($col, $table)); |
3007 | 3007 | } |
3008 | 3008 | } |
3009 | - if (!isset($columns['indexes']['PRIMARY']) && !empty($primary)) { |
|
3009 | + if ( ! isset($columns['indexes']['PRIMARY']) && ! empty($primary)) { |
|
3010 | 3010 | $col = array('PRIMARY' => array('column' => $primary, 'unique' => 1)); |
3011 | 3011 | $indexes = array_merge($indexes, $this->buildIndex($col, $table)); |
3012 | 3012 | } |
3013 | 3013 | $columns = $cols; |
3014 | - $out .= $this->renderStatement('schema', compact('table', 'columns', 'indexes', 'tableParameters')) . "\n\n"; |
|
3014 | + $out .= $this->renderStatement('schema', compact('table', 'columns', 'indexes', 'tableParameters'))."\n\n"; |
|
3015 | 3015 | } |
3016 | 3016 | } |
3017 | 3017 | return $out; |
@@ -3040,13 +3040,13 @@ discard block |
||
3040 | 3040 | $out = ''; |
3041 | 3041 | |
3042 | 3042 | if ($table && array_key_exists($table, $schema->tables)) { |
3043 | - return $this->_dropTable($table) . "\n"; |
|
3043 | + return $this->_dropTable($table)."\n"; |
|
3044 | 3044 | } elseif ($table) { |
3045 | 3045 | return $out; |
3046 | 3046 | } |
3047 | 3047 | |
3048 | 3048 | foreach (array_keys($schema->tables) as $curTable) { |
3049 | - $out .= $this->_dropTable($curTable) . "\n"; |
|
3049 | + $out .= $this->_dropTable($curTable)."\n"; |
|
3050 | 3050 | } |
3051 | 3051 | return $out; |
3052 | 3052 | } |
@@ -3058,7 +3058,7 @@ discard block |
||
3058 | 3058 | * @return string Drop table SQL statement |
3059 | 3059 | */ |
3060 | 3060 | protected function _dropTable($table) { |
3061 | - return 'DROP TABLE ' . $this->fullTableName($table) . ";"; |
|
3061 | + return 'DROP TABLE '.$this->fullTableName($table).";"; |
|
3062 | 3062 | } |
3063 | 3063 | |
3064 | 3064 | /** |
@@ -3077,13 +3077,13 @@ discard block |
||
3077 | 3077 | return null; |
3078 | 3078 | } |
3079 | 3079 | |
3080 | - if (!isset($this->columns[$type])) { |
|
3080 | + if ( ! isset($this->columns[$type])) { |
|
3081 | 3081 | trigger_error(__d('cake_dev', 'Column type %s does not exist', $type), E_USER_WARNING); |
3082 | 3082 | return null; |
3083 | 3083 | } |
3084 | 3084 | |
3085 | 3085 | $real = $this->columns[$type]; |
3086 | - $out = $this->name($name) . ' ' . $real['name']; |
|
3086 | + $out = $this->name($name).' '.$real['name']; |
|
3087 | 3087 | |
3088 | 3088 | if (isset($column['length'])) { |
3089 | 3089 | $length = $column['length']; |
@@ -3095,7 +3095,7 @@ discard block |
||
3095 | 3095 | $length = $real['limit']; |
3096 | 3096 | } |
3097 | 3097 | if (isset($length)) { |
3098 | - $out .= '(' . $length . ')'; |
|
3098 | + $out .= '('.$length.')'; |
|
3099 | 3099 | } |
3100 | 3100 | |
3101 | 3101 | if (($column['type'] === 'integer' || $column['type'] === 'float') && isset($column['default']) && $column['default'] === '') { |
@@ -3104,16 +3104,16 @@ discard block |
||
3104 | 3104 | $out = $this->_buildFieldParameters($out, $column, 'beforeDefault'); |
3105 | 3105 | |
3106 | 3106 | if (isset($column['key']) && $column['key'] === 'primary' && ($type === 'integer' || $type === 'biginteger')) { |
3107 | - $out .= ' ' . $this->columns['primary_key']['name']; |
|
3107 | + $out .= ' '.$this->columns['primary_key']['name']; |
|
3108 | 3108 | } elseif (isset($column['key']) && $column['key'] === 'primary') { |
3109 | 3109 | $out .= ' NOT NULL'; |
3110 | 3110 | } elseif (isset($column['default']) && isset($column['null']) && $column['null'] === false) { |
3111 | - $out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL'; |
|
3111 | + $out .= ' DEFAULT '.$this->value($column['default'], $type).' NOT NULL'; |
|
3112 | 3112 | } elseif (isset($column['default'])) { |
3113 | - $out .= ' DEFAULT ' . $this->value($column['default'], $type); |
|
3114 | - } elseif ($type !== 'timestamp' && !empty($column['null'])) { |
|
3113 | + $out .= ' DEFAULT '.$this->value($column['default'], $type); |
|
3114 | + } elseif ($type !== 'timestamp' && ! empty($column['null'])) { |
|
3115 | 3115 | $out .= ' DEFAULT NULL'; |
3116 | - } elseif ($type === 'timestamp' && !empty($column['null'])) { |
|
3116 | + } elseif ($type === 'timestamp' && ! empty($column['null'])) { |
|
3117 | 3117 | $out .= ' NULL'; |
3118 | 3118 | } elseif (isset($column['null']) && $column['null'] === false) { |
3119 | 3119 | $out .= ' NOT NULL'; |
@@ -3135,14 +3135,14 @@ discard block |
||
3135 | 3135 | protected function _buildFieldParameters($columnString, $columnData, $position) { |
3136 | 3136 | foreach ($this->fieldParameters as $paramName => $value) { |
3137 | 3137 | if (isset($columnData[$paramName]) && $value['position'] == $position) { |
3138 | - if (isset($value['options']) && !in_array($columnData[$paramName], $value['options'])) { |
|
3138 | + if (isset($value['options']) && ! in_array($columnData[$paramName], $value['options'])) { |
|
3139 | 3139 | continue; |
3140 | 3140 | } |
3141 | 3141 | $val = $columnData[$paramName]; |
3142 | 3142 | if ($value['quote']) { |
3143 | 3143 | $val = $this->value($val); |
3144 | 3144 | } |
3145 | - $columnString .= ' ' . $value['value'] . $value['join'] . $val; |
|
3145 | + $columnString .= ' '.$value['value'].$value['join'].$val; |
|
3146 | 3146 | } |
3147 | 3147 | } |
3148 | 3148 | return $columnString; |
@@ -3163,15 +3163,15 @@ discard block |
||
3163 | 3163 | $out .= 'PRIMARY '; |
3164 | 3164 | $name = null; |
3165 | 3165 | } else { |
3166 | - if (!empty($value['unique'])) { |
|
3166 | + if ( ! empty($value['unique'])) { |
|
3167 | 3167 | $out .= 'UNIQUE '; |
3168 | 3168 | } |
3169 | - $name = $this->startQuote . $name . $this->endQuote; |
|
3169 | + $name = $this->startQuote.$name.$this->endQuote; |
|
3170 | 3170 | } |
3171 | 3171 | if (is_array($value['column'])) { |
3172 | - $out .= 'KEY ' . $name . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; |
|
3172 | + $out .= 'KEY '.$name.' ('.implode(', ', array_map(array(&$this, 'name'), $value['column'])).')'; |
|
3173 | 3173 | } else { |
3174 | - $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')'; |
|
3174 | + $out .= 'KEY '.$name.' ('.$this->name($value['column']).')'; |
|
3175 | 3175 | } |
3176 | 3176 | $join[] = $out; |
3177 | 3177 | } |
@@ -3189,7 +3189,7 @@ discard block |
||
3189 | 3189 | if (method_exists($this, 'listDetailedSources')) { |
3190 | 3190 | $currentTableDetails = $this->listDetailedSources($name); |
3191 | 3191 | foreach ($this->tableParameters as $paramName => $parameter) { |
3192 | - if (!empty($parameter['column']) && !empty($currentTableDetails[$parameter['column']])) { |
|
3192 | + if ( ! empty($parameter['column']) && ! empty($currentTableDetails[$parameter['column']])) { |
|
3193 | 3193 | $parameters[$paramName] = $currentTableDetails[$parameter['column']]; |
3194 | 3194 | } |
3195 | 3195 | } |
@@ -3211,7 +3211,7 @@ discard block |
||
3211 | 3211 | if ($this->tableParameters[$name]['quote']) { |
3212 | 3212 | $value = $this->value($value); |
3213 | 3213 | } |
3214 | - $result[] = $this->tableParameters[$name]['value'] . $this->tableParameters[$name]['join'] . $value; |
|
3214 | + $result[] = $this->tableParameters[$name]['value'].$this->tableParameters[$name]['join'].$value; |
|
3215 | 3215 | } |
3216 | 3216 | } |
3217 | 3217 | return $result; |
@@ -3224,7 +3224,7 @@ discard block |
||
3224 | 3224 | * @return void |
3225 | 3225 | */ |
3226 | 3226 | public function introspectType($value) { |
3227 | - if (!is_array($value)) { |
|
3227 | + if ( ! is_array($value)) { |
|
3228 | 3228 | if (is_bool($value)) { |
3229 | 3229 | return 'boolean'; |
3230 | 3230 | } |
@@ -3244,12 +3244,12 @@ discard block |
||
3244 | 3244 | $containsInt = $containsString = false; |
3245 | 3245 | foreach ($value as $valElement) { |
3246 | 3246 | $valElement = trim($valElement); |
3247 | - if (!is_float($valElement) && !preg_match('/^[\d]+\.[\d]+$/', $valElement)) { |
|
3247 | + if ( ! is_float($valElement) && ! preg_match('/^[\d]+\.[\d]+$/', $valElement)) { |
|
3248 | 3248 | $isAllFloat = false; |
3249 | 3249 | } else { |
3250 | 3250 | continue; |
3251 | 3251 | } |
3252 | - if (!is_int($valElement) && !preg_match('/^[\d]+$/', $valElement)) { |
|
3252 | + if ( ! is_int($valElement) && ! preg_match('/^[\d]+$/', $valElement)) { |
|
3253 | 3253 | $isAllInt = false; |
3254 | 3254 | } else { |
3255 | 3255 | $containsInt = true; |
@@ -3265,7 +3265,7 @@ discard block |
||
3265 | 3265 | return 'integer'; |
3266 | 3266 | } |
3267 | 3267 | |
3268 | - if ($containsInt && !$containsString) { |
|
3268 | + if ($containsInt && ! $containsString) { |
|
3269 | 3269 | return 'integer'; |
3270 | 3270 | } |
3271 | 3271 | return 'string'; |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Method used to read from a database session. |
87 | 87 | * |
88 | - * @param integer|string $id The key of the value to read |
|
89 | - * @return mixed The value of the key or false if it does not exist |
|
88 | + * @param string $id The key of the value to read |
|
89 | + * @return boolean The value of the key or false if it does not exist |
|
90 | 90 | */ |
91 | 91 | public function read($id) { |
92 | 92 | $row = $this->_model->find('first', array( |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * Helper function called on write for database sessions. |
105 | 105 | * |
106 | 106 | * @param integer $id ID that uniquely identifies session in database |
107 | - * @param mixed $data The value of the data to be saved. |
|
107 | + * @param string $data The value of the data to be saved. |
|
108 | 108 | * @return boolean True for successful write, false otherwise. |
109 | 109 | */ |
110 | 110 | public function write($id, $data) { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return boolean True for successful write, false otherwise. |
109 | 109 | */ |
110 | 110 | public function write($id, $data) { |
111 | - if (!$id) { |
|
111 | + if ( ! $id) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | $expires = time() + $this->_timeout; |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @return boolean Success |
135 | 135 | */ |
136 | 136 | public function gc($expires = null) { |
137 | - if (!$expires) { |
|
137 | + if ( ! $expires) { |
|
138 | 138 | $expires = time(); |
139 | 139 | } else { |
140 | 140 | $expires = time() - $expires; |
141 | 141 | } |
142 | - return $this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false); |
|
142 | + return $this->_model->deleteAll(array($this->_model->alias.".expires <" => $expires), false, false); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | * |
1648 | 1648 | * @param string $name Name of the table field |
1649 | 1649 | * @param mixed $value Value of the field |
1650 | - * @param boolean|array $validate Either a boolean, or an array. |
|
1650 | + * @param boolean $validate Either a boolean, or an array. |
|
1651 | 1651 | * If a boolean, indicates whether or not to validate before saving. |
1652 | 1652 | * If an array, allows control of 'validate', 'callbacks' and 'counterCache' options. |
1653 | 1653 | * See Model::save() for details of each options. |
@@ -2285,7 +2285,7 @@ discard block |
||
2285 | 2285 | * |
2286 | 2286 | * @param array $data Record data to validate. This should be a numerically-indexed array |
2287 | 2287 | * @param array $options Options to use when validating record data (see above), See also $options of validates(). |
2288 | - * @return boolean|array If atomic: True on success, or false on failure. |
|
2288 | + * @return boolean If atomic: True on success, or false on failure. |
|
2289 | 2289 | * Otherwise: array similar to the $data array passed, but values are set to true/false |
2290 | 2290 | * depending on whether each record validated successfully. |
2291 | 2291 | */ |
@@ -3207,7 +3207,7 @@ discard block |
||
3207 | 3207 | * |
3208 | 3208 | * @param array $results Results to filter |
3209 | 3209 | * @param boolean $primary If this is the primary model results (results from model where the find operation was performed) |
3210 | - * @return array Set of filtered results |
|
3210 | + * @return string Set of filtered results |
|
3211 | 3211 | */ |
3212 | 3212 | protected function _filterResults($results, $primary = true) { |
3213 | 3213 | $event = new CakeEvent('Model.afterFind', $this, array($results, $primary)); |
@@ -3294,10 +3294,6 @@ discard block |
||
3294 | 3294 | * Returns a resultset for a given SQL statement. Custom SQL queries should be performed with this method. |
3295 | 3295 | * |
3296 | 3296 | * @param string $sql SQL statement |
3297 | - * @param boolean|array $params Either a boolean to control query caching or an array of parameters |
|
3298 | - * for use with prepared statement placeholders. |
|
3299 | - * @param boolean $cache If $params is provided, a boolean flag for enabling/disabled |
|
3300 | - * query caching. |
|
3301 | 3297 | * @return mixed Resultset array or boolean indicating success / failure depending on the query executed |
3302 | 3298 | * @link http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query |
3303 | 3299 | */ |
@@ -3417,7 +3413,7 @@ discard block |
||
3417 | 3413 | /** |
3418 | 3414 | * Returns the ID of the last record this model inserted. |
3419 | 3415 | * |
3420 | - * @return mixed Last inserted ID |
|
3416 | + * @return integer Last inserted ID |
|
3421 | 3417 | */ |
3422 | 3418 | public function getLastInsertID() { |
3423 | 3419 | return $this->getInsertID(); |
@@ -3426,7 +3422,7 @@ discard block |
||
3426 | 3422 | /** |
3427 | 3423 | * Returns the ID of the last record this model inserted. |
3428 | 3424 | * |
3429 | - * @return mixed Last inserted ID |
|
3425 | + * @return integer Last inserted ID |
|
3430 | 3426 | */ |
3431 | 3427 | public function getInsertID() { |
3432 | 3428 | return $this->_insertID; |
@@ -3445,7 +3441,7 @@ discard block |
||
3445 | 3441 | /** |
3446 | 3442 | * Returns the number of rows returned from the last query. |
3447 | 3443 | * |
3448 | - * @return integer Number of rows |
|
3444 | + * @return boolean Number of rows |
|
3449 | 3445 | */ |
3450 | 3446 | public function getNumRows() { |
3451 | 3447 | return $this->getDataSource()->lastNumRows(); |
@@ -3454,7 +3450,7 @@ discard block |
||
3454 | 3450 | /** |
3455 | 3451 | * Returns the number of rows affected by the last query. |
3456 | 3452 | * |
3457 | - * @return integer Number of rows |
|
3453 | + * @return boolean Number of rows |
|
3458 | 3454 | */ |
3459 | 3455 | public function getAffectedRows() { |
3460 | 3456 | return $this->getDataSource()->lastAffected(); |
@@ -3591,7 +3587,7 @@ discard block |
||
3591 | 3587 | * call, otherwise return the (modified) query data. |
3592 | 3588 | * |
3593 | 3589 | * @param array $query Data used to execute this query, i.e. conditions, order, etc. |
3594 | - * @return mixed true if the operation should continue, false if it should abort; or, modified |
|
3590 | + * @return boolean true if the operation should continue, false if it should abort; or, modified |
|
3595 | 3591 | * $query to continue with new $query |
3596 | 3592 | * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforefind |
3597 | 3593 | */ |
@@ -3692,7 +3688,7 @@ discard block |
||
3692 | 3688 | * |
3693 | 3689 | * @param string $type If null this deletes cached views if Cache.check is true |
3694 | 3690 | * Will be used to allow deleting query cache also |
3695 | - * @return mixed True on delete, null otherwise |
|
3691 | + * @return null|boolean True on delete, null otherwise |
|
3696 | 3692 | */ |
3697 | 3693 | protected function _clearCache($type = null) { |
3698 | 3694 | if ($type !== null || Configure::read('Cache.check') !== true) { |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | $this->useTable = Inflector::tableize($this->name); |
731 | 731 | } |
732 | 732 | |
733 | - if (!$this->displayField) { |
|
733 | + if ( ! $this->displayField) { |
|
734 | 734 | unset($this->displayField); |
735 | 735 | } |
736 | 736 | $this->table = $this->useTable; |
@@ -836,20 +836,20 @@ discard block |
||
836 | 836 | |
837 | 837 | if ($className) { |
838 | 838 | $assocKey = $k; |
839 | - $dynamic = !empty($relation['dynamicWith']); |
|
839 | + $dynamic = ! empty($relation['dynamicWith']); |
|
840 | 840 | break(2); |
841 | 841 | } |
842 | 842 | } |
843 | 843 | } |
844 | 844 | } |
845 | 845 | |
846 | - if (!$className) { |
|
846 | + if ( ! $className) { |
|
847 | 847 | return false; |
848 | 848 | } |
849 | 849 | |
850 | 850 | list($plugin, $className) = pluginSplit($className); |
851 | 851 | |
852 | - if (!ClassRegistry::isKeySet($className) && !empty($dynamic)) { |
|
852 | + if ( ! ClassRegistry::isKeySet($className) && ! empty($dynamic)) { |
|
853 | 853 | $this->{$className} = new AppModel(array( |
854 | 854 | 'name' => $className, |
855 | 855 | 'table' => $this->hasAndBelongsToMany[$assocKey]['joinTable'], |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | $this->_constructLinkedModel($name, $className, $plugin); |
860 | 860 | } |
861 | 861 | |
862 | - if (!empty($assocKey)) { |
|
862 | + if ( ! empty($assocKey)) { |
|
863 | 863 | $this->hasAndBelongsToMany[$assocKey]['joinTable'] = $this->{$name}->table; |
864 | 864 | if (count($this->{$name}->schema()) <= 2 && $this->{$name}->primaryKey !== false) { |
865 | 865 | $this->{$name}->primaryKey = $this->hasAndBelongsToMany[$assocKey]['foreignKey']; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | |
883 | 883 | if ($name === 'tablePrefix') { |
884 | 884 | $this->setDataSource(); |
885 | - if (property_exists($this, 'tablePrefix') && !empty($this->tablePrefix)) { |
|
885 | + if (property_exists($this, 'tablePrefix') && ! empty($this->tablePrefix)) { |
|
886 | 886 | return $this->tablePrefix; |
887 | 887 | } |
888 | 888 | |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | */ |
916 | 916 | public function bindModel($params, $reset = true) { |
917 | 917 | foreach ($params as $assoc => $model) { |
918 | - if ($reset === true && !isset($this->__backAssociation[$assoc])) { |
|
918 | + if ($reset === true && ! isset($this->__backAssociation[$assoc])) { |
|
919 | 919 | $this->__backAssociation[$assoc] = $this->{$assoc}; |
920 | 920 | } |
921 | 921 | |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | */ |
964 | 964 | public function unbindModel($params, $reset = true) { |
965 | 965 | foreach ($params as $assoc => $models) { |
966 | - if ($reset === true && !isset($this->__backAssociation[$assoc])) { |
|
966 | + if ($reset === true && ! isset($this->__backAssociation[$assoc])) { |
|
967 | 967 | $this->__backAssociation[$assoc] = $this->{$assoc}; |
968 | 968 | } |
969 | 969 | |
@@ -986,9 +986,9 @@ discard block |
||
986 | 986 | */ |
987 | 987 | protected function _createLinks() { |
988 | 988 | foreach ($this->_associations as $type) { |
989 | - $association =& $this->{$type}; |
|
989 | + $association = & $this->{$type}; |
|
990 | 990 | |
991 | - if (!is_array($association)) { |
|
991 | + if ( ! is_array($association)) { |
|
992 | 992 | $association = explode(',', $association); |
993 | 993 | |
994 | 994 | foreach ($association as $i => $className) { |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | |
1001 | - if (!empty($association)) { |
|
1001 | + if ( ! empty($association)) { |
|
1002 | 1002 | foreach ($association as $assoc => $value) { |
1003 | 1003 | $plugin = null; |
1004 | 1004 | |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | |
1010 | 1010 | if (strpos($assoc, '.') !== false) { |
1011 | 1011 | list($plugin, $assoc) = pluginSplit($assoc, true); |
1012 | - $association[$assoc] = array('className' => $plugin . $assoc); |
|
1012 | + $association[$assoc] = array('className' => $plugin.$assoc); |
|
1013 | 1013 | } else { |
1014 | 1014 | $association[$assoc] = $value; |
1015 | 1015 | } |
@@ -1039,16 +1039,16 @@ discard block |
||
1039 | 1039 | $className = $assoc; |
1040 | 1040 | } |
1041 | 1041 | |
1042 | - if (!isset($this->{$assoc}) || $this->{$assoc}->name !== $className) { |
|
1042 | + if ( ! isset($this->{$assoc}) || $this->{$assoc}->name !== $className) { |
|
1043 | 1043 | if ($plugin) { |
1044 | 1044 | $plugin .= '.'; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - $model = array('class' => $plugin . $className, 'alias' => $assoc); |
|
1047 | + $model = array('class' => $plugin.$className, 'alias' => $assoc); |
|
1048 | 1048 | $this->{$assoc} = ClassRegistry::init($model); |
1049 | 1049 | |
1050 | 1050 | if ($plugin) { |
1051 | - ClassRegistry::addObject($plugin . $className, $this->{$assoc}); |
|
1051 | + ClassRegistry::addObject($plugin.$className, $this->{$assoc}); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | if ($assoc) { |
@@ -1067,10 +1067,10 @@ discard block |
||
1067 | 1067 | protected function _generateAssociation($type, $assocKey) { |
1068 | 1068 | $class = $assocKey; |
1069 | 1069 | $dynamicWith = false; |
1070 | - $assoc =& $this->{$type}[$assocKey]; |
|
1070 | + $assoc = & $this->{$type}[$assocKey]; |
|
1071 | 1071 | |
1072 | 1072 | foreach ($this->_associationKeys[$type] as $key) { |
1073 | - if (!isset($assoc[$key]) || $assoc[$key] === null) { |
|
1073 | + if ( ! isset($assoc[$key]) || $assoc[$key] === null) { |
|
1074 | 1074 | $data = ''; |
1075 | 1075 | |
1076 | 1076 | switch ($key) { |
@@ -1079,11 +1079,11 @@ discard block |
||
1079 | 1079 | break; |
1080 | 1080 | |
1081 | 1081 | case 'foreignKey': |
1082 | - $data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id'; |
|
1082 | + $data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)).'_id'; |
|
1083 | 1083 | break; |
1084 | 1084 | |
1085 | 1085 | case 'associationForeignKey': |
1086 | - $data = Inflector::singularize($this->{$class}->table) . '_id'; |
|
1086 | + $data = Inflector::singularize($this->{$class}->table).'_id'; |
|
1087 | 1087 | break; |
1088 | 1088 | |
1089 | 1089 | case 'with': |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | case 'joinTable': |
1095 | 1095 | $tables = array($this->table, $this->{$class}->table); |
1096 | 1096 | sort($tables); |
1097 | - $data = $tables[0] . '_' . $tables[1]; |
|
1097 | + $data = $tables[0].'_'.$tables[1]; |
|
1098 | 1098 | break; |
1099 | 1099 | |
1100 | 1100 | case 'className': |
@@ -1132,9 +1132,9 @@ discard block |
||
1132 | 1132 | $sources = $db->listSources(); |
1133 | 1133 | $db->cacheSources = $restore; |
1134 | 1134 | |
1135 | - if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) { |
|
1135 | + if (is_array($sources) && ! in_array(strtolower($this->tablePrefix.$tableName), array_map('strtolower', $sources))) { |
|
1136 | 1136 | throw new MissingTableException(array( |
1137 | - 'table' => $this->tablePrefix . $tableName, |
|
1137 | + 'table' => $this->tablePrefix.$tableName, |
|
1138 | 1138 | 'class' => $this->alias, |
1139 | 1139 | 'ds' => $this->useDbConfig, |
1140 | 1140 | )); |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html |
1166 | 1166 | */ |
1167 | 1167 | public function set($one, $two = null) { |
1168 | - if (!$one) { |
|
1168 | + if ( ! $one) { |
|
1169 | 1169 | return; |
1170 | 1170 | } |
1171 | 1171 | |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | foreach ($data as $modelName => $fieldSet) { |
1190 | - if (!is_array($fieldSet)) { |
|
1190 | + if ( ! is_array($fieldSet)) { |
|
1191 | 1191 | continue; |
1192 | 1192 | } |
1193 | 1193 | |
@@ -1217,10 +1217,10 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | protected function _setAliasData($data) { |
1219 | 1219 | $models = array_keys($this->getAssociated()); |
1220 | - $schema = array_keys((array)$this->schema()); |
|
1220 | + $schema = array_keys((array) $this->schema()); |
|
1221 | 1221 | |
1222 | 1222 | foreach ($data as $field => $value) { |
1223 | - if (in_array($field, $schema) || !in_array($field, $models)) { |
|
1223 | + if (in_array($field, $schema) || ! in_array($field, $models)) { |
|
1224 | 1224 | $data[$this->alias][$field] = $value; |
1225 | 1225 | unset($data[$field]); |
1226 | 1226 | } |
@@ -1258,13 +1258,13 @@ discard block |
||
1258 | 1258 | * @return mixed The resulting data that should be assigned to a field |
1259 | 1259 | */ |
1260 | 1260 | public function deconstruct($field, $data) { |
1261 | - if (!is_array($data)) { |
|
1261 | + if ( ! is_array($data)) { |
|
1262 | 1262 | return $data; |
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | $type = $this->getColumnType($field); |
1266 | 1266 | |
1267 | - if (!in_array($type, array('datetime', 'timestamp', 'date', 'time'))) { |
|
1267 | + if ( ! in_array($type, array('datetime', 'timestamp', 'date', 'time'))) { |
|
1268 | 1268 | return $data; |
1269 | 1269 | } |
1270 | 1270 | |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | if ( |
1283 | 1283 | isset($data['hour']) && |
1284 | 1284 | isset($data['meridian']) && |
1285 | - !empty($data['hour']) && |
|
1285 | + ! empty($data['hour']) && |
|
1286 | 1286 | $data['hour'] != 12 && |
1287 | 1287 | $data['meridian'] === 'pm' |
1288 | 1288 | ) { |
@@ -1295,13 +1295,13 @@ discard block |
||
1295 | 1295 | |
1296 | 1296 | if ($type === 'time') { |
1297 | 1297 | foreach ($timeFields as $key => $val) { |
1298 | - if (!isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') { |
|
1298 | + if ( ! isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') { |
|
1299 | 1299 | $data[$val] = '00'; |
1300 | 1300 | } elseif ($data[$val] !== '') { |
1301 | 1301 | $data[$val] = sprintf('%02d', $data[$val]); |
1302 | 1302 | } |
1303 | 1303 | |
1304 | - if (!empty($data[$val])) { |
|
1304 | + if ( ! empty($data[$val])) { |
|
1305 | 1305 | $date[$key] = $data[$val]; |
1306 | 1306 | } else { |
1307 | 1307 | return null; |
@@ -1312,24 +1312,24 @@ discard block |
||
1312 | 1312 | if ($type === 'datetime' || $type === 'timestamp' || $type === 'date') { |
1313 | 1313 | foreach ($dateFields as $key => $val) { |
1314 | 1314 | if ($val === 'hour' || $val === 'min' || $val === 'sec') { |
1315 | - if (!isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') { |
|
1315 | + if ( ! isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') { |
|
1316 | 1316 | $data[$val] = '00'; |
1317 | 1317 | } else { |
1318 | 1318 | $data[$val] = sprintf('%02d', $data[$val]); |
1319 | 1319 | } |
1320 | 1320 | } |
1321 | 1321 | |
1322 | - if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || $data[$val][0] === '-')) { |
|
1322 | + if ( ! isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || $data[$val][0] === '-')) { |
|
1323 | 1323 | return null; |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - if (isset($data[$val]) && !empty($data[$val])) { |
|
1326 | + if (isset($data[$val]) && ! empty($data[$val])) { |
|
1327 | 1327 | $date[$key] = $data[$val]; |
1328 | 1328 | } |
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | |
1332 | - if ($useNewDate && !empty($date)) { |
|
1332 | + if ($useNewDate && ! empty($date)) { |
|
1333 | 1333 | $format = $this->getDataSource()->columns[$type]['format']; |
1334 | 1334 | foreach (array('m', 'd', 'H', 'i', 's') as $index) { |
1335 | 1335 | if (isset($date[$index])) { |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | * @return array Array of table metadata |
1352 | 1352 | */ |
1353 | 1353 | public function schema($field = false) { |
1354 | - if ($this->useTable !== false && (!is_array($this->_schema) || $field === true)) { |
|
1354 | + if ($this->useTable !== false && ( ! is_array($this->_schema) || $field === true)) { |
|
1355 | 1355 | $db = $this->getDataSource(); |
1356 | 1356 | $db->cacheSources = ($this->cacheSources && $db->cacheSources); |
1357 | 1357 | if (method_exists($db, 'describe')) { |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | } |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if (!is_string($field)) { |
|
1362 | + if ( ! is_string($field)) { |
|
1363 | 1363 | return $this->_schema; |
1364 | 1364 | } |
1365 | 1365 | |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | return false; |
1440 | 1440 | } |
1441 | 1441 | |
1442 | - if ($checkVirtual && !empty($this->virtualFields) && $this->isVirtualField($name)) { |
|
1442 | + if ($checkVirtual && ! empty($this->virtualFields) && $this->isVirtualField($name)) { |
|
1443 | 1443 | return true; |
1444 | 1444 | } |
1445 | 1445 | |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | * @return boolean indicating whether the field exists as a model virtual field. |
1477 | 1477 | */ |
1478 | 1478 | public function isVirtualField($field) { |
1479 | - if (empty($this->virtualFields) || !is_string($field)) { |
|
1479 | + if (empty($this->virtualFields) || ! is_string($field)) { |
|
1480 | 1480 | return false; |
1481 | 1481 | } |
1482 | 1482 | |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | * or false if none $field exist. |
1504 | 1504 | */ |
1505 | 1505 | public function getVirtualField($field = null) { |
1506 | - if (!$field) { |
|
1506 | + if ( ! $field) { |
|
1507 | 1507 | return empty($this->virtualFields) ? false : $this->virtualFields; |
1508 | 1508 | } |
1509 | 1509 | |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | $this->validationErrors = array(); |
1537 | 1537 | |
1538 | 1538 | if ($data !== null && $data !== false) { |
1539 | - $schema = (array)$this->schema(); |
|
1539 | + $schema = (array) $this->schema(); |
|
1540 | 1540 | foreach ($schema as $field => $properties) { |
1541 | 1541 | if ($this->primaryKey !== $field && isset($properties['default']) && $properties['default'] !== '') { |
1542 | 1542 | $defaults[$field] = $properties['default']; |
@@ -1589,7 +1589,7 @@ discard block |
||
1589 | 1589 | |
1590 | 1590 | if ($id !== null && $id !== false) { |
1591 | 1591 | $this->data = $this->find('first', array( |
1592 | - 'conditions' => array($this->alias . '.' . $this->primaryKey => $id), |
|
1592 | + 'conditions' => array($this->alias.'.'.$this->primaryKey => $id), |
|
1593 | 1593 | 'fields' => $fields |
1594 | 1594 | )); |
1595 | 1595 | |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | */ |
1612 | 1612 | public function field($name, $conditions = null, $order = null) { |
1613 | 1613 | if ($conditions === null && $this->id !== false) { |
1614 | - $conditions = array($this->alias . '.' . $this->primaryKey => $this->id); |
|
1614 | + $conditions = array($this->alias.'.'.$this->primaryKey => $this->id); |
|
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | $recursive = $this->recursive; |
@@ -1621,7 +1621,7 @@ discard block |
||
1621 | 1621 | |
1622 | 1622 | $fields = $name; |
1623 | 1623 | $data = $this->find('first', compact('conditions', 'fields', 'order', 'recursive')); |
1624 | - if (!$data) { |
|
1624 | + if ( ! $data) { |
|
1625 | 1625 | return false; |
1626 | 1626 | } |
1627 | 1627 | |
@@ -1694,14 +1694,14 @@ discard block |
||
1694 | 1694 | $_whitelist = $this->whitelist; |
1695 | 1695 | $fields = array(); |
1696 | 1696 | |
1697 | - if (!is_array($validate)) { |
|
1697 | + if ( ! is_array($validate)) { |
|
1698 | 1698 | $options = array_merge($defaults, compact('validate', 'fieldList')); |
1699 | 1699 | } else { |
1700 | 1700 | $options = array_merge($defaults, $validate); |
1701 | 1701 | } |
1702 | 1702 | |
1703 | - if (!empty($options['fieldList'])) { |
|
1704 | - if (!empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) { |
|
1703 | + if ( ! empty($options['fieldList'])) { |
|
1704 | + if ( ! empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) { |
|
1705 | 1705 | $this->whitelist = $options['fieldList'][$this->alias]; |
1706 | 1706 | } elseif (Hash::dimensions($options['fieldList']) < 2) { |
1707 | 1707 | $this->whitelist = $options['fieldList']; |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | |
1713 | 1713 | $this->set($data); |
1714 | 1714 | |
1715 | - if (empty($this->data) && !$this->hasField(array('created', 'updated', 'modified'))) { |
|
1715 | + if (empty($this->data) && ! $this->hasField(array('created', 'updated', 'modified'))) { |
|
1716 | 1716 | $this->whitelist = $_whitelist; |
1717 | 1717 | return false; |
1718 | 1718 | } |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | $exists = $this->exists(); |
1733 | 1733 | $dateFields = array('modified', 'updated'); |
1734 | 1734 | |
1735 | - if (!$exists) { |
|
1735 | + if ( ! $exists) { |
|
1736 | 1736 | $dateFields[] = 'created'; |
1737 | 1737 | } |
1738 | 1738 | |
@@ -1740,7 +1740,7 @@ discard block |
||
1740 | 1740 | $fields = array_keys($this->data[$this->alias]); |
1741 | 1741 | } |
1742 | 1742 | |
1743 | - if ($options['validate'] && !$this->validates($options)) { |
|
1743 | + if ($options['validate'] && ! $this->validates($options)) { |
|
1744 | 1744 | $this->whitelist = $_whitelist; |
1745 | 1745 | return false; |
1746 | 1746 | } |
@@ -1749,7 +1749,7 @@ discard block |
||
1749 | 1749 | $now = time(); |
1750 | 1750 | |
1751 | 1751 | foreach ($dateFields as $updateCol) { |
1752 | - if (in_array($updateCol, $fields) || !$this->hasField($updateCol)) { |
|
1752 | + if (in_array($updateCol, $fields) || ! $this->hasField($updateCol)) { |
|
1753 | 1753 | continue; |
1754 | 1754 | } |
1755 | 1755 | |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | $time = call_user_func($colType['formatter'], $colType['format']); |
1762 | 1762 | } |
1763 | 1763 | |
1764 | - if (!empty($this->whitelist)) { |
|
1764 | + if ( ! empty($this->whitelist)) { |
|
1765 | 1765 | $this->whitelist[] = $updateCol; |
1766 | 1766 | } |
1767 | 1767 | $this->set($updateCol, $time); |
@@ -1771,7 +1771,7 @@ discard block |
||
1771 | 1771 | $event = new CakeEvent('Model.beforeSave', $this, array($options)); |
1772 | 1772 | list($event->break, $event->breakOn) = array(true, array(false, null)); |
1773 | 1773 | $this->getEventManager()->dispatch($event); |
1774 | - if (!$event->result) { |
|
1774 | + if ( ! $event->result) { |
|
1775 | 1775 | $this->whitelist = $_whitelist; |
1776 | 1776 | return false; |
1777 | 1777 | } |
@@ -1807,7 +1807,7 @@ discard block |
||
1807 | 1807 | |
1808 | 1808 | $count = count($fields); |
1809 | 1809 | |
1810 | - if (!$exists && $count > 0) { |
|
1810 | + if ( ! $exists && $count > 0) { |
|
1811 | 1811 | $this->id = false; |
1812 | 1812 | } |
1813 | 1813 | |
@@ -1817,8 +1817,8 @@ discard block |
||
1817 | 1817 | if ($count > 0) { |
1818 | 1818 | $cache = $this->_prepareUpdateFields(array_combine($fields, $values)); |
1819 | 1819 | |
1820 | - if (!empty($this->id)) { |
|
1821 | - $success = (bool)$db->update($this, $fields, $values); |
|
1820 | + if ( ! empty($this->id)) { |
|
1821 | + $success = (bool) $db->update($this, $fields, $values); |
|
1822 | 1822 | } else { |
1823 | 1823 | if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_isUUIDField($this->primaryKey)) { |
1824 | 1824 | if (array_key_exists($this->primaryKey, $this->data[$this->alias])) { |
@@ -1829,19 +1829,19 @@ discard block |
||
1829 | 1829 | } |
1830 | 1830 | } |
1831 | 1831 | |
1832 | - if (!$db->create($this, $fields, $values)) { |
|
1832 | + if ( ! $db->create($this, $fields, $values)) { |
|
1833 | 1833 | $success = false; |
1834 | 1834 | } else { |
1835 | 1835 | $created = true; |
1836 | 1836 | } |
1837 | 1837 | } |
1838 | 1838 | |
1839 | - if ($success && $options['counterCache'] && !empty($this->belongsTo)) { |
|
1839 | + if ($success && $options['counterCache'] && ! empty($this->belongsTo)) { |
|
1840 | 1840 | $this->updateCounterCache($cache, $created); |
1841 | 1841 | } |
1842 | 1842 | } |
1843 | 1843 | |
1844 | - if (!empty($joined) && $success === true) { |
|
1844 | + if ( ! empty($joined) && $success === true) { |
|
1845 | 1845 | $this->_saveMulti($joined, $this->id, $db); |
1846 | 1846 | } |
1847 | 1847 | |
@@ -1850,7 +1850,7 @@ discard block |
||
1850 | 1850 | } |
1851 | 1851 | |
1852 | 1852 | if ($success && $count > 0) { |
1853 | - if (!empty($this->data)) { |
|
1853 | + if ( ! empty($this->data)) { |
|
1854 | 1854 | if ($created) { |
1855 | 1855 | $this->data[$this->alias][$this->primaryKey] = $this->id; |
1856 | 1856 | } |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | $this->getEventManager()->dispatch($event); |
1862 | 1862 | } |
1863 | 1863 | |
1864 | - if (!empty($this->data)) { |
|
1864 | + if ( ! empty($this->data)) { |
|
1865 | 1865 | $success = $this->data; |
1866 | 1866 | } |
1867 | 1867 | |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | */ |
1896 | 1896 | protected function _saveMulti($joined, $id, $db) { |
1897 | 1897 | foreach ($joined as $assoc => $data) { |
1898 | - if (!isset($this->hasAndBelongsToMany[$assoc])) { |
|
1898 | + if ( ! isset($this->hasAndBelongsToMany[$assoc])) { |
|
1899 | 1899 | continue; |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1905,7 +1905,7 @@ discard block |
||
1905 | 1905 | |
1906 | 1906 | $Model = $this->{$join}; |
1907 | 1907 | |
1908 | - if (!empty($habtm['with'])) { |
|
1908 | + if ( ! empty($habtm['with'])) { |
|
1909 | 1909 | $withModel = is_array($habtm['with']) ? key($habtm['with']) : $habtm['with']; |
1910 | 1910 | list(, $withModel) = pluginSplit($withModel); |
1911 | 1911 | $dbMulti = $this->{$withModel}->getDataSource(); |
@@ -1913,7 +1913,7 @@ discard block |
||
1913 | 1913 | $dbMulti = $db; |
1914 | 1914 | } |
1915 | 1915 | |
1916 | - $isUUID = !empty($Model->primaryKey) && $Model->_isUUIDField($Model->primaryKey); |
|
1916 | + $isUUID = ! empty($Model->primaryKey) && $Model->_isUUIDField($Model->primaryKey); |
|
1917 | 1917 | |
1918 | 1918 | $newData = $newValues = $newJoins = array(); |
1919 | 1919 | $primaryAdded = false; |
@@ -1924,12 +1924,12 @@ discard block |
||
1924 | 1924 | ); |
1925 | 1925 | |
1926 | 1926 | $idField = $db->name($Model->primaryKey); |
1927 | - if ($isUUID && !in_array($idField, $fields)) { |
|
1927 | + if ($isUUID && ! in_array($idField, $fields)) { |
|
1928 | 1928 | $fields[] = $idField; |
1929 | 1929 | $primaryAdded = true; |
1930 | 1930 | } |
1931 | 1931 | |
1932 | - foreach ((array)$data as $row) { |
|
1932 | + foreach ((array) $data as $row) { |
|
1933 | 1933 | if ((is_string($row) && (strlen($row) === 36 || strlen($row) === 16)) || is_numeric($row)) { |
1934 | 1934 | $newJoins[] = $row; |
1935 | 1935 | $values = array($id, $row); |
@@ -1941,13 +1941,13 @@ discard block |
||
1941 | 1941 | $newValues[$row] = $values; |
1942 | 1942 | unset($values); |
1943 | 1943 | } elseif (isset($row[$habtm['associationForeignKey']])) { |
1944 | - if (!empty($row[$Model->primaryKey])) { |
|
1944 | + if ( ! empty($row[$Model->primaryKey])) { |
|
1945 | 1945 | $newJoins[] = $row[$habtm['associationForeignKey']]; |
1946 | 1946 | } |
1947 | 1947 | |
1948 | 1948 | $newData[] = $row; |
1949 | 1949 | } elseif (isset($row[$join]) && isset($row[$join][$habtm['associationForeignKey']])) { |
1950 | - if (!empty($row[$join][$Model->primaryKey])) { |
|
1950 | + if ( ! empty($row[$join][$Model->primaryKey])) { |
|
1951 | 1951 | $newJoins[] = $row[$join][$habtm['associationForeignKey']]; |
1952 | 1952 | } |
1953 | 1953 | |
@@ -1958,14 +1958,14 @@ discard block |
||
1958 | 1958 | $keepExisting = $habtm['unique'] === 'keepExisting'; |
1959 | 1959 | if ($habtm['unique']) { |
1960 | 1960 | $conditions = array( |
1961 | - $join . '.' . $habtm['foreignKey'] => $id |
|
1961 | + $join.'.'.$habtm['foreignKey'] => $id |
|
1962 | 1962 | ); |
1963 | 1963 | |
1964 | - if (!empty($habtm['conditions'])) { |
|
1965 | - $conditions = array_merge($conditions, (array)$habtm['conditions']); |
|
1964 | + if ( ! empty($habtm['conditions'])) { |
|
1965 | + $conditions = array_merge($conditions, (array) $habtm['conditions']); |
|
1966 | 1966 | } |
1967 | 1967 | |
1968 | - $associationForeignKey = $Model->alias . '.' . $habtm['associationForeignKey']; |
|
1968 | + $associationForeignKey = $Model->alias.'.'.$habtm['associationForeignKey']; |
|
1969 | 1969 | $links = $Model->find('all', array( |
1970 | 1970 | 'conditions' => $conditions, |
1971 | 1971 | 'recursive' => empty($habtm['conditions']) ? -1 : 0, |
@@ -1973,8 +1973,8 @@ discard block |
||
1973 | 1973 | )); |
1974 | 1974 | |
1975 | 1975 | $oldLinks = Hash::extract($links, "{n}.{$associationForeignKey}"); |
1976 | - if (!empty($oldLinks)) { |
|
1977 | - if ($keepExisting && !empty($newJoins)) { |
|
1976 | + if ( ! empty($oldLinks)) { |
|
1977 | + if ($keepExisting && ! empty($newJoins)) { |
|
1978 | 1978 | $conditions[$associationForeignKey] = array_diff($oldLinks, $newJoins); |
1979 | 1979 | } else { |
1980 | 1980 | $conditions[$associationForeignKey] = $oldLinks; |
@@ -1984,7 +1984,7 @@ discard block |
||
1984 | 1984 | } |
1985 | 1985 | } |
1986 | 1986 | |
1987 | - if (!empty($newData)) { |
|
1987 | + if ( ! empty($newData)) { |
|
1988 | 1988 | foreach ($newData as $data) { |
1989 | 1989 | $data[$habtm['foreignKey']] = $id; |
1990 | 1990 | if (empty($data[$Model->primaryKey])) { |
@@ -1995,11 +1995,11 @@ discard block |
||
1995 | 1995 | } |
1996 | 1996 | } |
1997 | 1997 | |
1998 | - if (!empty($newValues)) { |
|
1999 | - if ($keepExisting && !empty($links)) { |
|
1998 | + if ( ! empty($newValues)) { |
|
1999 | + if ($keepExisting && ! empty($links)) { |
|
2000 | 2000 | foreach ($links as $link) { |
2001 | 2001 | $oldJoin = $link[$join][$habtm['associationForeignKey']]; |
2002 | - if (!in_array($oldJoin, $newJoins)) { |
|
2002 | + if ( ! in_array($oldJoin, $newJoins)) { |
|
2003 | 2003 | $conditions[$associationForeignKey] = $oldJoin; |
2004 | 2004 | $db->delete($Model, $conditions); |
2005 | 2005 | } else { |
@@ -2010,7 +2010,7 @@ discard block |
||
2010 | 2010 | $newValues = array_values($newValues); |
2011 | 2011 | } |
2012 | 2012 | |
2013 | - if (!empty($newValues)) { |
|
2013 | + if ( ! empty($newValues)) { |
|
2014 | 2014 | $dbMulti->insertMulti($Model, $fields, $newValues); |
2015 | 2015 | } |
2016 | 2016 | } |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | |
2039 | 2039 | $Model = $this->{$parent}; |
2040 | 2040 | |
2041 | - if (!is_array($assoc['counterCache'])) { |
|
2041 | + if ( ! is_array($assoc['counterCache'])) { |
|
2042 | 2042 | if (isset($assoc['counterScope'])) { |
2043 | 2043 | $assoc['counterCache'] = array($assoc['counterCache'] => $assoc['counterScope']); |
2044 | 2044 | } else { |
@@ -2050,21 +2050,21 @@ discard block |
||
2050 | 2050 | $fkQuoted = $this->escapeField($assoc['foreignKey']); |
2051 | 2051 | |
2052 | 2052 | foreach ($assoc['counterCache'] as $field => $conditions) { |
2053 | - if (!is_string($field)) { |
|
2054 | - $field = Inflector::underscore($this->alias) . '_count'; |
|
2053 | + if ( ! is_string($field)) { |
|
2054 | + $field = Inflector::underscore($this->alias).'_count'; |
|
2055 | 2055 | } |
2056 | 2056 | |
2057 | - if (!$Model->hasField($field)) { |
|
2057 | + if ( ! $Model->hasField($field)) { |
|
2058 | 2058 | continue; |
2059 | 2059 | } |
2060 | 2060 | |
2061 | 2061 | if ($conditions === true) { |
2062 | 2062 | $conditions = array(); |
2063 | 2063 | } else { |
2064 | - $conditions = (array)$conditions; |
|
2064 | + $conditions = (array) $conditions; |
|
2065 | 2065 | } |
2066 | 2066 | |
2067 | - if (!array_key_exists($foreignKey, $keys)) { |
|
2067 | + if ( ! array_key_exists($foreignKey, $keys)) { |
|
2068 | 2068 | $keys[$foreignKey] = $this->field($foreignKey); |
2069 | 2069 | } |
2070 | 2070 | |
@@ -2083,7 +2083,7 @@ discard block |
||
2083 | 2083 | $conditions[$fkQuoted] = $keys[$foreignKey]; |
2084 | 2084 | |
2085 | 2085 | if ($recursive === 0) { |
2086 | - $conditions = array_merge($conditions, (array)$conditions); |
|
2086 | + $conditions = array_merge($conditions, (array) $conditions); |
|
2087 | 2087 | } |
2088 | 2088 | |
2089 | 2089 | $count = intval($this->find('count', compact('conditions', 'recursive'))); |
@@ -2118,7 +2118,7 @@ discard block |
||
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | $old = $this->find('first', array( |
2121 | - 'conditions' => array($this->alias . '.' . $this->primaryKey => $this->id), |
|
2121 | + 'conditions' => array($this->alias.'.'.$this->primaryKey => $this->id), |
|
2122 | 2122 | 'fields' => array_values($included), |
2123 | 2123 | 'recursive' => -1 |
2124 | 2124 | )); |
@@ -2209,16 +2209,16 @@ discard block |
||
2209 | 2209 | |
2210 | 2210 | if (empty($data) && $options['validate'] !== false) { |
2211 | 2211 | $result = $this->save($data, $options); |
2212 | - if (!$options['atomic']) { |
|
2213 | - return array(!empty($result)); |
|
2212 | + if ( ! $options['atomic']) { |
|
2213 | + return array( ! empty($result)); |
|
2214 | 2214 | } |
2215 | 2215 | |
2216 | - return !empty($result); |
|
2216 | + return ! empty($result); |
|
2217 | 2217 | } |
2218 | 2218 | |
2219 | 2219 | if ($options['validate'] === 'first') { |
2220 | 2220 | $validates = $this->validateMany($data, $options); |
2221 | - if ((!$validates && $options['atomic']) || (!$options['atomic'] && in_array(false, $validates, true))) { |
|
2221 | + if (( ! $validates && $options['atomic']) || ( ! $options['atomic'] && in_array(false, $validates, true))) { |
|
2222 | 2222 | return $validates; |
2223 | 2223 | } |
2224 | 2224 | $options['validate'] = false; |
@@ -2241,21 +2241,21 @@ discard block |
||
2241 | 2241 | } |
2242 | 2242 | } |
2243 | 2243 | |
2244 | - $validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, $saved, true)))); |
|
2245 | - if (!$validates) { |
|
2244 | + $validates = ($validates && ($saved === true || (is_array($saved) && ! in_array(false, $saved, true)))); |
|
2245 | + if ( ! $validates) { |
|
2246 | 2246 | $validationErrors[$key] = $this->validationErrors; |
2247 | 2247 | } |
2248 | 2248 | |
2249 | - if (!$options['atomic']) { |
|
2249 | + if ( ! $options['atomic']) { |
|
2250 | 2250 | $return[$key] = $validates; |
2251 | - } elseif (!$validates) { |
|
2251 | + } elseif ( ! $validates) { |
|
2252 | 2252 | break; |
2253 | 2253 | } |
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | $this->validationErrors = $validationErrors; |
2257 | 2257 | |
2258 | - if (!$options['atomic']) { |
|
2258 | + if ( ! $options['atomic']) { |
|
2259 | 2259 | return $return; |
2260 | 2260 | } |
2261 | 2261 | |
@@ -2331,16 +2331,16 @@ discard block |
||
2331 | 2331 | |
2332 | 2332 | if (empty($data) && $options['validate'] !== false) { |
2333 | 2333 | $result = $this->save($data, $options); |
2334 | - if (!$options['atomic']) { |
|
2335 | - return array(!empty($result)); |
|
2334 | + if ( ! $options['atomic']) { |
|
2335 | + return array( ! empty($result)); |
|
2336 | 2336 | } |
2337 | 2337 | |
2338 | - return !empty($result); |
|
2338 | + return ! empty($result); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | if ($options['validate'] === 'first') { |
2342 | 2342 | $validates = $this->validateAssociated($data, $options); |
2343 | - if ((!$validates && $options['atomic']) || (!$options['atomic'] && in_array(false, Hash::flatten($validates), true))) { |
|
2343 | + if (( ! $validates && $options['atomic']) || ( ! $options['atomic'] && in_array(false, Hash::flatten($validates), true))) { |
|
2344 | 2344 | return $validates; |
2345 | 2345 | } |
2346 | 2346 | |
@@ -2357,7 +2357,7 @@ discard block |
||
2357 | 2357 | $validates = true; |
2358 | 2358 | foreach ($data as $association => $values) { |
2359 | 2359 | $isEmpty = empty($values) || (isset($values[$association]) && empty($values[$association])); |
2360 | - if ($isEmpty || !isset($associations[$association]) || $associations[$association] !== 'belongsTo') { |
|
2360 | + if ($isEmpty || ! isset($associations[$association]) || $associations[$association] !== 'belongsTo') { |
|
2361 | 2361 | continue; |
2362 | 2362 | } |
2363 | 2363 | |
@@ -2371,7 +2371,7 @@ discard block |
||
2371 | 2371 | } else { |
2372 | 2372 | $saved = $Model->save($values, array_merge($options, array('atomic' => false))); |
2373 | 2373 | } |
2374 | - $validates = ($saved === true || (is_array($saved) && !in_array(false, $saved, true))); |
|
2374 | + $validates = ($saved === true || (is_array($saved) && ! in_array(false, $saved, true))); |
|
2375 | 2375 | } |
2376 | 2376 | |
2377 | 2377 | if ($validates) { |
@@ -2389,19 +2389,19 @@ discard block |
||
2389 | 2389 | $return[$association] = $validates; |
2390 | 2390 | } |
2391 | 2391 | |
2392 | - if ($validates && !($this->create(null) !== null && $this->save($data, $options))) { |
|
2392 | + if ($validates && ! ($this->create(null) !== null && $this->save($data, $options))) { |
|
2393 | 2393 | $validationErrors[$this->alias] = $this->validationErrors; |
2394 | 2394 | $validates = false; |
2395 | 2395 | } |
2396 | 2396 | $return[$this->alias] = $validates; |
2397 | 2397 | |
2398 | 2398 | foreach ($data as $association => $values) { |
2399 | - if (!$validates) { |
|
2399 | + if ( ! $validates) { |
|
2400 | 2400 | break; |
2401 | 2401 | } |
2402 | 2402 | |
2403 | 2403 | $isEmpty = empty($values) || (isset($values[$association]) && empty($values[$association])); |
2404 | - if ($isEmpty || !isset($associations[$association])) { |
|
2404 | + if ($isEmpty || ! isset($associations[$association])) { |
|
2405 | 2405 | continue; |
2406 | 2406 | } |
2407 | 2407 | |
@@ -2429,8 +2429,8 @@ discard block |
||
2429 | 2429 | } |
2430 | 2430 | } |
2431 | 2431 | |
2432 | - $validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, $saved, true)))); |
|
2433 | - if (!$validates) { |
|
2432 | + $validates = ($validates && ($saved === true || (is_array($saved) && ! in_array(false, $saved, true)))); |
|
2433 | + if ( ! $validates) { |
|
2434 | 2434 | $validationErrors[$association] = $Model->validationErrors; |
2435 | 2435 | } |
2436 | 2436 | |
@@ -2464,7 +2464,7 @@ discard block |
||
2464 | 2464 | $this->validationErrors = array_merge($this->validationErrors, $validationErrors); |
2465 | 2465 | } |
2466 | 2466 | |
2467 | - if (!$options['atomic']) { |
|
2467 | + if ( ! $options['atomic']) { |
|
2468 | 2468 | return $return; |
2469 | 2469 | } |
2470 | 2470 | if ($validates) { |
@@ -2487,18 +2487,18 @@ discard block |
||
2487 | 2487 | * @return array $options |
2488 | 2488 | */ |
2489 | 2489 | protected function _addToWhiteList($key, $options) { |
2490 | - if (empty($options['fieldList']) && $this->whitelist && !in_array($key, $this->whitelist)) { |
|
2490 | + if (empty($options['fieldList']) && $this->whitelist && ! in_array($key, $this->whitelist)) { |
|
2491 | 2491 | $options['fieldList'][$this->alias] = $this->whitelist; |
2492 | 2492 | $options['fieldList'][$this->alias][] = $key; |
2493 | 2493 | return $options; |
2494 | 2494 | } |
2495 | 2495 | |
2496 | - if (!empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) { |
|
2496 | + if ( ! empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) { |
|
2497 | 2497 | $options['fieldList'][$this->alias][] = $key; |
2498 | 2498 | return $options; |
2499 | 2499 | } |
2500 | 2500 | |
2501 | - if (!empty($options['fieldList']) && is_array($options['fieldList']) && Hash::dimensions($options['fieldList']) < 2) { |
|
2501 | + if ( ! empty($options['fieldList']) && is_array($options['fieldList']) && Hash::dimensions($options['fieldList']) < 2) { |
|
2502 | 2502 | $options['fieldList'][] = $key; |
2503 | 2503 | } |
2504 | 2504 | |
@@ -2550,7 +2550,7 @@ discard block |
||
2550 | 2550 | * @link http://book.cakephp.org/2.0/en/models/deleting-data.html |
2551 | 2551 | */ |
2552 | 2552 | public function delete($id = null, $cascade = true) { |
2553 | - if (!empty($id)) { |
|
2553 | + if ( ! empty($id)) { |
|
2554 | 2554 | $this->id = $id; |
2555 | 2555 | } |
2556 | 2556 | |
@@ -2563,7 +2563,7 @@ discard block |
||
2563 | 2563 | return false; |
2564 | 2564 | } |
2565 | 2565 | |
2566 | - if (!$this->exists()) { |
|
2566 | + if ( ! $this->exists()) { |
|
2567 | 2567 | return false; |
2568 | 2568 | } |
2569 | 2569 | |
@@ -2571,7 +2571,7 @@ discard block |
||
2571 | 2571 | $this->_deleteLinks($id); |
2572 | 2572 | $this->id = $id; |
2573 | 2573 | |
2574 | - if (!empty($this->belongsTo)) { |
|
2574 | + if ( ! empty($this->belongsTo)) { |
|
2575 | 2575 | foreach ($this->belongsTo as $assoc) { |
2576 | 2576 | if (empty($assoc['counterCache'])) { |
2577 | 2577 | continue; |
@@ -2579,7 +2579,7 @@ discard block |
||
2579 | 2579 | |
2580 | 2580 | $keys = $this->find('first', array( |
2581 | 2581 | 'fields' => $this->_collectForeignKeys(), |
2582 | - 'conditions' => array($this->alias . '.' . $this->primaryKey => $id), |
|
2582 | + 'conditions' => array($this->alias.'.'.$this->primaryKey => $id), |
|
2583 | 2583 | 'recursive' => -1, |
2584 | 2584 | 'callbacks' => false |
2585 | 2585 | )); |
@@ -2587,11 +2587,11 @@ discard block |
||
2587 | 2587 | } |
2588 | 2588 | } |
2589 | 2589 | |
2590 | - if (!$this->getDataSource()->delete($this, array($this->alias . '.' . $this->primaryKey => $id))) { |
|
2590 | + if ( ! $this->getDataSource()->delete($this, array($this->alias.'.'.$this->primaryKey => $id))) { |
|
2591 | 2591 | return false; |
2592 | 2592 | } |
2593 | 2593 | |
2594 | - if (!empty($keys[$this->alias])) { |
|
2594 | + if ( ! empty($keys[$this->alias])) { |
|
2595 | 2595 | $this->updateCounterCache($keys[$this->alias]); |
2596 | 2596 | } |
2597 | 2597 | |
@@ -2614,7 +2614,7 @@ discard block |
||
2614 | 2614 | return; |
2615 | 2615 | } |
2616 | 2616 | |
2617 | - if (!empty($this->__backAssociation)) { |
|
2617 | + if ( ! empty($this->__backAssociation)) { |
|
2618 | 2618 | $savedAssociations = $this->__backAssociation; |
2619 | 2619 | $this->__backAssociation = array(); |
2620 | 2620 | } |
@@ -2633,7 +2633,7 @@ discard block |
||
2633 | 2633 | $Model->recursive = -1; |
2634 | 2634 | $conditions = array($Model->escapeField($data['foreignKey']) => $id); |
2635 | 2635 | if ($data['conditions']) { |
2636 | - $conditions = array_merge((array)$data['conditions'], $conditions); |
|
2636 | + $conditions = array_merge((array) $data['conditions'], $conditions); |
|
2637 | 2637 | } |
2638 | 2638 | } |
2639 | 2639 | |
@@ -2644,7 +2644,7 @@ discard block |
||
2644 | 2644 | 'conditions' => $conditions, 'fields' => $Model->primaryKey |
2645 | 2645 | )); |
2646 | 2646 | |
2647 | - if (!empty($records)) { |
|
2647 | + if ( ! empty($records)) { |
|
2648 | 2648 | foreach ($records as $record) { |
2649 | 2649 | $Model->delete($record[$Model->alias][$Model->primaryKey]); |
2650 | 2650 | } |
@@ -2674,7 +2674,7 @@ discard block |
||
2674 | 2674 | 'callbacks' => false |
2675 | 2675 | )); |
2676 | 2676 | |
2677 | - if (!empty($records)) { |
|
2677 | + if ( ! empty($records)) { |
|
2678 | 2678 | foreach ($records as $record) { |
2679 | 2679 | $Model->delete($record[$Model->alias][$Model->primaryKey]); |
2680 | 2680 | } |
@@ -2698,7 +2698,7 @@ discard block |
||
2698 | 2698 | |
2699 | 2699 | $db = $this->getDataSource(); |
2700 | 2700 | |
2701 | - if (!$cascade && !$callbacks) { |
|
2701 | + if ( ! $cascade && ! $callbacks) { |
|
2702 | 2702 | return $db->delete($this, $conditions); |
2703 | 2703 | } |
2704 | 2704 | |
@@ -2736,7 +2736,7 @@ discard block |
||
2736 | 2736 | } |
2737 | 2737 | } |
2738 | 2738 | |
2739 | - return $db->delete($this, array($this->alias . '.' . $this->primaryKey => $ids)); |
|
2739 | + return $db->delete($this, array($this->alias.'.'.$this->primaryKey => $ids)); |
|
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | /** |
@@ -2776,9 +2776,9 @@ discard block |
||
2776 | 2776 | return false; |
2777 | 2777 | } |
2778 | 2778 | |
2779 | - return (bool)$this->find('count', array( |
|
2779 | + return (bool) $this->find('count', array( |
|
2780 | 2780 | 'conditions' => array( |
2781 | - $this->alias . '.' . $this->primaryKey => $id |
|
2781 | + $this->alias.'.'.$this->primaryKey => $id |
|
2782 | 2782 | ), |
2783 | 2783 | 'recursive' => -1, |
2784 | 2784 | 'callbacks' => false |
@@ -2792,7 +2792,7 @@ discard block |
||
2792 | 2792 | * @return boolean True if such a record exists |
2793 | 2793 | */ |
2794 | 2794 | public function hasAny($conditions = null) { |
2795 | - return (bool)$this->find('count', array('conditions' => $conditions, 'recursive' => -1)); |
|
2795 | + return (bool) $this->find('count', array('conditions' => $conditions, 'recursive' => -1)); |
|
2796 | 2796 | } |
2797 | 2797 | |
2798 | 2798 | /** |
@@ -2910,7 +2910,7 @@ discard block |
||
2910 | 2910 | $this->findQueryType = null; |
2911 | 2911 | |
2912 | 2912 | if ($this->findMethods[$type] === true) { |
2913 | - return $this->{'_find' . ucfirst($type)}('after', $query, $results); |
|
2913 | + return $this->{'_find'.ucfirst($type)}('after', $query, $results); |
|
2914 | 2914 | } |
2915 | 2915 | } |
2916 | 2916 | |
@@ -2928,18 +2928,18 @@ discard block |
||
2928 | 2928 | 'conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => null, |
2929 | 2929 | 'offset' => null, 'order' => null, 'page' => 1, 'group' => null, 'callbacks' => true, |
2930 | 2930 | ), |
2931 | - (array)$query |
|
2931 | + (array) $query |
|
2932 | 2932 | ); |
2933 | 2933 | |
2934 | 2934 | if ($this->findMethods[$type] === true) { |
2935 | - $query = $this->{'_find' . ucfirst($type)}('before', $query); |
|
2935 | + $query = $this->{'_find'.ucfirst($type)}('before', $query); |
|
2936 | 2936 | } |
2937 | 2937 | |
2938 | - if (!is_numeric($query['page']) || intval($query['page']) < 1) { |
|
2938 | + if ( ! is_numeric($query['page']) || intval($query['page']) < 1) { |
|
2939 | 2939 | $query['page'] = 1; |
2940 | 2940 | } |
2941 | 2941 | |
2942 | - if ($query['page'] > 1 && !empty($query['limit'])) { |
|
2942 | + if ($query['page'] > 1 && ! empty($query['limit'])) { |
|
2943 | 2943 | $query['offset'] = ($query['page'] - 1) * $query['limit']; |
2944 | 2944 | } |
2945 | 2945 | |
@@ -3014,26 +3014,26 @@ discard block |
||
3014 | 3014 | */ |
3015 | 3015 | protected function _findCount($state, $query, $results = array()) { |
3016 | 3016 | if ($state === 'before') { |
3017 | - if (!empty($query['type']) && isset($this->findMethods[$query['type']]) && $query['type'] !== 'count') { |
|
3017 | + if ( ! empty($query['type']) && isset($this->findMethods[$query['type']]) && $query['type'] !== 'count') { |
|
3018 | 3018 | $query['operation'] = 'count'; |
3019 | - $query = $this->{'_find' . ucfirst($query['type'])}('before', $query); |
|
3019 | + $query = $this->{'_find'.ucfirst($query['type'])}('before', $query); |
|
3020 | 3020 | } |
3021 | 3021 | |
3022 | 3022 | $db = $this->getDataSource(); |
3023 | 3023 | $query['order'] = false; |
3024 | - if (!method_exists($db, 'calculate')) { |
|
3024 | + if ( ! method_exists($db, 'calculate')) { |
|
3025 | 3025 | return $query; |
3026 | 3026 | } |
3027 | 3027 | |
3028 | - if (!empty($query['fields']) && is_array($query['fields'])) { |
|
3029 | - if (!preg_match('/^count/i', current($query['fields']))) { |
|
3028 | + if ( ! empty($query['fields']) && is_array($query['fields'])) { |
|
3029 | + if ( ! preg_match('/^count/i', current($query['fields']))) { |
|
3030 | 3030 | unset($query['fields']); |
3031 | 3031 | } |
3032 | 3032 | } |
3033 | 3033 | |
3034 | 3034 | if (empty($query['fields'])) { |
3035 | 3035 | $query['fields'] = $db->calculate($this, 'count'); |
3036 | - } elseif (method_exists($db, 'expression') && is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) { |
|
3036 | + } elseif (method_exists($db, 'expression') && is_string($query['fields']) && ! preg_match('/count/i', $query['fields'])) { |
|
3037 | 3037 | $query['fields'] = $db->calculate($this, 'count', array( |
3038 | 3038 | $db->expression($query['fields']), 'count' |
3039 | 3039 | )); |
@@ -3070,37 +3070,37 @@ discard block |
||
3070 | 3070 | $query['fields'] = array("{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}"); |
3071 | 3071 | $list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null); |
3072 | 3072 | } else { |
3073 | - if (!is_array($query['fields'])) { |
|
3073 | + if ( ! is_array($query['fields'])) { |
|
3074 | 3074 | $query['fields'] = String::tokenize($query['fields']); |
3075 | 3075 | } |
3076 | 3076 | |
3077 | 3077 | if (count($query['fields']) === 1) { |
3078 | 3078 | if (strpos($query['fields'][0], '.') === false) { |
3079 | - $query['fields'][0] = $this->alias . '.' . $query['fields'][0]; |
|
3079 | + $query['fields'][0] = $this->alias.'.'.$query['fields'][0]; |
|
3080 | 3080 | } |
3081 | 3081 | |
3082 | - $list = array("{n}.{$this->alias}.{$this->primaryKey}", '{n}.' . $query['fields'][0], null); |
|
3082 | + $list = array("{n}.{$this->alias}.{$this->primaryKey}", '{n}.'.$query['fields'][0], null); |
|
3083 | 3083 | $query['fields'] = array("{$this->alias}.{$this->primaryKey}", $query['fields'][0]); |
3084 | 3084 | } elseif (count($query['fields']) === 3) { |
3085 | 3085 | for ($i = 0; $i < 3; $i++) { |
3086 | 3086 | if (strpos($query['fields'][$i], '.') === false) { |
3087 | - $query['fields'][$i] = $this->alias . '.' . $query['fields'][$i]; |
|
3087 | + $query['fields'][$i] = $this->alias.'.'.$query['fields'][$i]; |
|
3088 | 3088 | } |
3089 | 3089 | } |
3090 | 3090 | |
3091 | - $list = array('{n}.' . $query['fields'][0], '{n}.' . $query['fields'][1], '{n}.' . $query['fields'][2]); |
|
3091 | + $list = array('{n}.'.$query['fields'][0], '{n}.'.$query['fields'][1], '{n}.'.$query['fields'][2]); |
|
3092 | 3092 | } else { |
3093 | 3093 | for ($i = 0; $i < 2; $i++) { |
3094 | 3094 | if (strpos($query['fields'][$i], '.') === false) { |
3095 | - $query['fields'][$i] = $this->alias . '.' . $query['fields'][$i]; |
|
3095 | + $query['fields'][$i] = $this->alias.'.'.$query['fields'][$i]; |
|
3096 | 3096 | } |
3097 | 3097 | } |
3098 | 3098 | |
3099 | - $list = array('{n}.' . $query['fields'][0], '{n}.' . $query['fields'][1], null); |
|
3099 | + $list = array('{n}.'.$query['fields'][0], '{n}.'.$query['fields'][1], null); |
|
3100 | 3100 | } |
3101 | 3101 | } |
3102 | 3102 | |
3103 | - if (!isset($query['recursive']) || $query['recursive'] === null) { |
|
3103 | + if ( ! isset($query['recursive']) || $query['recursive'] === null) { |
|
3104 | 3104 | $query['recursive'] = -1; |
3105 | 3105 | } |
3106 | 3106 | list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list; |
@@ -3128,18 +3128,18 @@ discard block |
||
3128 | 3128 | extract($query); |
3129 | 3129 | |
3130 | 3130 | if ($state === 'before') { |
3131 | - $conditions = (array)$conditions; |
|
3131 | + $conditions = (array) $conditions; |
|
3132 | 3132 | if (isset($field) && isset($value)) { |
3133 | 3133 | if (strpos($field, '.') === false) { |
3134 | - $field = $this->alias . '.' . $field; |
|
3134 | + $field = $this->alias.'.'.$field; |
|
3135 | 3135 | } |
3136 | 3136 | } else { |
3137 | - $field = $this->alias . '.' . $this->primaryKey; |
|
3137 | + $field = $this->alias.'.'.$this->primaryKey; |
|
3138 | 3138 | $value = $this->id; |
3139 | 3139 | } |
3140 | 3140 | |
3141 | - $query['conditions'] = array_merge($conditions, array($field . ' <' => $value)); |
|
3142 | - $query['order'] = $field . ' DESC'; |
|
3141 | + $query['conditions'] = array_merge($conditions, array($field.' <' => $value)); |
|
3142 | + $query['order'] = $field.' DESC'; |
|
3143 | 3143 | $query['limit'] = 1; |
3144 | 3144 | $query['field'] = $field; |
3145 | 3145 | $query['value'] = $value; |
@@ -3147,28 +3147,28 @@ discard block |
||
3147 | 3147 | return $query; |
3148 | 3148 | } |
3149 | 3149 | |
3150 | - unset($query['conditions'][$field . ' <']); |
|
3150 | + unset($query['conditions'][$field.' <']); |
|
3151 | 3151 | $return = array(); |
3152 | 3152 | if (isset($results[0])) { |
3153 | 3153 | $prevVal = Hash::get($results[0], $field); |
3154 | - $query['conditions'][$field . ' >='] = $prevVal; |
|
3155 | - $query['conditions'][$field . ' !='] = $value; |
|
3154 | + $query['conditions'][$field.' >='] = $prevVal; |
|
3155 | + $query['conditions'][$field.' !='] = $value; |
|
3156 | 3156 | $query['limit'] = 2; |
3157 | 3157 | } else { |
3158 | 3158 | $return['prev'] = null; |
3159 | - $query['conditions'][$field . ' >'] = $value; |
|
3159 | + $query['conditions'][$field.' >'] = $value; |
|
3160 | 3160 | $query['limit'] = 1; |
3161 | 3161 | } |
3162 | 3162 | |
3163 | - $query['order'] = $field . ' ASC'; |
|
3163 | + $query['order'] = $field.' ASC'; |
|
3164 | 3164 | $neighbors = $this->find('all', $query); |
3165 | - if (!array_key_exists('prev', $return)) { |
|
3165 | + if ( ! array_key_exists('prev', $return)) { |
|
3166 | 3166 | $return['prev'] = isset($neighbors[0]) ? $neighbors[0] : null; |
3167 | 3167 | } |
3168 | 3168 | |
3169 | 3169 | if (count($neighbors) === 2) { |
3170 | 3170 | $return['next'] = $neighbors[1]; |
3171 | - } elseif (count($neighbors) === 1 && !$return['prev']) { |
|
3171 | + } elseif (count($neighbors) === 1 && ! $return['prev']) { |
|
3172 | 3172 | $return['next'] = $neighbors[0]; |
3173 | 3173 | } else { |
3174 | 3174 | $return['next'] = null; |
@@ -3197,8 +3197,8 @@ discard block |
||
3197 | 3197 | } |
3198 | 3198 | |
3199 | 3199 | return Hash::nest($results, array( |
3200 | - 'idPath' => '{n}.' . $this->alias . '.' . $this->primaryKey, |
|
3201 | - 'parentPath' => '{n}.' . $this->alias . '.' . $parent |
|
3200 | + 'idPath' => '{n}.'.$this->alias.'.'.$this->primaryKey, |
|
3201 | + 'parentPath' => '{n}.'.$this->alias.'.'.$parent |
|
3202 | 3202 | )); |
3203 | 3203 | } |
3204 | 3204 | |
@@ -3224,7 +3224,7 @@ discard block |
||
3224 | 3224 | * @return boolean Success |
3225 | 3225 | */ |
3226 | 3226 | public function resetAssociations() { |
3227 | - if (!empty($this->__backAssociation)) { |
|
3227 | + if ( ! empty($this->__backAssociation)) { |
|
3228 | 3228 | foreach ($this->_associations as $type) { |
3229 | 3229 | if (isset($this->__backAssociation[$type])) { |
3230 | 3230 | $this->{$type} = $this->__backAssociation[$type]; |
@@ -3236,7 +3236,7 @@ discard block |
||
3236 | 3236 | |
3237 | 3237 | foreach ($this->_associations as $type) { |
3238 | 3238 | foreach ($this->{$type} as $key => $name) { |
3239 | - if (property_exists($this, $key) && !empty($this->{$key}->__backAssociation)) { |
|
3239 | + if (property_exists($this, $key) && ! empty($this->{$key}->__backAssociation)) { |
|
3240 | 3240 | $this->{$key}->resetAssociations(); |
3241 | 3241 | } |
3242 | 3242 | } |
@@ -3254,7 +3254,7 @@ discard block |
||
3254 | 3254 | * @return boolean False if any records matching any fields are found |
3255 | 3255 | */ |
3256 | 3256 | public function isUnique($fields, $or = true) { |
3257 | - if (!is_array($fields)) { |
|
3257 | + if ( ! is_array($fields)) { |
|
3258 | 3258 | $fields = func_get_args(); |
3259 | 3259 | if (is_bool($fields[count($fields) - 1])) { |
3260 | 3260 | $or = $fields[count($fields) - 1]; |
@@ -3275,7 +3275,7 @@ discard block |
||
3275 | 3275 | |
3276 | 3276 | if (strpos($field, '.') === false) { |
3277 | 3277 | unset($fields[$field]); |
3278 | - $fields[$this->alias . '.' . $field] = $value; |
|
3278 | + $fields[$this->alias.'.'.$field] = $value; |
|
3279 | 3279 | } |
3280 | 3280 | } |
3281 | 3281 | |
@@ -3283,11 +3283,11 @@ discard block |
||
3283 | 3283 | $fields = array('or' => $fields); |
3284 | 3284 | } |
3285 | 3285 | |
3286 | - if (!empty($this->id)) { |
|
3287 | - $fields[$this->alias . '.' . $this->primaryKey . ' !='] = $this->id; |
|
3286 | + if ( ! empty($this->id)) { |
|
3287 | + $fields[$this->alias.'.'.$this->primaryKey.' !='] = $this->id; |
|
3288 | 3288 | } |
3289 | 3289 | |
3290 | - return !$this->find('count', array('conditions' => $fields, 'recursive' => -1)); |
|
3290 | + return ! $this->find('count', array('conditions' => $fields, 'recursive' => -1)); |
|
3291 | 3291 | } |
3292 | 3292 | |
3293 | 3293 | /** |
@@ -3354,7 +3354,7 @@ discard block |
||
3354 | 3354 | */ |
3355 | 3355 | public function isForeignKey($field) { |
3356 | 3356 | $foreignKeys = array(); |
3357 | - if (!empty($this->belongsTo)) { |
|
3357 | + if ( ! empty($this->belongsTo)) { |
|
3358 | 3358 | foreach ($this->belongsTo as $data) { |
3359 | 3359 | $foreignKeys[] = $data['foreignKey']; |
3360 | 3360 | } |
@@ -3381,11 +3381,11 @@ discard block |
||
3381 | 3381 | } |
3382 | 3382 | |
3383 | 3383 | $db = $this->getDataSource(); |
3384 | - if (strpos($field, $db->name($alias) . '.') === 0) { |
|
3384 | + if (strpos($field, $db->name($alias).'.') === 0) { |
|
3385 | 3385 | return $field; |
3386 | 3386 | } |
3387 | 3387 | |
3388 | - return $db->name($alias . '.' . $field); |
|
3388 | + return $db->name($alias.'.'.$field); |
|
3389 | 3389 | } |
3390 | 3390 | |
3391 | 3391 | /** |
@@ -3399,11 +3399,11 @@ discard block |
||
3399 | 3399 | return false; |
3400 | 3400 | } |
3401 | 3401 | |
3402 | - if (!is_array($this->id)) { |
|
3402 | + if ( ! is_array($this->id)) { |
|
3403 | 3403 | return $this->id; |
3404 | 3404 | } |
3405 | 3405 | |
3406 | - if (isset($this->id[$list]) && !empty($this->id[$list])) { |
|
3406 | + if (isset($this->id[$list]) && ! empty($this->id[$list])) { |
|
3407 | 3407 | return $this->id[$list]; |
3408 | 3408 | } |
3409 | 3409 | |
@@ -3475,10 +3475,10 @@ discard block |
||
3475 | 3475 | } |
3476 | 3476 | |
3477 | 3477 | $db = ConnectionManager::getDataSource($this->useDbConfig); |
3478 | - if (!empty($oldConfig) && isset($db->config['prefix'])) { |
|
3478 | + if ( ! empty($oldConfig) && isset($db->config['prefix'])) { |
|
3479 | 3479 | $oldDb = ConnectionManager::getDataSource($oldConfig); |
3480 | 3480 | |
3481 | - if (!isset($this->tablePrefix) || (!isset($oldDb->config['prefix']) || $this->tablePrefix === $oldDb->config['prefix'])) { |
|
3481 | + if ( ! isset($this->tablePrefix) || ( ! isset($oldDb->config['prefix']) || $this->tablePrefix === $oldDb->config['prefix'])) { |
|
3482 | 3482 | $this->tablePrefix = $db->config['prefix']; |
3483 | 3483 | } |
3484 | 3484 | } elseif (isset($db->config['prefix'])) { |
@@ -3494,7 +3494,7 @@ discard block |
||
3494 | 3494 | * @return DataSource A DataSource object |
3495 | 3495 | */ |
3496 | 3496 | public function getDataSource() { |
3497 | - if (!$this->_sourceConfigured && $this->useTable !== false) { |
|
3497 | + if ( ! $this->_sourceConfigured && $this->useTable !== false) { |
|
3498 | 3498 | $this->_sourceConfigured = true; |
3499 | 3499 | $this->setSource($this->useTable); |
3500 | 3500 | } |
@@ -3518,10 +3518,10 @@ discard block |
||
3518 | 3518 | * @return array Associations |
3519 | 3519 | */ |
3520 | 3520 | public function getAssociated($type = null) { |
3521 | - if (!$type) { |
|
3521 | + if ( ! $type) { |
|
3522 | 3522 | $associated = array(); |
3523 | 3523 | foreach ($this->_associations as $assoc) { |
3524 | - if (!empty($this->{$assoc})) { |
|
3524 | + if ( ! empty($this->{$assoc})) { |
|
3525 | 3525 | $models = array_keys($this->{$assoc}); |
3526 | 3526 | foreach ($models as $m) { |
3527 | 3527 | $associated[$m] = $assoc; |
@@ -3706,7 +3706,7 @@ discard block |
||
3706 | 3706 | foreach ($this->_associations as $association) { |
3707 | 3707 | foreach ($this->{$association} as $className) { |
3708 | 3708 | $pluralizedAssociation = Inflector::pluralize($className['className']); |
3709 | - if (!in_array(strtolower($pluralizedAssociation), $assoc)) { |
|
3709 | + if ( ! in_array(strtolower($pluralizedAssociation), $assoc)) { |
|
3710 | 3710 | $assoc = array_merge($assoc, array( |
3711 | 3711 | strtolower($pluralizedAssociation), |
3712 | 3712 | Inflector::underscore($pluralizedAssociation) |
@@ -3728,7 +3728,7 @@ discard block |
||
3728 | 3728 | public function validator(ModelValidator $instance = null) { |
3729 | 3729 | if ($instance) { |
3730 | 3730 | $this->_validator = $instance; |
3731 | - } elseif (!$this->_validator) { |
|
3731 | + } elseif ( ! $this->_validator) { |
|
3732 | 3732 | $this->_validator = new ModelValidator($this); |
3733 | 3733 | } |
3734 | 3734 |
@@ -121,7 +121,7 @@ |
||
121 | 121 | * |
122 | 122 | * @param array $data Record data to validate. This should be an array indexed by association name. |
123 | 123 | * @param array $options Options to use when validating record data (see above), See also $options of validates(). |
124 | - * @return array|boolean If atomic: True on success, or false on failure. |
|
124 | + * @return boolean If atomic: True on success, or false on failure. |
|
125 | 125 | * Otherwise: array similar to the $data array passed, but values are set to true/false |
126 | 126 | * depending on whether each record validated successfully. |
127 | 127 | */ |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | $model->validationErrors = $validationErrors = $return = array(); |
132 | 132 | $model->create(null); |
133 | 133 | $return[$model->alias] = true; |
134 | - if (!($model->set($data) && $model->validates($options))) { |
|
134 | + if ( ! ($model->set($data) && $model->validates($options))) { |
|
135 | 135 | $validationErrors[$model->alias] = $model->validationErrors; |
136 | 136 | $return[$model->alias] = false; |
137 | 137 | } |
138 | 138 | $data = $model->data; |
139 | - if (!empty($options['deep']) && isset($data[$model->alias])) { |
|
139 | + if ( ! empty($options['deep']) && isset($data[$model->alias])) { |
|
140 | 140 | $recordData = $data[$model->alias]; |
141 | 141 | unset($data[$model->alias]); |
142 | 142 | $data += $recordData; |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | $data[$association] = $model->{$association}->data[$model->{$association}->alias]; |
156 | 156 | } |
157 | 157 | if (is_array($validates)) { |
158 | - $validates = !in_array(false, Hash::flatten($validates), true); |
|
158 | + $validates = ! in_array(false, Hash::flatten($validates), true); |
|
159 | 159 | } |
160 | 160 | $return[$association] = $validates; |
161 | 161 | } elseif ($associations[$association] === 'hasMany') { |
162 | 162 | $validates = $model->{$association}->validateMany($values, $options); |
163 | 163 | $return[$association] = $validates; |
164 | 164 | } |
165 | - if (!$validates || (is_array($validates) && in_array(false, $validates, true))) { |
|
165 | + if ( ! $validates || (is_array($validates) && in_array(false, $validates, true))) { |
|
166 | 166 | $validationErrors[$association] = $model->{$association}->validationErrors; |
167 | 167 | } |
168 | 168 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | unset($validationErrors[$model->alias]); |
175 | 175 | $model->validationErrors = array_merge($model->validationErrors, $validationErrors); |
176 | 176 | } |
177 | - if (!$options['atomic']) { |
|
177 | + if ( ! $options['atomic']) { |
|
178 | 178 | return $return; |
179 | 179 | } |
180 | - if ($return[$model->alias] === false || !empty($model->validationErrors)) { |
|
180 | + if ($return[$model->alias] === false || ! empty($model->validationErrors)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | return true; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $return[$key] = $validates; |
224 | 224 | } |
225 | 225 | $model->validationErrors = $validationErrors; |
226 | - if (!$options['atomic']) { |
|
226 | + if ( ! $options['atomic']) { |
|
227 | 227 | return $return; |
228 | 228 | } |
229 | 229 | return empty($model->validationErrors); |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * @see ModelValidator::validates() |
239 | 239 | */ |
240 | 240 | public function errors($options = array()) { |
241 | - if (!$this->_triggerBeforeValidate($options)) { |
|
241 | + if ( ! $this->_triggerBeforeValidate($options)) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | $model = $this->getModel(); |
245 | 245 | |
246 | - if (!$this->_parseRules()) { |
|
246 | + if ( ! $this->_parseRules()) { |
|
247 | 247 | return $model->validationErrors; |
248 | 248 | } |
249 | 249 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getMethods() { |
288 | 288 | $behaviors = $this->_model->Behaviors->enabled(); |
289 | - if (!empty($this->_methods) && $behaviors === $this->_behaviors) { |
|
289 | + if ( ! empty($this->_methods) && $behaviors === $this->_behaviors) { |
|
290 | 290 | return $this->_methods; |
291 | 291 | } |
292 | 292 | $this->_behaviors = $behaviors; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | public function getField($name = null) { |
316 | 316 | $this->_parseRules(); |
317 | 317 | if ($name !== null) { |
318 | - if (!empty($this->_fields[$name])) { |
|
318 | + if ( ! empty($this->_fields[$name])) { |
|
319 | 319 | return $this->_fields[$name]; |
320 | 320 | } |
321 | 321 | return null; |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | $model = $this->getModel(); |
385 | 385 | $whitelist = $model->whitelist; |
386 | 386 | |
387 | - if (!empty($fieldList)) { |
|
388 | - if (!empty($fieldList[$model->alias]) && is_array($fieldList[$model->alias])) { |
|
387 | + if ( ! empty($fieldList)) { |
|
388 | + if ( ! empty($fieldList[$model->alias]) && is_array($fieldList[$model->alias])) { |
|
389 | 389 | $whitelist = $fieldList[$model->alias]; |
390 | 390 | } else { |
391 | 391 | $whitelist = $fieldList; |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | |
400 | 400 | $validateList = array(); |
401 | 401 | $this->validationErrors = array(); |
402 | - foreach ((array)$whitelist as $f) { |
|
403 | - if (!empty($this->_fields[$f])) { |
|
402 | + foreach ((array) $whitelist as $f) { |
|
403 | + if ( ! empty($this->_fields[$f])) { |
|
404 | 404 | $validateList[$f] = $this->_fields[$f]; |
405 | 405 | } |
406 | 406 | } |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | $model = $this->getModel(); |
422 | 422 | |
423 | 423 | foreach ($model->hasAndBelongsToMany as $assoc => $association) { |
424 | - if (empty($association['with']) || !isset($model->data[$assoc])) { |
|
424 | + if (empty($association['with']) || ! isset($model->data[$assoc])) { |
|
425 | 425 | continue; |
426 | 426 | } |
427 | 427 | list($join) = $model->joinModel($model->hasAndBelongsToMany[$assoc]['with']); |
428 | 428 | $data = $model->data[$assoc]; |
429 | 429 | |
430 | 430 | $newData = array(); |
431 | - foreach ((array)$data as $row) { |
|
431 | + foreach ((array) $data as $row) { |
|
432 | 432 | if (isset($row[$model->hasAndBelongsToMany[$assoc]['associationForeignKey']])) { |
433 | 433 | $newData[] = $row; |
434 | 434 | } elseif (isset($row[$join]) && isset($row[$join][$model->hasAndBelongsToMany[$assoc]['associationForeignKey']])) { |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | */ |
493 | 493 | public function offsetSet($field, $rules) { |
494 | 494 | $this->_parseRules(); |
495 | - if (!$rules instanceof CakeValidationSet) { |
|
495 | + if ( ! $rules instanceof CakeValidationSet) { |
|
496 | 496 | $rules = new CakeValidationSet($field, $rules); |
497 | 497 | $methods = $this->getMethods(); |
498 | 498 | $rules->setMethods($methods); |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | return $this; |
562 | 562 | } |
563 | 563 | |
564 | - if (!isset($this->_fields[$field])) { |
|
564 | + if ( ! isset($this->_fields[$field])) { |
|
565 | 565 | $rule = (is_string($name)) ? array($name => $rule) : $name; |
566 | 566 | $this->_fields[$field] = new CakeValidationSet($field, $rule); |
567 | 567 | } else { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * Constructor |
76 | 76 | * |
77 | 77 | * @param string $fieldName The fieldname |
78 | - * @param array $ruleset |
|
78 | + * @param array $ruleSet |
|
79 | 79 | */ |
80 | 80 | public function __construct($fieldName, $ruleSet) { |
81 | 81 | $this->field = $fieldName; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @param array $rules The rules to be set |
236 | 236 | * @param boolean $mergeVars [optional] If true, merges vars instead of replace. Defaults to true. |
237 | - * @return ModelField |
|
237 | + * @return CakeValidationSet |
|
238 | 238 | */ |
239 | 239 | public function setRules($rules = array(), $mergeVars = true) { |
240 | 240 | if ($mergeVars === false) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public function __construct($fieldName, $ruleSet) { |
81 | 81 | $this->field = $fieldName; |
82 | 82 | |
83 | - if (!is_array($ruleSet) || (is_array($ruleSet) && isset($ruleSet['rule']))) { |
|
83 | + if ( ! is_array($ruleSet) || (is_array($ruleSet) && isset($ruleSet['rule']))) { |
|
84 | 84 | $ruleSet = array($ruleSet); |
85 | 85 | } |
86 | 86 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return void |
98 | 98 | */ |
99 | 99 | public function setMethods(&$methods) { |
100 | - $this->_methods =& $methods; |
|
100 | + $this->_methods = & $methods; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | $checkRequired = $rule->checkRequired($this->field, $data); |
131 | - if (!$checkRequired && array_key_exists($this->field, $data)) { |
|
131 | + if ( ! $checkRequired && array_key_exists($this->field, $data)) { |
|
132 | 132 | if ($rule->checkEmpty($this->field, $data)) { |
133 | 133 | break; |
134 | 134 | } |
135 | 135 | $rule->process($this->field, $data, $this->_methods); |
136 | 136 | } |
137 | 137 | |
138 | - if ($checkRequired || !$rule->isValid()) { |
|
138 | + if ($checkRequired || ! $rule->isValid()) { |
|
139 | 139 | $errors[] = $this->_processValidationResponse($name, $rule); |
140 | 140 | if ($rule->isLast()) { |
141 | 141 | break; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return CakeValidationRule |
165 | 165 | */ |
166 | 166 | public function getRule($name) { |
167 | - if (!empty($this->_rules[$name])) { |
|
167 | + if ( ! empty($this->_rules[$name])) { |
|
168 | 168 | return $this->_rules[$name]; |
169 | 169 | } |
170 | 170 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @return CakeValidationSet this instance |
195 | 195 | */ |
196 | 196 | public function setRule($name, $rule) { |
197 | - if (!($rule instanceof CakeValidationRule)) { |
|
197 | + if ( ! ($rule instanceof CakeValidationRule)) { |
|
198 | 198 | $rule = new CakeValidationRule($rule); |
199 | 199 | } |
200 | 200 | $this->_rules[$name] = $rule; |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @return array Translated args. |
297 | 297 | */ |
298 | 298 | protected function _translateArgs($args) { |
299 | - foreach ((array)$args as $k => $arg) { |
|
299 | + foreach ((array) $args as $k => $arg) { |
|
300 | 300 | if (is_string($arg)) { |
301 | 301 | $args[$k] = __d($this->_validationDomain, $arg); |
302 | 302 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @param string $name The method called |
442 | 442 | * @param array $params Array of parameters for the method call |
443 | - * @return mixed |
|
443 | + * @return boolean |
|
444 | 444 | * @throws CakeException when an invalid method is called. |
445 | 445 | */ |
446 | 446 | public function __call($name, $params) { |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * See CakeRequest::is() for how to add additional types and the |
529 | 529 | * built-in types. |
530 | 530 | * |
531 | - * @param array $types The types to check. |
|
531 | + * @param string[] $types The types to check. |
|
532 | 532 | * @return boolean Success. |
533 | 533 | * @see CakeRequest::is() |
534 | 534 | */ |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | * This modifies the parameters available through `$request->params`. |
592 | 592 | * |
593 | 593 | * @param array $params Array of parameters to merge in |
594 | - * @return The current object, you can chain this method. |
|
594 | + * @return CakeRequest current object, you can chain this method. |
|
595 | 595 | */ |
596 | 596 | public function addParams($params) { |
597 | 597 | $this->params = array_merge($this->params, (array)$params); |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * You can write to any value, even paths/keys that do not exist, and the arrays |
844 | 844 | * will be created for you. |
845 | 845 | * |
846 | - * @param string $name,... Dot separated name of the value to read/write |
|
846 | + * @param string $name |
|
847 | 847 | * @return mixed Either the value being read, or this so you can chain consecutive writes. |
848 | 848 | */ |
849 | 849 | public function data($name) { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $this->_processGet(); |
144 | 144 | $this->_processFiles(); |
145 | 145 | } |
146 | - $this->here = $this->base . '/' . $this->url; |
|
146 | + $this->here = $this->base.'/'.$this->url; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | } |
178 | 178 | $isArray = is_array($this->data); |
179 | 179 | if ($isArray && isset($this->data['_method'])) { |
180 | - if (!empty($_SERVER)) { |
|
180 | + if ( ! empty($_SERVER)) { |
|
181 | 181 | $_SERVER['REQUEST_METHOD'] = $this->data['_method']; |
182 | 182 | } else { |
183 | 183 | $_ENV['REQUEST_METHOD'] = $this->data['_method']; |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | $query = $_GET; |
208 | 208 | } |
209 | 209 | |
210 | - $unsetUrl = '/' . str_replace('.', '_', urldecode($this->url)); |
|
210 | + $unsetUrl = '/'.str_replace('.', '_', urldecode($this->url)); |
|
211 | 211 | unset($query[$unsetUrl]); |
212 | - unset($query[$this->base . $unsetUrl]); |
|
212 | + unset($query[$this->base.$unsetUrl]); |
|
213 | 213 | if (strpos($this->url, '?') !== false) { |
214 | 214 | list(, $querystr) = explode('?', $this->url); |
215 | 215 | parse_str($querystr, $queryArgs); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return string URI The CakePHP request path that is being accessed. |
230 | 230 | */ |
231 | 231 | protected function _url() { |
232 | - if (!empty($_SERVER['PATH_INFO'])) { |
|
232 | + if ( ! empty($_SERVER['PATH_INFO'])) { |
|
233 | 233 | return $_SERVER['PATH_INFO']; |
234 | 234 | } elseif (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) { |
235 | 235 | $uri = $_SERVER['REQUEST_URI']; |
@@ -285,20 +285,20 @@ discard block |
||
285 | 285 | $config = Configure::read('App'); |
286 | 286 | extract($config); |
287 | 287 | |
288 | - if (!isset($base)) { |
|
288 | + if ( ! isset($base)) { |
|
289 | 289 | $base = $this->base; |
290 | 290 | } |
291 | 291 | if ($base !== false) { |
292 | - $this->webroot = $base . '/'; |
|
292 | + $this->webroot = $base.'/'; |
|
293 | 293 | return $this->base = $base; |
294 | 294 | } |
295 | 295 | |
296 | - if (!$baseUrl) { |
|
296 | + if ( ! $baseUrl) { |
|
297 | 297 | $base = dirname(env('PHP_SELF')); |
298 | 298 | |
299 | 299 | $indexPos = strpos($base, '/webroot/index.php'); |
300 | 300 | if ($indexPos !== false) { |
301 | - $base = substr($base, 0, $indexPos) . '/webroot'; |
|
301 | + $base = substr($base, 0, $indexPos).'/webroot'; |
|
302 | 302 | } |
303 | 303 | if ($webroot === 'webroot' && $webroot === basename($base)) { |
304 | 304 | $base = dirname($base); |
@@ -311,31 +311,31 @@ discard block |
||
311 | 311 | $base = ''; |
312 | 312 | } |
313 | 313 | $base = implode('/', array_map('rawurlencode', explode('/', $base))); |
314 | - $this->webroot = $base . '/'; |
|
314 | + $this->webroot = $base.'/'; |
|
315 | 315 | |
316 | 316 | return $this->base = $base; |
317 | 317 | } |
318 | 318 | |
319 | - $file = '/' . basename($baseUrl); |
|
319 | + $file = '/'.basename($baseUrl); |
|
320 | 320 | $base = dirname($baseUrl); |
321 | 321 | |
322 | 322 | if ($base === DS || $base === '.') { |
323 | 323 | $base = ''; |
324 | 324 | } |
325 | - $this->webroot = $base . '/'; |
|
325 | + $this->webroot = $base.'/'; |
|
326 | 326 | |
327 | 327 | $docRoot = env('DOCUMENT_ROOT'); |
328 | - $docRootContainsWebroot = strpos($docRoot, $dir . DS . $webroot); |
|
328 | + $docRootContainsWebroot = strpos($docRoot, $dir.DS.$webroot); |
|
329 | 329 | |
330 | - if (!empty($base) || !$docRootContainsWebroot) { |
|
331 | - if (strpos($this->webroot, '/' . $dir . '/') === false) { |
|
332 | - $this->webroot .= $dir . '/'; |
|
330 | + if ( ! empty($base) || ! $docRootContainsWebroot) { |
|
331 | + if (strpos($this->webroot, '/'.$dir.'/') === false) { |
|
332 | + $this->webroot .= $dir.'/'; |
|
333 | 333 | } |
334 | - if (strpos($this->webroot, '/' . $webroot . '/') === false) { |
|
335 | - $this->webroot .= $webroot . '/'; |
|
334 | + if (strpos($this->webroot, '/'.$webroot.'/') === false) { |
|
335 | + $this->webroot .= $webroot.'/'; |
|
336 | 336 | } |
337 | 337 | } |
338 | - return $this->base = $base . $file; |
|
338 | + return $this->base = $base.$file; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | protected function _processFileData($path, $data, $field) { |
372 | 372 | foreach ($data as $key => $fields) { |
373 | 373 | $newPath = $key; |
374 | - if (!empty($path)) { |
|
375 | - $newPath = $path . '.' . $key; |
|
374 | + if ( ! empty($path)) { |
|
375 | + $newPath = $path.'.'.$key; |
|
376 | 376 | } |
377 | 377 | if (is_array($fields)) { |
378 | 378 | $this->_processFileData($newPath, $fields, $field); |
379 | 379 | } else { |
380 | - $newPath .= '.' . $field; |
|
380 | + $newPath .= '.'.$field; |
|
381 | 381 | $this->data = Hash::insert($this->data, $newPath, $fields); |
382 | 382 | } |
383 | 383 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @return string The client IP. |
392 | 392 | */ |
393 | 393 | public function clientIp($safe = true) { |
394 | - if (!$safe && env('HTTP_X_FORWARDED_FOR')) { |
|
394 | + if ( ! $safe && env('HTTP_X_FORWARDED_FOR')) { |
|
395 | 395 | $ipaddr = preg_replace('/(?:,.*)/', '', env('HTTP_X_FORWARDED_FOR')); |
396 | 396 | } else { |
397 | 397 | if (env('HTTP_CLIENT_IP')) { |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | if (env('HTTP_CLIENTADDRESS')) { |
405 | 405 | $tmpipaddr = env('HTTP_CLIENTADDRESS'); |
406 | 406 | |
407 | - if (!empty($tmpipaddr)) { |
|
407 | + if ( ! empty($tmpipaddr)) { |
|
408 | 408 | $ipaddr = preg_replace('/(?:,.*)/', '', $tmpipaddr); |
409 | 409 | } |
410 | 410 | } |
@@ -420,15 +420,15 @@ discard block |
||
420 | 420 | public function referer($local = false) { |
421 | 421 | $ref = env('HTTP_REFERER'); |
422 | 422 | |
423 | - $base = Configure::read('App.fullBaseUrl') . $this->webroot; |
|
424 | - if (!empty($ref) && !empty($base)) { |
|
423 | + $base = Configure::read('App.fullBaseUrl').$this->webroot; |
|
424 | + if ( ! empty($ref) && ! empty($base)) { |
|
425 | 425 | if ($local && strpos($ref, $base) === 0) { |
426 | 426 | $ref = substr($ref, strlen($base)); |
427 | 427 | if ($ref[0] !== '/') { |
428 | - $ref = '/' . $ref; |
|
428 | + $ref = '/'.$ref; |
|
429 | 429 | } |
430 | 430 | return $ref; |
431 | - } elseif (!$local) { |
|
431 | + } elseif ( ! $local) { |
|
432 | 432 | return $ref; |
433 | 433 | } |
434 | 434 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | return count(array_filter($result)) > 0; |
495 | 495 | } |
496 | 496 | $type = strtolower($type); |
497 | - if (!isset($this->_detectors[$type])) { |
|
497 | + if ( ! isset($this->_detectors[$type])) { |
|
498 | 498 | return false; |
499 | 499 | } |
500 | 500 | $detect = $this->_detectors[$type]; |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | return env($detect['env']) == $detect['value']; |
504 | 504 | } |
505 | 505 | if (isset($detect['pattern'])) { |
506 | - return (bool)preg_match($detect['pattern'], env($detect['env'])); |
|
506 | + return (bool) preg_match($detect['pattern'], env($detect['env'])); |
|
507 | 507 | } |
508 | 508 | if (isset($detect['options'])) { |
509 | - $pattern = '/' . implode('|', $detect['options']) . '/i'; |
|
510 | - return (bool)preg_match($pattern, env($detect['env'])); |
|
509 | + $pattern = '/'.implode('|', $detect['options']).'/i'; |
|
510 | + return (bool) preg_match($pattern, env($detect['env'])); |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | if (isset($detect['param'])) { |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * @return The current object, you can chain this method. |
595 | 595 | */ |
596 | 596 | public function addParams($params) { |
597 | - $this->params = array_merge($this->params, (array)$params); |
|
597 | + $this->params = array_merge($this->params, (array) $params); |
|
598 | 598 | return $this; |
599 | 599 | } |
600 | 600 | |
@@ -622,11 +622,11 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function here($base = true) { |
624 | 624 | $url = $this->here; |
625 | - if (!empty($this->query)) { |
|
626 | - $url .= '?' . http_build_query($this->query, null, '&'); |
|
625 | + if ( ! empty($this->query)) { |
|
626 | + $url .= '?'.http_build_query($this->query, null, '&'); |
|
627 | 627 | } |
628 | - if (!$base) { |
|
629 | - $url = preg_replace('/^' . preg_quote($this->base, '/') . '/', '', $url, 1); |
|
628 | + if ( ! $base) { |
|
629 | + $url = preg_replace('/^'.preg_quote($this->base, '/').'/', '', $url, 1); |
|
630 | 630 | } |
631 | 631 | return $url; |
632 | 632 | } |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @return mixed Either false on no header being set or the value of the header. |
639 | 639 | */ |
640 | 640 | public static function header($name) { |
641 | - $name = 'HTTP_' . strtoupper(str_replace('-', '_', $name)); |
|
642 | - if (!empty($_SERVER[$name])) { |
|
641 | + $name = 'HTTP_'.strtoupper(str_replace('-', '_', $name)); |
|
642 | + if ( ! empty($_SERVER[$name])) { |
|
643 | 643 | return $_SERVER[$name]; |
644 | 644 | } |
645 | 645 | return false; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | } |
805 | 805 | } |
806 | 806 | |
807 | - if (!isset($accept[$prefValue])) { |
|
807 | + if ( ! isset($accept[$prefValue])) { |
|
808 | 808 | $accept[$prefValue] = array(); |
809 | 809 | } |
810 | 810 | if ($prefValue) { |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | * return false if the parameter doesn't exist or is falsey. |
864 | 864 | */ |
865 | 865 | public function param($name) { |
866 | - if (!isset($this->params[$name])) { |
|
866 | + if ( ! isset($this->params[$name])) { |
|
867 | 867 | return false; |
868 | 868 | } |
869 | 869 | return $this->params[$name]; |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | public function input($callback = null) { |
892 | 892 | $input = $this->_readInput(); |
893 | 893 | $args = func_get_args(); |
894 | - if (!empty($args)) { |
|
894 | + if ( ! empty($args)) { |
|
895 | 895 | $callback = array_shift($args); |
896 | 896 | array_unshift($args, $input); |
897 | 897 | return call_user_func_array($callback, $args); |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | * @throws MethodNotAllowedException |
918 | 918 | */ |
919 | 919 | public function onlyAllow($methods) { |
920 | - if (!is_array($methods)) { |
|
920 | + if ( ! is_array($methods)) { |
|
921 | 921 | $methods = func_get_args(); |
922 | 922 | } |
923 | 923 | foreach ($methods as $method) { |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * if set to false, the response will be set to private |
814 | 814 | * if no value is provided, it will return whether the response is sharable or not |
815 | 815 | * @param integer $time time in seconds after which the response should no longer be considered fresh |
816 | - * @return boolean |
|
816 | + * @return null|boolean |
|
817 | 817 | */ |
818 | 818 | public function sharable($public = null, $time = null) { |
819 | 819 | if ($public === null) { |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | * If called with no parameters, this function will return the current max-age value if any |
849 | 849 | * |
850 | 850 | * @param integer $seconds if null, the method will return the current s-maxage value |
851 | - * @return integer |
|
851 | + * @return string|null |
|
852 | 852 | */ |
853 | 853 | public function sharedMaxAge($seconds = null) { |
854 | 854 | if ($seconds !== null) { |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | * If called with no parameters, this function will return the current max-age value if any |
869 | 869 | * |
870 | 870 | * @param integer $seconds if null, the method will return the current max-age value |
871 | - * @return integer |
|
871 | + * @return string|null |
|
872 | 872 | */ |
873 | 873 | public function maxAge($seconds = null) { |
874 | 874 | if ($seconds !== null) { |
@@ -888,8 +888,6 @@ discard block |
||
888 | 888 | * with the origin. |
889 | 889 | * If called with no parameters, this function will return whether must-revalidate is present. |
890 | 890 | * |
891 | - * @param integer $seconds if null, the method will return the current |
|
892 | - * must-revalidate value |
|
893 | 891 | * @return boolean |
894 | 892 | */ |
895 | 893 | public function mustRevalidate($enable = null) { |
@@ -1029,7 +1027,6 @@ discard block |
||
1029 | 1027 | * |
1030 | 1028 | * If no parameters are passed, current Etag header is returned. |
1031 | 1029 | * |
1032 | - * @param string $hash the unique has that identifies this response |
|
1033 | 1030 | * @param boolean $weak whether the response is semantically the same as |
1034 | 1031 | * other with the same hash or not |
1035 | 1032 | * @return string |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if (isset($options['type'])) { |
394 | 394 | $this->type($options['type']); |
395 | 395 | } |
396 | - if (!isset($options['charset'])) { |
|
396 | + if ( ! isset($options['charset'])) { |
|
397 | 397 | $options['charset'] = Configure::read('App.encoding'); |
398 | 398 | } |
399 | 399 | $this->charset($options['charset']); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $this->_setContentLength(); |
418 | 418 | $this->_setContentType(); |
419 | 419 | foreach ($this->_headers as $header => $values) { |
420 | - foreach ((array)$values as $value) { |
|
420 | + foreach ((array) $values as $value) { |
|
421 | 421 | $this->_sendHeader($header, $value); |
422 | 422 | } |
423 | 423 | } |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @return void |
493 | 493 | */ |
494 | 494 | protected function _setContentLength() { |
495 | - $shouldSetLength = !isset($this->_headers['Content-Length']) && !in_array($this->_status, range(301, 307)); |
|
495 | + $shouldSetLength = ! isset($this->_headers['Content-Length']) && ! in_array($this->_status, range(301, 307)); |
|
496 | 496 | if (isset($this->_headers['Content-Length']) && $this->_headers['Content-Length'] === false) { |
497 | 497 | unset($this->_headers['Content-Length']); |
498 | 498 | return; |
499 | 499 | } |
500 | - if ($shouldSetLength && !$this->outputCompressed()) { |
|
500 | + if ($shouldSetLength && ! $this->outputCompressed()) { |
|
501 | 501 | $offset = ob_get_level() ? ob_get_length() : 0; |
502 | 502 | if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) { |
503 | 503 | $this->length($offset + mb_strlen($this->_body, '8bit')); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return void |
516 | 516 | */ |
517 | 517 | protected function _sendHeader($name, $value = null) { |
518 | - if (!headers_sent()) { |
|
518 | + if ( ! headers_sent()) { |
|
519 | 519 | if ($value === null) { |
520 | 520 | header($name); |
521 | 521 | } else { |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | if ($code === null) { |
621 | 621 | return $this->_status; |
622 | 622 | } |
623 | - if (!isset($this->_statusCodes[$code])) { |
|
623 | + if ( ! isset($this->_statusCodes[$code])) { |
|
624 | 624 | throw new CakeException(__d('cake_dev', 'Unknown status code')); |
625 | 625 | } |
626 | 626 | return $this->_status = $code; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | if (is_array($code)) { |
665 | 665 | $codes = array_keys($code); |
666 | 666 | $min = min($codes); |
667 | - if (!is_int($min) || $min < 100 || max($codes) > 999) { |
|
667 | + if ( ! is_int($min) || $min < 100 || max($codes) > 999) { |
|
668 | 668 | throw new CakeException(__d('cake_dev', 'Invalid status code')); |
669 | 669 | } |
670 | 670 | $this->_statusCodes = $code + $this->_statusCodes; |
671 | 671 | return true; |
672 | 672 | } |
673 | - if (!isset($this->_statusCodes[$code])) { |
|
673 | + if ( ! isset($this->_statusCodes[$code])) { |
|
674 | 674 | return null; |
675 | 675 | } |
676 | 676 | return array($code => $this->_statusCodes[$code]); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | } |
751 | 751 | |
752 | 752 | foreach ($this->_mimeTypes as $alias => $types) { |
753 | - if (in_array($ctype, (array)$types)) { |
|
753 | + if (in_array($ctype, (array) $types)) { |
|
754 | 754 | return $alias; |
755 | 755 | } |
756 | 756 | } |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | public function disableCache() { |
780 | 780 | $this->header(array( |
781 | 781 | 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', |
782 | - 'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT", |
|
782 | + 'Last-Modified' => gmdate("D, d M Y H:i:s")." GMT", |
|
783 | 783 | 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' |
784 | 784 | )); |
785 | 785 | } |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | * @return void |
793 | 793 | */ |
794 | 794 | public function cache($since, $time = '+1 day') { |
795 | - if (!is_int($time)) { |
|
795 | + if ( ! is_int($time)) { |
|
796 | 796 | $time = strtotime($time); |
797 | 797 | } |
798 | 798 | $this->header(array( |
799 | - 'Date' => gmdate("D, j M Y G:i:s ", time()) . 'GMT' |
|
799 | + 'Date' => gmdate("D, j M Y G:i:s ", time()).'GMT' |
|
800 | 800 | )); |
801 | 801 | $this->modified($since); |
802 | 802 | $this->expires($time); |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $public = array_key_exists('public', $this->_cacheDirectives); |
821 | 821 | $private = array_key_exists('private', $this->_cacheDirectives); |
822 | 822 | $noCache = array_key_exists('no-cache', $this->_cacheDirectives); |
823 | - if (!$public && !$private && !$noCache) { |
|
823 | + if ( ! $public && ! $private && ! $noCache) { |
|
824 | 824 | return null; |
825 | 825 | } |
826 | 826 | $sharable = $public || ! ($private || $noCache); |
@@ -835,10 +835,10 @@ discard block |
||
835 | 835 | unset($this->_cacheDirectives['public']); |
836 | 836 | $this->maxAge($time); |
837 | 837 | } |
838 | - if (!$time) { |
|
838 | + if ( ! $time) { |
|
839 | 839 | $this->_setCacheControl(); |
840 | 840 | } |
841 | - return (bool)$public; |
|
841 | + return (bool) $public; |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | public function expires($time = null) { |
937 | 937 | if ($time !== null) { |
938 | 938 | $date = $this->_getUTCDate($time); |
939 | - $this->_headers['Expires'] = $date->format('D, j M Y H:i:s') . ' GMT'; |
|
939 | + $this->_headers['Expires'] = $date->format('D, j M Y H:i:s').' GMT'; |
|
940 | 940 | } |
941 | 941 | if (isset($this->_headers['Expires'])) { |
942 | 942 | return $this->_headers['Expires']; |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | public function modified($time = null) { |
961 | 961 | if ($time !== null) { |
962 | 962 | $date = $this->_getUTCDate($time); |
963 | - $this->_headers['Last-Modified'] = $date->format('D, j M Y H:i:s') . ' GMT'; |
|
963 | + $this->_headers['Last-Modified'] = $date->format('D, j M Y H:i:s').' GMT'; |
|
964 | 964 | } |
965 | 965 | if (isset($this->_headers['Last-Modified'])) { |
966 | 966 | return $this->_headers['Last-Modified']; |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | */ |
1005 | 1005 | public function vary($cacheVariances = null) { |
1006 | 1006 | if ($cacheVariances !== null) { |
1007 | - $cacheVariances = (array)$cacheVariances; |
|
1007 | + $cacheVariances = (array) $cacheVariances; |
|
1008 | 1008 | $this->_headers['Vary'] = implode(', ', $cacheVariances); |
1009 | 1009 | } |
1010 | 1010 | if (isset($this->_headers['Vary'])) { |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @return void |
1094 | 1094 | */ |
1095 | 1095 | public function download($filename) { |
1096 | - $this->header('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
1096 | + $this->header('Content-Disposition', 'attachment; filename="'.$filename.'"'); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | if (empty($checks)) { |
1154 | 1154 | return false; |
1155 | 1155 | } |
1156 | - $notModified = !in_array(false, $checks, true); |
|
1156 | + $notModified = ! in_array(false, $checks, true); |
|
1157 | 1157 | if ($notModified) { |
1158 | 1158 | $this->notModified(); |
1159 | 1159 | } |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | * @return string |
1168 | 1168 | */ |
1169 | 1169 | public function __toString() { |
1170 | - return (string)$this->_body; |
|
1170 | + return (string) $this->_body; |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | /** |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | if (is_string($options)) { |
1219 | - if (!isset($this->_cookies[$options])) { |
|
1219 | + if ( ! isset($this->_cookies[$options])) { |
|
1220 | 1220 | return null; |
1221 | 1221 | } |
1222 | 1222 | return $this->_cookies[$options]; |
@@ -1266,12 +1266,12 @@ discard block |
||
1266 | 1266 | )); |
1267 | 1267 | } |
1268 | 1268 | |
1269 | - if (!is_file($path)) { |
|
1270 | - $path = APP . $path; |
|
1269 | + if ( ! is_file($path)) { |
|
1270 | + $path = APP.$path; |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | $file = new File($path); |
1274 | - if (!$file->exists() || !$file->readable()) { |
|
1274 | + if ( ! $file->exists() || ! $file->readable()) { |
|
1275 | 1275 | if (Configure::read('debug')) { |
1276 | 1276 | throw new NotFoundException(__d('cake_dev', 'The requested file %s was not found or not readable', $path)); |
1277 | 1277 | } |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | $extension = strtolower($file->ext()); |
1282 | 1282 | $download = $options['download']; |
1283 | - if ((!$extension || $this->type($extension) === false) && $download === null) { |
|
1283 | + if (( ! $extension || $this->type($extension) === false) && $download === null) { |
|
1284 | 1284 | $download = true; |
1285 | 1285 | } |
1286 | 1286 | |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $contentType = 'application/force-download'; |
1295 | 1295 | } |
1296 | 1296 | |
1297 | - if (!empty($contentType)) { |
|
1297 | + if ( ! empty($contentType)) { |
|
1298 | 1298 | $this->type($contentType); |
1299 | 1299 | } |
1300 | 1300 | if ($options['name'] === null) { |
@@ -1347,14 +1347,14 @@ discard block |
||
1347 | 1347 | if ($start > $end || $end > $lastByte || $start > $lastByte) { |
1348 | 1348 | $this->statusCode(416); |
1349 | 1349 | $this->header(array( |
1350 | - 'Content-Range' => 'bytes 0-' . $lastByte . '/' . $fileSize |
|
1350 | + 'Content-Range' => 'bytes 0-'.$lastByte.'/'.$fileSize |
|
1351 | 1351 | )); |
1352 | 1352 | return; |
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | $this->header(array( |
1356 | 1356 | 'Content-Length' => $end - $start + 1, |
1357 | - 'Content-Range' => 'bytes ' . $start . '-' . $end . '/' . $fileSize |
|
1357 | + 'Content-Range' => 'bytes '.$start.'-'.$end.'/'.$fileSize |
|
1358 | 1358 | )); |
1359 | 1359 | |
1360 | 1360 | $this->statusCode(206); |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | $bufferSize = 8192; |
1384 | 1384 | set_time_limit(0); |
1385 | 1385 | session_write_close(); |
1386 | - while (!feof($file->handle)) { |
|
1387 | - if (!$this->_isActive()) { |
|
1386 | + while ( ! feof($file->handle)) { |
|
1387 | + if ( ! $this->_isActive()) { |
|
1388 | 1388 | $file->close(); |
1389 | 1389 | return false; |
1390 | 1390 | } |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | $bufferSize = $end - $offset + 1; |
1397 | 1397 | } |
1398 | 1398 | echo fread($file->handle, $bufferSize); |
1399 | - if (!$compress) { |
|
1399 | + if ( ! $compress) { |
|
1400 | 1400 | $this->_flushBuffer(); |
1401 | 1401 | } |
1402 | 1402 | } |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | * @return boolean |
1411 | 1411 | */ |
1412 | 1412 | protected function _isActive() { |
1413 | - return connection_status() === CONNECTION_NORMAL && !connection_aborted(); |
|
1413 | + return connection_status() === CONNECTION_NORMAL && ! connection_aborted(); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
@@ -288,7 +288,7 @@ |
||
288 | 288 | * established. |
289 | 289 | * |
290 | 290 | * @param integer $length Optional buffer length to read; defaults to 1024 |
291 | - * @return mixed Socket data |
|
291 | + * @return false|string Socket data |
|
292 | 292 | */ |
293 | 293 | public function read($length = 1024) { |
294 | 294 | if (!$this->connected) { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function __construct($config = array()) { |
118 | 118 | $this->config = array_merge($this->_baseConfig, $config); |
119 | - if (!is_numeric($this->config['protocol'])) { |
|
119 | + if ( ! is_numeric($this->config['protocol'])) { |
|
120 | 120 | $this->config['protocol'] = getprotobyname($this->config['protocol']); |
121 | 121 | } |
122 | 122 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $scheme = 'ssl://'; |
138 | 138 | } |
139 | 139 | |
140 | - if (!empty($this->config['context'])) { |
|
140 | + if ( ! empty($this->config['context'])) { |
|
141 | 141 | $context = stream_context_create($this->config['context']); |
142 | 142 | } else { |
143 | 143 | $context = stream_context_create(); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | set_error_handler(array($this, '_connectionErrorHandler')); |
152 | 152 | $this->connection = stream_socket_client( |
153 | - $scheme . $this->config['host'] . ':' . $this->config['port'], |
|
153 | + $scheme.$this->config['host'].':'.$this->config['port'], |
|
154 | 154 | $errNum, |
155 | 155 | $errStr, |
156 | 156 | $this->config['timeout'], |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | ); |
160 | 160 | restore_error_handler(); |
161 | 161 | |
162 | - if (!empty($errNum) || !empty($errStr)) { |
|
162 | + if ( ! empty($errNum) || ! empty($errStr)) { |
|
163 | 163 | $this->setLastError($errNum, $errStr); |
164 | 164 | throw new SocketException($errStr, $errNum); |
165 | 165 | } |
166 | 166 | |
167 | - if (!$this->connection && $this->_connectionErrors) { |
|
167 | + if ( ! $this->connection && $this->_connectionErrors) { |
|
168 | 168 | $message = implode("\n", $this->_connectionErrors); |
169 | 169 | throw new SocketException($message, E_WARNING); |
170 | 170 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return null|array Null when there is no connection, an array when there is. |
197 | 197 | */ |
198 | 198 | public function context() { |
199 | - if (!$this->connection) { |
|
199 | + if ( ! $this->connection) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | return stream_context_get_options($this->connection); |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return string Last error |
245 | 245 | */ |
246 | 246 | public function lastError() { |
247 | - if (!empty($this->lastError)) { |
|
248 | - return $this->lastError['num'] . ': ' . $this->lastError['str']; |
|
247 | + if ( ! empty($this->lastError)) { |
|
248 | + return $this->lastError['num'].': '.$this->lastError['str']; |
|
249 | 249 | } |
250 | 250 | return null; |
251 | 251 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @return boolean Success |
269 | 269 | */ |
270 | 270 | public function write($data) { |
271 | - if (!$this->connected) { |
|
272 | - if (!$this->connect()) { |
|
271 | + if ( ! $this->connected) { |
|
272 | + if ( ! $this->connect()) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | } |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | * @return mixed Socket data |
292 | 292 | */ |
293 | 293 | public function read($length = 1024) { |
294 | - if (!$this->connected) { |
|
295 | - if (!$this->connect()) { |
|
294 | + if ( ! $this->connected) { |
|
295 | + if ( ! $this->connect()) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - if (!feof($this->connection)) { |
|
300 | + if ( ! feof($this->connection)) { |
|
301 | 301 | $buffer = fread($this->connection, $length); |
302 | 302 | $info = stream_get_meta_data($this->connection); |
303 | 303 | if ($info['timed_out']) { |
@@ -315,16 +315,16 @@ discard block |
||
315 | 315 | * @return boolean Success |
316 | 316 | */ |
317 | 317 | public function disconnect() { |
318 | - if (!is_resource($this->connection)) { |
|
318 | + if ( ! is_resource($this->connection)) { |
|
319 | 319 | $this->connected = false; |
320 | 320 | return true; |
321 | 321 | } |
322 | - $this->connected = !fclose($this->connection); |
|
322 | + $this->connected = ! fclose($this->connection); |
|
323 | 323 | |
324 | - if (!$this->connected) { |
|
324 | + if ( ! $this->connected) { |
|
325 | 325 | $this->connection = null; |
326 | 326 | } |
327 | - return !$this->connected; |
|
327 | + return ! $this->connected; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | * @see stream_socket_enable_crypto |
368 | 368 | */ |
369 | 369 | public function enableCrypto($type, $clientOrServer = 'client', $enable = true) { |
370 | - if (!array_key_exists($type . '_' . $clientOrServer, $this->_encryptMethods)) { |
|
370 | + if ( ! array_key_exists($type.'_'.$clientOrServer, $this->_encryptMethods)) { |
|
371 | 371 | throw new InvalidArgumentException(__d('cake_dev', 'Invalid encryption scheme chosen')); |
372 | 372 | } |
373 | 373 | $enableCryptoResult = false; |
374 | 374 | try { |
375 | - $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $this->_encryptMethods[$type . '_' . $clientOrServer]); |
|
375 | + $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $this->_encryptMethods[$type.'_'.$clientOrServer]); |
|
376 | 376 | } catch (Exception $e) { |
377 | 377 | $this->setLastError(null, $e->getMessage()); |
378 | 378 | throw new SocketException($e->getMessage()); |