@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | public function bindColumn($column, &$value, $dataType=null) |
64 | 64 | { |
65 | 65 | if($dataType===null) |
66 | - $this->_statement->bindColumn($column,$value); |
|
66 | + $this->_statement->bindColumn($column, $value); |
|
67 | 67 | else |
68 | - $this->_statement->bindColumn($column,$value,$dataType); |
|
68 | + $this->_statement->bindColumn($column, $value, $dataType); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function setFetchMode($mode) |
75 | 75 | { |
76 | 76 | $params=func_get_args(); |
77 | - call_user_func_array(array($this->_statement,'setFetchMode'),$params); |
|
77 | + call_user_func_array(array($this->_statement, 'setFetchMode'), $params); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created |
103 | 103 | * @return mixed|false the populated object, false if no more row of data available |
104 | 104 | */ |
105 | - public function readObject($className,$fields) |
|
105 | + public function readObject($className, $fields) |
|
106 | 106 | { |
107 | - return $this->_statement->fetchObject($className,$fields); |
|
107 | + return $this->_statement->fetchObject($className, $fields); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function rewind() |
173 | 173 | { |
174 | - if($this->_index<0) |
|
174 | + if($this->_index < 0) |
|
175 | 175 | { |
176 | 176 | $this->_row=$this->_statement->fetch(); |
177 | 177 | $this->_index=0; |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | public function __construct($condition=null, $parameters=array()) |
49 | 49 | { |
50 | 50 | if(!is_array($parameters) && func_num_args() > 1) |
51 | - $parameters = array_slice(func_get_args(),1); |
|
51 | + $parameters=array_slice(func_get_args(), 1); |
|
52 | 52 | $this->_parameters=new TAttributeCollection; |
53 | 53 | $this->_parameters->setCaseSensitive(true); |
54 | - $this->_parameters->copyFrom((array)$parameters); |
|
54 | + $this->_parameters->copyFrom((array) $parameters); |
|
55 | 55 | $this->_ordersBy=new TAttributeCollection; |
56 | 56 | $this->_ordersBy->setCaseSensitive(true); |
57 | 57 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function setSelect($value) |
111 | 111 | { |
112 | - $this->_select = $value; |
|
112 | + $this->_select=$value; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | { |
129 | 129 | if(empty($value)) { |
130 | 130 | // reset the condition |
131 | - $this->_condition = null; |
|
131 | + $this->_condition=null; |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | if(preg_match('/ORDER\s+BY\s+(.*?)(?=LIMIT)|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) { |
142 | 142 | // condition contains ORDER BY |
143 | - $value = str_replace($matches[0], '', $value); |
|
143 | + $value=str_replace($matches[0], '', $value); |
|
144 | 144 | if(strlen($matches[1]) > 0) { |
145 | 145 | $this->setOrdersBy($matches[1]); |
146 | 146 | } else if(strlen($matches[2]) > 0) { |
@@ -150,23 +150,23 @@ discard block |
||
150 | 150 | |
151 | 151 | if(preg_match('/LIMIT\s+([\d\s,]+)/i', $value, $matches) > 0) { |
152 | 152 | // condition contains limit |
153 | - $value = str_replace($matches[0], '', $value); // remove limit from query |
|
153 | + $value=str_replace($matches[0], '', $value); // remove limit from query |
|
154 | 154 | if(strpos($matches[1], ',')) { // both offset and limit given |
155 | - list($offset, $limit) = explode(',', $matches[1]); |
|
156 | - $this->_limit = (int)$limit; |
|
157 | - $this->_offset = (int)$offset; |
|
155 | + list($offset, $limit)=explode(',', $matches[1]); |
|
156 | + $this->_limit=(int) $limit; |
|
157 | + $this->_offset=(int) $offset; |
|
158 | 158 | } else { // only limit given |
159 | - $this->_limit = (int)$matches[1]; |
|
159 | + $this->_limit=(int) $matches[1]; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | if(preg_match('/OFFSET\s+(\d+)/i', $value, $matches) > 0) { |
164 | 164 | // condition contains offset |
165 | - $value = str_replace($matches[0], '', $value); // remove offset from query |
|
166 | - $this->_offset = (int)$matches[1]; // set offset in criteria |
|
165 | + $value=str_replace($matches[0], '', $value); // remove offset from query |
|
166 | + $this->_offset=(int) $matches[1]; // set offset in criteria |
|
167 | 167 | } |
168 | 168 | |
169 | - $this->_condition = trim($value); |
|
169 | + $this->_condition=trim($value); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | $this->_ordersBy->copyFrom($value); |
214 | 214 | else |
215 | 215 | { |
216 | - $value=trim(preg_replace('/\s+/',' ',(string)$value)); |
|
216 | + $value=trim(preg_replace('/\s+/', ' ', (string) $value)); |
|
217 | 217 | $orderBys=array(); |
218 | - foreach(explode(',',$value) as $orderBy) |
|
218 | + foreach(explode(',', $value) as $orderBy) |
|
219 | 219 | { |
220 | - $vs=explode(' ',trim($orderBy)); |
|
221 | - $orderBys[$vs[0]]=isset($vs[1])?$vs[1]:'asc'; |
|
220 | + $vs=explode(' ', trim($orderBy)); |
|
221 | + $orderBys[$vs[0]]=isset($vs[1]) ? $vs[1] : 'asc'; |
|
222 | 222 | } |
223 | 223 | $this->_ordersBy->copyFrom($orderBys); |
224 | 224 | } |
@@ -261,23 +261,23 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function __toString() |
263 | 263 | { |
264 | - $str = ''; |
|
265 | - if(strlen((string)$this->getCondition()) > 0) |
|
266 | - $str .= '"'.(string)$this->getCondition().'"'; |
|
267 | - $params = array(); |
|
264 | + $str=''; |
|
265 | + if(strlen((string) $this->getCondition()) > 0) |
|
266 | + $str.='"'.(string) $this->getCondition().'"'; |
|
267 | + $params=array(); |
|
268 | 268 | foreach($this->getParameters() as $k=>$v) |
269 | - $params[] = "{$k} => ${v}"; |
|
269 | + $params[]="{$k} => ${v}"; |
|
270 | 270 | if(count($params) > 0) |
271 | - $str .= ', "'.implode(', ',$params).'"'; |
|
272 | - $orders = array(); |
|
271 | + $str.=', "'.implode(', ', $params).'"'; |
|
272 | + $orders=array(); |
|
273 | 273 | foreach($this->getOrdersBy() as $k=>$v) |
274 | - $orders[] = "{$k} => ${v}"; |
|
274 | + $orders[]="{$k} => ${v}"; |
|
275 | 275 | if(count($orders) > 0) |
276 | - $str .= ', "'.implode(', ',$orders).'"'; |
|
277 | - if($this->_limit !==null) |
|
278 | - $str .= ', '.$this->_limit; |
|
279 | - if($this->_offset !== null) |
|
280 | - $str .= ', '.$this->_offset; |
|
276 | + $str.=', "'.implode(', ', $orders).'"'; |
|
277 | + if($this->_limit!==null) |
|
278 | + $str.=', '.$this->_limit; |
|
279 | + if($this->_offset!==null) |
|
280 | + $str.=', '.$this->_offset; |
|
281 | 281 | return $str; |
282 | 282 | } |
283 | 283 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string|TDbTableInfo table or view name or table information. |
88 | 88 | * @param TDbConnection database connection. |
89 | 89 | */ |
90 | - public function __construct($table,$connection) |
|
90 | + public function __construct($table, $connection) |
|
91 | 91 | { |
92 | 92 | $this->_connection=$connection; |
93 | 93 | if(is_string($table)) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function setTableInfo($tableInfo) |
105 | 105 | { |
106 | - $builder = $tableInfo->createCommandBuilder($this->getDbConnection()); |
|
106 | + $builder=$tableInfo->createCommandBuilder($this->getDbConnection()); |
|
107 | 107 | $this->initCommandBuilder($builder); |
108 | 108 | } |
109 | 109 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | protected function setTableName($tableName) |
115 | 115 | { |
116 | 116 | Prado::using('System.Data.Common.TDbMetaData'); |
117 | - $meta = TDbMetaData::getInstance($this->getDbConnection()); |
|
117 | + $meta=TDbMetaData::getInstance($this->getDbConnection()); |
|
118 | 118 | $this->initCommandBuilder($meta->createCommandBuilder($tableName)); |
119 | 119 | } |
120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function initCommandBuilder($builder) |
135 | 135 | { |
136 | - $this->_command = new TDataGatewayCommand($builder); |
|
137 | - $this->_command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
138 | - $this->_command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
136 | + $this->_command=new TDataGatewayCommand($builder); |
|
137 | + $this->_command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
138 | + $this->_command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function findBySql($sql, $parameters=array()) |
191 | 191 | { |
192 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
193 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
192 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
193 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
194 | 194 | return $this->getCommand()->findBySql($criteria); |
195 | 195 | } |
196 | 196 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function findAllBySql($sql, $parameters=array()) |
204 | 204 | { |
205 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
206 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
205 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
206 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
207 | 207 | return $this->getCommand()->findAllBySql($criteria); |
208 | 208 | } |
209 | 209 | |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function find($criteria, $parameters=array()) |
228 | 228 | { |
229 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
230 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
229 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
230 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
231 | 231 | return $this->getCommand()->find($criteria); |
232 | 232 | } |
233 | 233 | |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function findAll($criteria=null, $parameters=array()) |
241 | 241 | { |
242 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
242 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
243 | 243 | if($criteria!==null) |
244 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
244 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
245 | 245 | return $this->getCommand()->findAll($criteria); |
246 | 246 | } |
247 | 247 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | public function findByPk($keys) |
261 | 261 | { |
262 | 262 | if(func_num_args() > 1) |
263 | - $keys = func_get_args(); |
|
263 | + $keys=func_get_args(); |
|
264 | 264 | return $this->getCommand()->findByPk($keys); |
265 | 265 | } |
266 | 266 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | public function findAllByPks($keys) |
285 | 285 | { |
286 | 286 | if(func_num_args() > 1) |
287 | - $keys = func_get_args(); |
|
287 | + $keys=func_get_args(); |
|
288 | 288 | return $this->getCommand()->findAllByPk($keys); |
289 | 289 | } |
290 | 290 | |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function deleteAll($criteria, $parameters=array()) |
303 | 303 | { |
304 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
305 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
304 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
305 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
306 | 306 | return $this->getCommand()->delete($criteria); |
307 | 307 | } |
308 | 308 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public function deleteByPk($keys) |
333 | 333 | { |
334 | 334 | if(func_num_args() > 1) |
335 | - $keys = func_get_args(); |
|
335 | + $keys=func_get_args(); |
|
336 | 336 | return $this->getCommand()->deleteByPk($keys); |
337 | 337 | } |
338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | public function deleteAllByPks($keys) |
343 | 343 | { |
344 | 344 | if(func_num_args() > 1) |
345 | - $keys = func_get_args(); |
|
345 | + $keys=func_get_args(); |
|
346 | 346 | return $this->deleteByPk($keys); |
347 | 347 | } |
348 | 348 | |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | * @param mixed parameter values. |
353 | 353 | * @return int number of records. |
354 | 354 | */ |
355 | - public function count($criteria=null,$parameters=array()) |
|
355 | + public function count($criteria=null, $parameters=array()) |
|
356 | 356 | { |
357 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
357 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
358 | 358 | if($criteria!==null) |
359 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
359 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
360 | 360 | return $this->getCommand()->count($criteria); |
361 | 361 | } |
362 | 362 | |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function update($data, $criteria, $parameters=array()) |
378 | 378 | { |
379 | - $args = func_num_args() > 2 ? array_slice(func_get_args(),2) : null; |
|
380 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
379 | + $args=func_num_args() > 2 ? array_slice(func_get_args(), 2) : null; |
|
380 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
381 | 381 | return $this->getCommand()->update($data, $criteria); |
382 | 382 | } |
383 | 383 | |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | { |
415 | 415 | if(is_string($criteria)) |
416 | 416 | { |
417 | - $useArgs = !is_array($parameters) && is_array($args); |
|
418 | - return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
|
417 | + $useArgs=!is_array($parameters) && is_array($args); |
|
418 | + return new TSqlCriteria($criteria, $useArgs ? $args : $parameters); |
|
419 | 419 | } |
420 | 420 | else if($criteria instanceof TSqlCriteria) |
421 | 421 | return $criteria; |
@@ -452,21 +452,21 @@ discard block |
||
452 | 452 | * @return mixed single record if method name starts with "findBy", 0 or more records |
453 | 453 | * if method name starts with "findAllBy" |
454 | 454 | */ |
455 | - public function __call($method,$args) |
|
455 | + public function __call($method, $args) |
|
456 | 456 | { |
457 | - $delete =false; |
|
458 | - if($findOne = substr(strtolower($method),0,6)==='findby') |
|
459 | - $condition = $method[6]==='_' ? substr($method,7) : substr($method,6); |
|
460 | - else if(substr(strtolower($method),0,9)==='findallby') |
|
461 | - $condition = $method[9]==='_' ? substr($method,10) : substr($method,9); |
|
462 | - else if($delete = substr(strtolower($method),0,8)==='deleteby') |
|
463 | - $condition = $method[8]==='_' ? substr($method,9) : substr($method,8); |
|
464 | - else if($delete = substr(strtolower($method),0,11)==='deleteallby') |
|
465 | - $condition = $method[11]==='_' ? substr($method,12) : substr($method,11); |
|
457 | + $delete=false; |
|
458 | + if($findOne=substr(strtolower($method), 0, 6)==='findby') |
|
459 | + $condition=$method[6]==='_' ? substr($method, 7) : substr($method, 6); |
|
460 | + else if(substr(strtolower($method), 0, 9)==='findallby') |
|
461 | + $condition=$method[9]==='_' ? substr($method, 10) : substr($method, 9); |
|
462 | + else if($delete=substr(strtolower($method), 0, 8)==='deleteby') |
|
463 | + $condition=$method[8]==='_' ? substr($method, 9) : substr($method, 8); |
|
464 | + else if($delete=substr(strtolower($method), 0, 11)==='deleteallby') |
|
465 | + $condition=$method[11]==='_' ? substr($method, 12) : substr($method, 11); |
|
466 | 466 | else |
467 | 467 | return null; |
468 | 468 | |
469 | - $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
469 | + $criteria=$this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
470 | 470 | if($delete) |
471 | 471 | return $this->deleteAll($criteria); |
472 | 472 | else |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | if(!extension_loaded('apc')) |
57 | 57 | throw new TConfigurationException('apccache_extension_required'); |
58 | 58 | |
59 | - if(ini_get('apc.enabled') == false) |
|
59 | + if(ini_get('apc.enabled')==false) |
|
60 | 60 | throw new TConfigurationException('apccache_extension_not_enabled'); |
61 | 61 | |
62 | - if(substr(php_sapi_name(), 0, 3) === 'cli' and ini_get('apc.enable_cli') == false) |
|
62 | + if(substr(php_sapi_name(), 0, 3)==='cli' and ini_get('apc.enable_cli')==false) |
|
63 | 63 | throw new TConfigurationException('apccache_extension_not_enabled_cli'); |
64 | 64 | |
65 | 65 | parent::init($config); |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
86 | 86 | * @return boolean true if the value is successfully stored into cache, false otherwise |
87 | 87 | */ |
88 | - protected function setValue($key,$value,$expire) |
|
88 | + protected function setValue($key, $value, $expire) |
|
89 | 89 | { |
90 | - return apc_store($key,$value,$expire); |
|
90 | + return apc_store($key, $value, $expire); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
100 | 100 | * @return boolean true if the value is successfully stored into cache, false otherwise |
101 | 101 | */ |
102 | - protected function addValue($key,$value,$expire) |
|
102 | + protected function addValue($key, $value, $expire) |
|
103 | 103 | { |
104 | - return apc_add($key,$value,$expire); |
|
104 | + return apc_add($key, $value, $expire); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @var boolean controls the use of a persistent connection. Default to true. |
106 | 106 | */ |
107 | - private $_persistence = true; |
|
107 | + private $_persistence=true; |
|
108 | 108 | /** |
109 | 109 | * @var integer number of buckets to create for this server which in turn control its |
110 | 110 | * probability of it being selected. The probability is relative to the total weight |
111 | 111 | * of all servers. |
112 | 112 | */ |
113 | - private $_weight = 1; |
|
113 | + private $_weight=1; |
|
114 | 114 | |
115 | - private $_timeout = 360; |
|
115 | + private $_timeout=360; |
|
116 | 116 | |
117 | - private $_retryInterval = 15; |
|
117 | + private $_retryInterval=15; |
|
118 | 118 | /** |
119 | 119 | * @var integer Controls the minimum value length before attempting to compress automatically. |
120 | 120 | */ |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | private $_minSavings=0.0; |
127 | 127 | |
128 | - private $_status = true; |
|
128 | + private $_status=true; |
|
129 | 129 | |
130 | - private $_failureCallback = null; |
|
130 | + private $_failureCallback=null; |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -168,26 +168,26 @@ discard block |
||
168 | 168 | if(!extension_loaded('memcached') && $this->_useMemcached) |
169 | 169 | throw new TConfigurationException('memcached_extension_required'); |
170 | 170 | |
171 | - $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
|
171 | + $this->_cache=$this->_useMemcached ? new Memcached : new Memcache; |
|
172 | 172 | $this->loadConfig($config); |
173 | 173 | if(count($this->_servers)) |
174 | 174 | { |
175 | 175 | foreach($this->_servers as $server) |
176 | 176 | { |
177 | 177 | Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
178 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
179 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
180 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
178 | + if($this->_cache->addServer($server['Host'], $server['Port'], $server['Persistent'], |
|
179 | + $server['Weight'], $server['Timeout'], $server['RetryInterval'])===false) |
|
180 | + throw new TConfigurationException('memcache_connection_failed', $server['Host'], $server['Port']); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | else |
184 | 184 | { |
185 | 185 | Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
186 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
187 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
186 | + if($this->_cache->addServer($this->_host, $this->_port)===false) |
|
187 | + throw new TConfigurationException('memcache_connection_failed', $this->_host, $this->_port); |
|
188 | 188 | } |
189 | 189 | if($this->_threshold!==0) |
190 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
190 | + $this->_cache->setCompressThreshold($this->_threshold, $this->_minSavings); |
|
191 | 191 | $this->_initialized=true; |
192 | 192 | parent::init($config); |
193 | 193 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | throw new TConfigurationException('memcache_serverport_required'); |
211 | 211 | if(!is_numeric($port)) |
212 | 212 | throw new TConfigurationException('memcache_serverport_invalid'); |
213 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
214 | - $checks = array( |
|
213 | + $server=array('Host'=>$host, 'Port'=>$port, 'Weight'=>1, 'Timeout'=>1800, 'RetryInterval'=>15, 'Persistent'=>true); |
|
214 | + $checks=array( |
|
215 | 215 | 'Weight'=>'memcache_serverweight_invalid', |
216 | 216 | 'Timeout'=>'memcache_servertimeout_invalid', |
217 | 217 | 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | else if($value!==null) |
225 | 225 | throw new TConfigurationException($exception); |
226 | 226 | } |
227 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
227 | + $server['Persistent']=TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
228 | 228 | $this->_servers[]=$server; |
229 | 229 | } |
230 | 230 | } |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
351 | 351 | * @return boolean true if the value is successfully stored into cache, false otherwise |
352 | 352 | */ |
353 | - protected function setValue($key,$value,$expire) |
|
353 | + protected function setValue($key, $value, $expire) |
|
354 | 354 | { |
355 | 355 | if($this->_useMemcached) { |
356 | - return $this->_cache->set($key,$value,$expire); |
|
356 | + return $this->_cache->set($key, $value, $expire); |
|
357 | 357 | } else { |
358 | - return $this->_cache->set($key,$value,0,$expire); |
|
358 | + return $this->_cache->set($key, $value, 0, $expire); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
369 | 369 | * @return boolean true if the value is successfully stored into cache, false otherwise |
370 | 370 | */ |
371 | - protected function addValue($key,$value,$expire) |
|
371 | + protected function addValue($key, $value, $expire) |
|
372 | 372 | { |
373 | 373 | if($this->_useMemcached) { |
374 | - $this->_cache->add($key,$value,$expire); |
|
374 | + $this->_cache->add($key, $value, $expire); |
|
375 | 375 | } else { |
376 | - return $this->_cache->add($key,$value,0,$expire); |
|
376 | + return $this->_cache->add($key, $value, 0, $expire); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | if(!function_exists('xcache_isset')) |
53 | 53 | throw new TConfigurationException('xcache_extension_required'); |
54 | 54 | |
55 | - $enabled = (int)ini_get('xcache.cacher') !== 0; |
|
56 | - $var_size = (int)ini_get('xcache.var_size'); |
|
55 | + $enabled=(int) ini_get('xcache.cacher')!==0; |
|
56 | + $var_size=(int) ini_get('xcache.var_size'); |
|
57 | 57 | |
58 | 58 | if(!($enabled && $var_size > 0)) |
59 | 59 | throw new TConfigurationException('xcache_extension_not_enabled'); |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
82 | 82 | * @return boolean true if the value is successfully stored into cache, false otherwise |
83 | 83 | */ |
84 | - protected function setValue($key,$value,$expire) |
|
84 | + protected function setValue($key, $value, $expire) |
|
85 | 85 | { |
86 | - return xcache_set($key,$value,$expire); |
|
86 | + return xcache_set($key, $value, $expire); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
96 | 96 | * @return boolean true if the value is successfully stored into cache, false otherwise |
97 | 97 | */ |
98 | - protected function addValue($key,$value,$expire) |
|
98 | + protected function addValue($key, $value, $expire) |
|
99 | 99 | { |
100 | - return !xcache_isset($key) ? $this->setValue($key,$value,$expire) : false; |
|
100 | + return !xcache_isset($key) ? $this->setValue($key, $value, $expire) : false; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function flush() |
119 | 119 | { |
120 | - for($i=0, $max=xcache_count(XC_TYPE_VAR); $i<$max; $i++) |
|
120 | + for($i=0, $max=xcache_count(XC_TYPE_VAR); $i < $max; $i++) |
|
121 | 121 | { |
122 | 122 | if(xcache_clear_cache(XC_TYPE_VAR, $i)===false) |
123 | 123 | return false; |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | protected function __getZappableSleepProps(&$exprops) |
54 | 54 | { |
55 | 55 | parent::__getZappableSleepProps($exprops); |
56 | - if ($this->_caseSensitive===false) |
|
57 | - $exprops[] = "\0TAttributeCollection\0_caseSensitive"; |
|
56 | + if($this->_caseSensitive===false) |
|
57 | + $exprops[]="\0TAttributeCollection\0_caseSensitive"; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function __get($name) |
69 | 69 | { |
70 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
70 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param mixed the property value or event handler |
79 | 79 | * @throws TInvalidOperationException If the property is not defined or read-only. |
80 | 80 | */ |
81 | - public function __set($name,$value) |
|
81 | + public function __set($name, $value) |
|
82 | 82 | { |
83 | - $this->add($name,$value); |
|
83 | + $this->add($name, $value); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function itemAt($key) |
109 | 109 | { |
110 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
110 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * @param mixed key |
118 | 118 | * @param mixed value |
119 | 119 | */ |
120 | - public function add($key,$value) |
|
120 | + public function add($key, $value) |
|
121 | 121 | { |
122 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
122 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function remove($key) |
132 | 132 | { |
133 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
133 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function contains($key) |
143 | 143 | { |
144 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
144 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | public function createListItem($index=-1) |
39 | 39 | { |
40 | 40 | $item=$this->createNewListItem(); |
41 | - if($index<0) |
|
41 | + if($index < 0) |
|
42 | 42 | $this->add($item); |
43 | 43 | else |
44 | - $this->insertAt($index,$item); |
|
44 | + $this->insertAt($index, $item); |
|
45 | 45 | return $item; |
46 | 46 | } |
47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function createNewListItem($text=null) |
52 | 52 | { |
53 | - $item = new TListItem; |
|
53 | + $item=new TListItem; |
|
54 | 54 | if($text!==null) |
55 | 55 | $item->setText($text); |
56 | 56 | return $item; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * @param TListItem the item to be inserted. |
64 | 64 | * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem |
65 | 65 | */ |
66 | - public function insertAt($index,$item) |
|
66 | + public function insertAt($index, $item) |
|
67 | 67 | { |
68 | 68 | if(is_string($item)) |
69 | - $item = $this->createNewListItem($item); |
|
69 | + $item=$this->createNewListItem($item); |
|
70 | 70 | if(!($item instanceof TListItem)) |
71 | - throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this)); |
|
72 | - parent::insertAt($index,$item); |
|
71 | + throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this)); |
|
72 | + parent::insertAt($index, $item); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param boolean whether to look for disabled items also |
79 | 79 | * @return integer the index of the item found, -1 if not found. |
80 | 80 | */ |
81 | - public function findIndexByValue($value,$includeDisabled=true) |
|
81 | + public function findIndexByValue($value, $includeDisabled=true) |
|
82 | 82 | { |
83 | 83 | $value=TPropertyValue::ensureString($value); |
84 | 84 | $index=0; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param boolean whether to look for disabled items also |
98 | 98 | * @return integer the index of the item found, -1 if not found. |
99 | 99 | */ |
100 | - public function findIndexByText($text,$includeDisabled=true) |
|
100 | + public function findIndexByText($text, $includeDisabled=true) |
|
101 | 101 | { |
102 | 102 | $text=TPropertyValue::ensureString($text); |
103 | 103 | $index=0; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param boolean whether to look for disabled items also |
117 | 117 | * @return TListItem the item found, null if not found. |
118 | 118 | */ |
119 | - public function findItemByValue($value,$includeDisabled=true) |
|
119 | + public function findItemByValue($value, $includeDisabled=true) |
|
120 | 120 | { |
121 | - if(($index=$this->findIndexByValue($value,$includeDisabled))>=0) |
|
121 | + if(($index=$this->findIndexByValue($value, $includeDisabled)) >= 0) |
|
122 | 122 | return $this->itemAt($index); |
123 | 123 | else |
124 | 124 | return null; |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param boolean whether to look for disabled items also |
131 | 131 | * @return TListItem the item found, null if not found. |
132 | 132 | */ |
133 | - public function findItemByText($text,$includeDisabled=true) |
|
133 | + public function findItemByText($text, $includeDisabled=true) |
|
134 | 134 | { |
135 | - if(($index=$this->findIndexByText($text,$includeDisabled))>=0) |
|
135 | + if(($index=$this->findIndexByText($text, $includeDisabled)) >= 0) |
|
136 | 136 | return $this->itemAt($index); |
137 | 137 | else |
138 | 138 | return null; |
@@ -157,6 +157,6 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function saveState() |
159 | 159 | { |
160 | - return ($this->getCount()>0) ? $this->toArray() : null; |
|
160 | + return ($this->getCount() > 0) ? $this->toArray() : null; |
|
161 | 161 | } |
162 | 162 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
95 | 95 | * @return string URL to the asset path. |
96 | 96 | */ |
97 | - public function publishAsset($assetPath,$className=null) |
|
97 | + public function publishAsset($assetPath, $className=null) |
|
98 | 98 | { |
99 | 99 | if($className===null) |
100 | 100 | $className=get_class($this); |