@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @var boolean |
107 | 107 | */ |
108 | - private $_cacheInitialized = false; |
|
108 | + private $_cacheInitialized=false; |
|
109 | 109 | /** |
110 | 110 | * @var boolean |
111 | 111 | */ |
112 | - private $_createCheck= false; |
|
112 | + private $_createCheck=false; |
|
113 | 113 | /** |
114 | 114 | * @var boolean whether the cache DB table should be created automatically |
115 | 115 | */ |
@@ -183,20 +183,20 @@ discard block |
||
183 | 183 | $db=$this->getDbConnection(); |
184 | 184 | try |
185 | 185 | { |
186 | - $key = 'TDbCache:' . $this->_cacheTable . ':created'; |
|
186 | + $key='TDbCache:'.$this->_cacheTable.':created'; |
|
187 | 187 | if($force) |
188 | - $this -> _createCheck = false; |
|
188 | + $this -> _createCheck=false; |
|
189 | 189 | else |
190 | - $this -> _createCheck = $this -> getApplication() -> getGlobalState($key, 0); |
|
190 | + $this -> _createCheck=$this -> getApplication() -> getGlobalState($key, 0); |
|
191 | 191 | |
192 | 192 | if($this->_autoCreate && !$this -> _createCheck) { |
193 | 193 | |
194 | - Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ') . $this -> id . ', ' . $this->_cacheTable, 'System.Caching.TDbCache'); |
|
194 | + Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ').$this -> id.', '.$this->_cacheTable, 'System.Caching.TDbCache'); |
|
195 | 195 | |
196 | 196 | $sql='SELECT 1 FROM '.$this->_cacheTable.' WHERE 0=1'; |
197 | 197 | $db->createCommand($sql)->queryScalar(); |
198 | 198 | |
199 | - $this -> _createCheck = true; |
|
199 | + $this -> _createCheck=true; |
|
200 | 200 | $this -> getApplication() -> setGlobalState($key, time()); |
201 | 201 | } |
202 | 202 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // DB table not exists |
206 | 206 | if($this->_autoCreate) |
207 | 207 | { |
208 | - Prado::trace('Autocreate: ' . $this->_cacheTable, 'System.Caching.TDbCache'); |
|
208 | + Prado::trace('Autocreate: '.$this->_cacheTable, 'System.Caching.TDbCache'); |
|
209 | 209 | |
210 | 210 | $driver=$db->getDriverName(); |
211 | 211 | if($driver==='mysql') |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $sql='CREATE TABLE '.$this->_cacheTable." (itemkey CHAR(128) PRIMARY KEY, value $blob, expire INTEGER)"; |
219 | 219 | $db->createCommand($sql)->execute(); |
220 | 220 | |
221 | - $sql='CREATE INDEX IX_expire ON ' . $this->_cacheTable . ' (expire)'; |
|
221 | + $sql='CREATE INDEX IX_expire ON '.$this->_cacheTable.' (expire)'; |
|
222 | 222 | $db->createCommand($sql)->execute(); |
223 | 223 | |
224 | - $this -> _createCheck = true; |
|
224 | + $this -> _createCheck=true; |
|
225 | 225 | $this -> getApplication() -> setGlobalState($key, time()); |
226 | 226 | } |
227 | 227 | else |
228 | - throw new TConfigurationException('db_cachetable_inexistent',$this->_cacheTable); |
|
228 | + throw new TConfigurationException('db_cachetable_inexistent', $this->_cacheTable); |
|
229 | 229 | } |
230 | - $this->_cacheInitialized = true; |
|
230 | + $this->_cacheInitialized=true; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function flushCacheExpired($force=false) |
240 | 240 | { |
241 | - $interval = $this -> getFlushInterval(); |
|
242 | - if(!$force && $interval === 0) return; |
|
241 | + $interval=$this -> getFlushInterval(); |
|
242 | + if(!$force && $interval===0) return; |
|
243 | 243 | |
244 | - $key = 'TDbCache:' . $this->_cacheTable . ':flushed'; |
|
245 | - $now = time(); |
|
246 | - $next = $interval + (integer)$this -> getApplication() -> getGlobalState($key, 0); |
|
244 | + $key='TDbCache:'.$this->_cacheTable.':flushed'; |
|
245 | + $now=time(); |
|
246 | + $next=$interval + (integer) $this -> getApplication() -> getGlobalState($key, 0); |
|
247 | 247 | |
248 | 248 | if($force || $next <= $now) |
249 | 249 | { |
250 | 250 | if(!$this->_cacheInitialized) $this->initializeCache(); |
251 | - Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ') . $this -> id . ', ' . $this->_cacheTable, 'System.Caching.TDbCache'); |
|
251 | + Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ').$this -> id.', '.$this->_cacheTable, 'System.Caching.TDbCache'); |
|
252 | 252 | $sql='DELETE FROM '.$this->_cacheTable.' WHERE expire<>0 AND expire<'.$now; |
253 | 253 | $this->getDbConnection()->createCommand($sql)->execute(); |
254 | 254 | $this -> getApplication() -> setGlobalState($key, $now); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function setFlushInterval($value) |
277 | 277 | { |
278 | - $this->_flushInterval = (integer) $value; |
|
278 | + $this->_flushInterval=(integer) $value; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | if($config instanceof TDataSourceConfig) |
293 | 293 | return $config->getDbConnection(); |
294 | 294 | else |
295 | - throw new TConfigurationException('dbcache_connectionid_invalid',$this->_connID); |
|
295 | + throw new TConfigurationException('dbcache_connectionid_invalid', $this->_connID); |
|
296 | 296 | } |
297 | 297 | else |
298 | 298 | { |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
480 | 480 | * @return boolean true if the value is successfully stored into cache, false otherwise |
481 | 481 | */ |
482 | - protected function setValue($key,$value,$expire) |
|
482 | + protected function setValue($key, $value, $expire) |
|
483 | 483 | { |
484 | 484 | $this->deleteValue($key); |
485 | - return $this->addValue($key,$value,$expire); |
|
485 | + return $this->addValue($key, $value, $expire); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -494,16 +494,16 @@ discard block |
||
494 | 494 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
495 | 495 | * @return boolean true if the value is successfully stored into cache, false otherwise |
496 | 496 | */ |
497 | - protected function addValue($key,$value,$expire) |
|
497 | + protected function addValue($key, $value, $expire) |
|
498 | 498 | { |
499 | 499 | if(!$this->_cacheInitialized) $this->initializeCache(); |
500 | - $expire=($expire<=0)?0:time()+$expire; |
|
500 | + $expire=($expire <= 0) ? 0 : time() + $expire; |
|
501 | 501 | $sql="INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,$expire)"; |
502 | 502 | try |
503 | 503 | { |
504 | 504 | $command=$this->getDbConnection()->createCommand($sql); |
505 | - $command->bindValue(':key',$key,PDO::PARAM_STR); |
|
506 | - $command->bindValue(':value',serialize($value),PDO::PARAM_LOB); |
|
505 | + $command->bindValue(':key', $key, PDO::PARAM_STR); |
|
506 | + $command->bindValue(':value', serialize($value), PDO::PARAM_LOB); |
|
507 | 507 | $command->execute(); |
508 | 508 | return true; |
509 | 509 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | try |
535 | 535 | { |
536 | 536 | $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable} WHERE itemkey=:key"); |
537 | - $command->bindValue(':key',$key,PDO::PARAM_STR); |
|
537 | + $command->bindValue(':key', $key, PDO::PARAM_STR); |
|
538 | 538 | $command->execute(); |
539 | 539 | return true; |
540 | 540 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | if(!$this->_cacheInitialized) $this->initializeCache(); |
556 | 556 | try |
557 | 557 | { |
558 | - $command = $this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
558 | + $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
559 | 559 | $command->execute(); |
560 | 560 | } |
561 | 561 | catch(Exception $e) |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getHasElement() |
111 | 111 | { |
112 | - return $this->_elements!==null && $this->_elements->getCount()>0; |
|
112 | + return $this->_elements!==null && $this->_elements->getCount() > 0; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getHasAttribute() |
119 | 119 | { |
120 | - return $this->_attributes!==null && $this->_attributes->getCount()>0; |
|
120 | + return $this->_attributes!==null && $this->_attributes->getCount() > 0; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * @param string attribute name |
136 | 136 | * @param string attribute value |
137 | 137 | */ |
138 | - public function setAttribute($name,$value) |
|
138 | + public function setAttribute($name, $value) |
|
139 | 139 | { |
140 | - $this->getAttributes()->add($name,TPropertyValue::ensureString($value)); |
|
140 | + $this->getAttributes()->add($name, TPropertyValue::ensureString($value)); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | $attr.=" $name=\"$value\""; |
204 | 204 | } |
205 | 205 | } |
206 | - $prefix=str_repeat(' ',$indent*4); |
|
206 | + $prefix=str_repeat(' ', $indent * 4); |
|
207 | 207 | if($this->getHasElement()) |
208 | 208 | { |
209 | 209 | $str=$prefix."<{$this->_tagName}$attr>\n"; |
210 | 210 | foreach($this->getElements() as $element) |
211 | - $str.=$element->toString($indent+1)."\n"; |
|
211 | + $str.=$element->toString($indent + 1)."\n"; |
|
212 | 212 | $str.=$prefix."</{$this->_tagName}>"; |
213 | 213 | return $str; |
214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | private function xmlEncode($str) |
243 | 243 | { |
244 | - return strtr($str,array( |
|
244 | + return strtr($str, array( |
|
245 | 245 | '>'=>'>', |
246 | 246 | '<'=>'<', |
247 | 247 | '&'=>'&', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param string version of this XML document |
318 | 318 | * @param string encoding of this XML document |
319 | 319 | */ |
320 | - public function __construct($version='1.0',$encoding='') |
|
320 | + public function __construct($version='1.0', $encoding='') |
|
321 | 321 | { |
322 | 322 | parent::__construct(''); |
323 | 323 | $this->setVersion($version); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | if(($str=@file_get_contents($file))!==false) |
368 | 368 | return $this->loadFromString($str); |
369 | 369 | else |
370 | - throw new TIOException('xmldocument_file_read_failed',$file); |
|
370 | + throw new TIOException('xmldocument_file_read_failed', $file); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -395,17 +395,17 @@ discard block |
||
395 | 395 | $attributes->clear(); |
396 | 396 | |
397 | 397 | static $bSimpleXml; |
398 | - if($bSimpleXml === null) |
|
399 | - $bSimpleXml = (boolean)function_exists('simplexml_load_string'); |
|
398 | + if($bSimpleXml===null) |
|
399 | + $bSimpleXml=(boolean) function_exists('simplexml_load_string'); |
|
400 | 400 | |
401 | 401 | if($bSimpleXml) |
402 | 402 | { |
403 | - $simpleDoc = simplexml_load_string($string); |
|
404 | - $docNamespaces = $simpleDoc->getDocNamespaces(false); |
|
405 | - $simpleDoc = null; |
|
403 | + $simpleDoc=simplexml_load_string($string); |
|
404 | + $docNamespaces=$simpleDoc->getDocNamespaces(false); |
|
405 | + $simpleDoc=null; |
|
406 | 406 | foreach($docNamespaces as $prefix => $uri) |
407 | 407 | { |
408 | - if($prefix === '') |
|
408 | + if($prefix==='') |
|
409 | 409 | $attributes->add('xmlns', $uri); |
410 | 410 | else |
411 | 411 | $attributes->add('xmlns:'.$prefix, $uri); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | |
415 | 415 | foreach($element->attributes as $name=>$attr) |
416 | - $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
416 | + $attributes->add(($attr->prefix==='' ? '' : $attr->prefix.':').$name, $attr->value); |
|
417 | 417 | foreach($element->childNodes as $child) |
418 | 418 | { |
419 | 419 | if($child instanceof DOMElement) |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function saveToFile($file) |
432 | 432 | { |
433 | - if(($fw=fopen($file,'w'))!==false) |
|
433 | + if(($fw=fopen($file, 'w'))!==false) |
|
434 | 434 | { |
435 | - fwrite($fw,$this->saveToString()); |
|
435 | + fwrite($fw, $this->saveToString()); |
|
436 | 436 | fclose($fw); |
437 | 437 | } |
438 | 438 | else |
439 | - throw new TIOException('xmldocument_file_write_failed',$file); |
|
439 | + throw new TIOException('xmldocument_file_write_failed', $file); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function saveToString() |
447 | 447 | { |
448 | - $version=empty($this->_version)?' version="1.0"':' version="'.$this->_version.'"'; |
|
449 | - $encoding=empty($this->_encoding)?'':' encoding="'.$this->_encoding.'"'; |
|
448 | + $version=empty($this->_version) ? ' version="1.0"' : ' version="'.$this->_version.'"'; |
|
449 | + $encoding=empty($this->_encoding) ? '' : ' encoding="'.$this->_encoding.'"'; |
|
450 | 450 | return "<?xml{$version}{$encoding}?>\n".$this->toString(0); |
451 | 451 | } |
452 | 452 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | $element=new TXmlElement($node->tagName); |
481 | 481 | $element->setValue($node->nodeValue); |
482 | 482 | foreach($node->attributes as $name=>$attr) |
483 | - $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
483 | + $element->getAttributes()->add(($attr->prefix==='' ? '' : $attr->prefix.':').$name, $attr->value); |
|
484 | 484 | |
485 | 485 | foreach($node->childNodes as $child) |
486 | 486 | { |
@@ -534,11 +534,11 @@ discard block |
||
534 | 534 | * @param mixed new item |
535 | 535 | * @throws TInvalidDataTypeException if the item to be inserted is not a TXmlElement object. |
536 | 536 | */ |
537 | - public function insertAt($index,$item) |
|
537 | + public function insertAt($index, $item) |
|
538 | 538 | { |
539 | 539 | if($item instanceof TXmlElement) |
540 | 540 | { |
541 | - parent::insertAt($index,$item); |
|
541 | + parent::insertAt($index, $item); |
|
542 | 542 | if($item->getParent()!==null) |
543 | 543 | $item->getParent()->getElements()->remove($item); |
544 | 544 | $item->setParent($this->_o); |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @param array|Iterator the initial data. Default is null, meaning no initialization. |
78 | 78 | * @param boolean whether the list is read-only. Always true for paged list. |
79 | 79 | */ |
80 | - public function __construct($data=null,$readOnly=false) |
|
80 | + public function __construct($data=null, $readOnly=false) |
|
81 | 81 | { |
82 | - parent::__construct($data,true); |
|
82 | + parent::__construct($data, true); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setPageSize($value) |
113 | 113 | { |
114 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
114 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
115 | 115 | $this->_pageSize=$value; |
116 | 116 | else |
117 | 117 | throw new TInvalidDataValueException('pagedlist_pagesize_invalid'); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function onPageIndexChanged($param) |
144 | 144 | { |
145 | - $this->raiseEvent('OnPageIndexChanged',$this,$param); |
|
145 | + $this->raiseEvent('OnPageIndexChanged', $this, $param); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function onFetchData($param) |
156 | 156 | { |
157 | - $this->raiseEvent('OnFetchData',$this,$param); |
|
157 | + $this->raiseEvent('OnFetchData', $this, $param); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | return $pageIndex; |
169 | 169 | if($this->_customPaging) |
170 | 170 | { |
171 | - if($pageIndex>=0 && ($this->_virtualCount<0 || $pageIndex<$this->getPageCount())) |
|
171 | + if($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount())) |
|
172 | 172 | { |
173 | - $param=new TPagedListFetchDataEventParameter($pageIndex,$this->_pageSize*$pageIndex,$this->_pageSize); |
|
173 | + $param=new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize); |
|
174 | 174 | $this->onFetchData($param); |
175 | 175 | if(($data=$param->getData())!==null) |
176 | 176 | { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
193 | - if($pageIndex>=0 && $pageIndex<$this->getPageCount()) |
|
193 | + if($pageIndex >= 0 && $pageIndex < $this->getPageCount()) |
|
194 | 194 | { |
195 | 195 | $this->_currentPageIndex=$pageIndex; |
196 | 196 | $this->onPageIndexChanged(null); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function nextPage() |
209 | 209 | { |
210 | - return $this->gotoPage($this->_currentPageIndex+1); |
|
210 | + return $this->gotoPage($this->_currentPageIndex + 1); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function previousPage() |
218 | 218 | { |
219 | - return $this->gotoPage($this->_currentPageIndex-1); |
|
219 | + return $this->gotoPage($this->_currentPageIndex - 1); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function setVirtualCount($value) |
234 | 234 | { |
235 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
235 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
236 | 236 | $value=-1; |
237 | 237 | $this->_virtualCount=$value; |
238 | 238 | } |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | { |
245 | 245 | if($this->_customPaging) |
246 | 246 | { |
247 | - if($this->_virtualCount>=0) |
|
248 | - return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize); |
|
247 | + if($this->_virtualCount >= 0) |
|
248 | + return (int) (($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize); |
|
249 | 249 | else |
250 | 250 | return -1; |
251 | 251 | } |
252 | 252 | else |
253 | - return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize); |
|
253 | + return (int) ((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function getIsLastPage() |
268 | 268 | { |
269 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
269 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | return parent::getCount(); |
279 | 279 | else |
280 | 280 | { |
281 | - if($this->_currentPageIndex===$this->getPageCount()-1) |
|
282 | - return parent::getCount()-$this->_pageSize*$this->_currentPageIndex; |
|
281 | + if($this->_currentPageIndex===$this->getPageCount() - 1) |
|
282 | + return parent::getCount() - $this->_pageSize * $this->_currentPageIndex; |
|
283 | 283 | else |
284 | 284 | return $this->_pageSize; |
285 | 285 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | if($this->_customPaging) |
312 | 312 | return parent::itemAt($index); |
313 | 313 | else |
314 | - return parent::itemAt($this->_pageSize*$this->_currentPageIndex+$index); |
|
314 | + return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function indexOf($item) |
322 | 322 | { |
323 | 323 | $c=$this->getCount(); |
324 | - for($i=0;$i<$c;++$i) |
|
324 | + for($i=0; $i < $c; ++$i) |
|
325 | 325 | if($this->itemAt($i)===$item) |
326 | 326 | return $i; |
327 | 327 | return -1; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function offsetExists($offset) |
337 | 337 | { |
338 | - return ($offset>=0 && $offset<$this->getCount()); |
|
338 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | { |
358 | 358 | $c=$this->getCount(); |
359 | 359 | $array=array(); |
360 | - for($i=0;$i<$c;++$i) |
|
360 | + for($i=0; $i < $c; ++$i) |
|
361 | 361 | $array[$i]=$this->itemAt($i); |
362 | 362 | return $array; |
363 | 363 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @param integer offset of the first item in the new page |
424 | 424 | * @param integer number of items in the new page desired |
425 | 425 | */ |
426 | - public function __construct($pageIndex,$offset,$limit) |
|
426 | + public function __construct($pageIndex, $offset, $limit) |
|
427 | 427 | { |
428 | 428 | $this->_pageIndex=$pageIndex; |
429 | 429 | $this->_offset=$offset; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @package System.Collections |
31 | 31 | * @since 3.0 |
32 | 32 | */ |
33 | -class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
33 | +class TMap extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
34 | 34 | { |
35 | 35 | /** |
36 | 36 | * @var array internal data storage |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | protected function __getZappableSleepProps(&$exprops) |
51 | 51 | { |
52 | 52 | parent::__getZappableSleepProps($exprops); |
53 | - if ($this->_d===array()) |
|
54 | - $exprops[] = "\0TMap\0_d"; |
|
55 | - if ($this->_r===false) |
|
56 | - $exprops[] = "\0TMap\0_r"; |
|
53 | + if($this->_d===array()) |
|
54 | + $exprops[]="\0TMap\0_d"; |
|
55 | + if($this->_r===false) |
|
56 | + $exprops[]="\0TMap\0_r"; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param boolean whether the list is read-only |
64 | 64 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
65 | 65 | */ |
66 | - public function __construct($data=null,$readOnly=false) |
|
66 | + public function __construct($data=null, $readOnly=false) |
|
67 | 67 | { |
68 | 68 | if($data!==null) |
69 | 69 | $this->copyFrom($data); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getIterator() |
95 | 95 | { |
96 | - return new ArrayIterator( $this->_d ); |
|
96 | + return new ArrayIterator($this->_d); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | * @param mixed value |
141 | 141 | * @throws TInvalidOperationException if the map is read-only |
142 | 142 | */ |
143 | - public function add($key,$value) |
|
143 | + public function add($key, $value) |
|
144 | 144 | { |
145 | 145 | if(!$this->_r) |
146 | 146 | $this->_d[$key]=$value; |
147 | 147 | else |
148 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
148 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | if(!$this->_r) |
160 | 160 | { |
161 | - if(isset($this->_d[$key]) || array_key_exists($key,$this->_d)) |
|
161 | + if(isset($this->_d[$key]) || array_key_exists($key, $this->_d)) |
|
162 | 162 | { |
163 | 163 | $value=$this->_d[$key]; |
164 | 164 | unset($this->_d[$key]); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | else |
171 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
171 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function contains($key) |
188 | 188 | { |
189 | - return isset($this->_d[$key]) || array_key_exists($key,$this->_d); |
|
189 | + return isset($this->_d[$key]) || array_key_exists($key, $this->_d); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | { |
208 | 208 | if(is_array($data) || $data instanceof Traversable) |
209 | 209 | { |
210 | - if($this->getCount()>0) |
|
210 | + if($this->getCount() > 0) |
|
211 | 211 | $this->clear(); |
212 | 212 | foreach($data as $key=>$value) |
213 | - $this->add($key,$value); |
|
213 | + $this->add($key, $value); |
|
214 | 214 | } |
215 | 215 | else if($data!==null) |
216 | 216 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | if(is_array($data) || $data instanceof Traversable) |
228 | 228 | { |
229 | 229 | foreach($data as $key=>$value) |
230 | - $this->add($key,$value); |
|
230 | + $this->add($key, $value); |
|
231 | 231 | } |
232 | 232 | else if($data!==null) |
233 | 233 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * @param integer the offset to set element |
262 | 262 | * @param mixed the element value |
263 | 263 | */ |
264 | - public function offsetSet($offset,$item) |
|
264 | + public function offsetSet($offset, $item) |
|
265 | 265 | { |
266 | - $this->add($offset,$item); |
|
266 | + $this->add($offset, $item); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @package System.Collections |
33 | 33 | * @since 3.1 |
34 | 34 | */ |
35 | -class TQueue extends TComponent implements IteratorAggregate,Countable |
|
35 | +class TQueue extends TComponent implements IteratorAggregate, Countable |
|
36 | 36 | { |
37 | 37 | /** |
38 | 38 | * internal data storage |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function contains($item) |
103 | 103 | { |
104 | - return array_search($item,$this->_d,true)!==false; |
|
104 | + return array_search($item, $this->_d, true)!==false; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function enqueue($item) |
142 | 142 | { |
143 | 143 | ++$this->_c; |
144 | - $this->_d[] = $item; |
|
144 | + $this->_d[]=$item; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function getIterator() |
153 | 153 | { |
154 | - return new ArrayIterator( $this->_d ); |
|
154 | + return new ArrayIterator($this->_d); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function valid() |
259 | 259 | { |
260 | - return $this->_i<$this->_c; |
|
260 | + return $this->_i < $this->_c; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @package System.Collections |
35 | 35 | * @since 3.0 |
36 | 36 | */ |
37 | -class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
37 | +class TList extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
38 | 38 | { |
39 | 39 | /** |
40 | 40 | * internal data storage |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param boolean whether the list is read-only |
59 | 59 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
60 | 60 | */ |
61 | - public function __construct($data=null,$readOnly=false) |
|
61 | + public function __construct($data=null, $readOnly=false) |
|
62 | 62 | { |
63 | 63 | if($data!==null) |
64 | 64 | $this->copyFrom($data); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function getIterator() |
90 | 90 | { |
91 | - return new ArrayIterator( $this->_d ); |
|
91 | + return new ArrayIterator($this->_d); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function itemAt($index) |
120 | 120 | { |
121 | - if($index>=0 && $index<$this->_c) |
|
121 | + if($index >= 0 && $index < $this->_c) |
|
122 | 122 | return $this->_d[$index]; |
123 | 123 | else |
124 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
124 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function add($item) |
134 | 134 | { |
135 | - $this->insertAt($this->_c,$item); |
|
136 | - return $this->_c-1; |
|
135 | + $this->insertAt($this->_c, $item); |
|
136 | + return $this->_c - 1; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
146 | 146 | * @throws TInvalidOperationException if the list is read-only |
147 | 147 | */ |
148 | - public function insertAt($index,$item) |
|
148 | + public function insertAt($index, $item) |
|
149 | 149 | { |
150 | 150 | if(!$this->_r) |
151 | 151 | { |
152 | 152 | if($index===$this->_c) |
153 | 153 | $this->_d[$this->_c++]=$item; |
154 | - else if($index>=0 && $index<$this->_c) |
|
154 | + else if($index >= 0 && $index < $this->_c) |
|
155 | 155 | { |
156 | - array_splice($this->_d,$index,0,array($item)); |
|
156 | + array_splice($this->_d, $index, 0, array($item)); |
|
157 | 157 | $this->_c++; |
158 | 158 | } |
159 | 159 | else |
160 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
160 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
161 | 161 | } |
162 | 162 | else |
163 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
163 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | if(!$this->_r) |
178 | 178 | { |
179 | - if(($index=$this->indexOf($item))>=0) |
|
179 | + if(($index=$this->indexOf($item)) >= 0) |
|
180 | 180 | { |
181 | 181 | $this->removeAt($index); |
182 | 182 | return $index; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | throw new TInvalidDataValueException('list_item_inexistent'); |
186 | 186 | } |
187 | 187 | else |
188 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
188 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | if(!$this->_r) |
201 | 201 | { |
202 | - if($index>=0 && $index<$this->_c) |
|
202 | + if($index >= 0 && $index < $this->_c) |
|
203 | 203 | { |
204 | 204 | $this->_c--; |
205 | 205 | if($index===$this->_c) |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | else |
208 | 208 | { |
209 | 209 | $item=$this->_d[$index]; |
210 | - array_splice($this->_d,$index,1); |
|
210 | + array_splice($this->_d, $index, 1); |
|
211 | 211 | return $item; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | else |
215 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
215 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
216 | 216 | } |
217 | 217 | else |
218 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
218 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function clear() |
226 | 226 | { |
227 | - for($i=$this->_c-1;$i>=0;--$i) |
|
227 | + for($i=$this->_c - 1; $i >= 0; --$i) |
|
228 | 228 | $this->removeAt($i); |
229 | 229 | } |
230 | 230 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function contains($item) |
236 | 236 | { |
237 | - return $this->indexOf($item)>=0; |
|
237 | + return $this->indexOf($item) >= 0; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function indexOf($item) |
245 | 245 | { |
246 | - if(($index=array_search($item,$this->_d,true))===false) |
|
246 | + if(($index=array_search($item, $this->_d, true))===false) |
|
247 | 247 | return -1; |
248 | 248 | else |
249 | 249 | return $index; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | { |
263 | 263 | if(!$this->_r) |
264 | 264 | { |
265 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
265 | + if(($index=$this->indexOf($baseitem))==-1) |
|
266 | 266 | throw new TInvalidDataValueException('list_item_inexistent'); |
267 | 267 | |
268 | 268 | $this->insertAt($index, $item); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | return $index; |
271 | 271 | } |
272 | 272 | else |
273 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
273 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | { |
287 | 287 | if(!$this->_r) |
288 | 288 | { |
289 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
289 | + if(($index=$this->indexOf($baseitem))==-1) |
|
290 | 290 | throw new TInvalidDataValueException('list_item_inexistent'); |
291 | 291 | |
292 | 292 | $this->insertAt($index + 1, $item); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | return $index + 1; |
295 | 295 | } |
296 | 296 | else |
297 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
297 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | { |
316 | 316 | if(is_array($data) || ($data instanceof Traversable)) |
317 | 317 | { |
318 | - if($this->_c>0) |
|
318 | + if($this->_c > 0) |
|
319 | 319 | $this->clear(); |
320 | 320 | foreach($data as $item) |
321 | 321 | $this->add($item); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | public function offsetExists($offset) |
351 | 351 | { |
352 | - return ($offset>=0 && $offset<$this->_c); |
|
352 | + return ($offset >= 0 && $offset < $this->_c); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | * @param integer the offset to set item |
371 | 371 | * @param mixed the item value |
372 | 372 | */ |
373 | - public function offsetSet($offset,$item) |
|
373 | + public function offsetSet($offset, $item) |
|
374 | 374 | { |
375 | 375 | if($offset===null || $offset===$this->_c) |
376 | - $this->insertAt($this->_c,$item); |
|
376 | + $this->insertAt($this->_c, $item); |
|
377 | 377 | else |
378 | 378 | { |
379 | 379 | $this->removeAt($offset); |
380 | - $this->insertAt($offset,$item); |
|
380 | + $this->insertAt($offset, $item); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param integer the precision of the numeric priorities |
82 | 82 | * @throws TInvalidDataTypeException If data is not null and is neither an array nor an iterator. |
83 | 83 | */ |
84 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
84 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
85 | 85 | { |
86 | 86 | parent::__construct(); |
87 | 87 | if($data!==null) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | if($priority===null) |
121 | 121 | $priority=$this->getDefaultPriority(); |
122 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
122 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
123 | 123 | |
124 | 124 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
125 | 125 | return false; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function setDefaultPriority($value) |
142 | 142 | { |
143 | - $this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p); |
|
143 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function sortPriorities() { |
188 | 188 | if(!$this->_o) { |
189 | - ksort($this->_d,SORT_NUMERIC); |
|
189 | + ksort($this->_d, SORT_NUMERIC); |
|
190 | 190 | $this->_o=true; |
191 | 191 | } |
192 | 192 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $this->sortPriorities(); |
203 | 203 | $this->_fd=array(); |
204 | 204 | foreach($this->_d as $priority => $itemsatpriority) |
205 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
205 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
206 | 206 | return $this->_fd; |
207 | 207 | } |
208 | 208 | |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function itemAt($index) |
218 | 218 | { |
219 | - if($index>=0&&$index<$this->getCount()) { |
|
219 | + if($index >= 0 && $index < $this->getCount()) { |
|
220 | 220 | $arr=$this->flattenPriorities(); |
221 | 221 | return $arr[$index]; |
222 | 222 | } else |
223 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
223 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | { |
233 | 233 | if($priority===null) |
234 | 234 | $priority=$this->getDefaultPriority(); |
235 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
235 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
236 | 236 | |
237 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
237 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | * @param numeric the priority which to index. no parameter or null will result in the default priority |
244 | 244 | * @return mixed the element at the offset, false if no element is found at the offset |
245 | 245 | */ |
246 | - public function itemAtIndexInPriority($index,$priority=null) |
|
246 | + public function itemAtIndexInPriority($index, $priority=null) |
|
247 | 247 | { |
248 | 248 | if($priority===null) |
249 | 249 | $priority=$this->getDefaultPriority(); |
250 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
250 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
251 | 251 | |
252 | - return !isset($this->_d[$priority])?false:( |
|
253 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
252 | + return !isset($this->_d[$priority]) ? false : ( |
|
253 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | * @return int the index within the flattened array |
263 | 263 | * @throws TInvalidOperationException if the map is read-only |
264 | 264 | */ |
265 | - public function add($item,$priority=null) |
|
265 | + public function add($item, $priority=null) |
|
266 | 266 | { |
267 | 267 | if($this->getReadOnly()) |
268 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
268 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
269 | 269 | |
270 | - return $this->insertAtIndexInPriority($item,false,$priority,true); |
|
270 | + return $this->insertAtIndexInPriority($item, false, $priority, true); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
279 | 279 | * @throws TInvalidOperationException if the list is read-only |
280 | 280 | */ |
281 | - public function insertAt($index,$item) |
|
281 | + public function insertAt($index, $item) |
|
282 | 282 | { |
283 | 283 | if($this->getReadOnly()) |
284 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
284 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
285 | 285 | |
286 | - if(($priority=$this->priorityAt($index,true))!==false) |
|
287 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
286 | + if(($priority=$this->priorityAt($index, true))!==false) |
|
287 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
288 | 288 | else |
289 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
289 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -299,54 +299,54 @@ discard block |
||
299 | 299 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
300 | 300 | * @throws TInvalidOperationException if the list is read-only |
301 | 301 | */ |
302 | - public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false) |
|
302 | + public function insertAtIndexInPriority($item, $index=false, $priority=null, $preserveCache=false) |
|
303 | 303 | { |
304 | 304 | if($this->getReadOnly()) |
305 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
305 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
306 | 306 | |
307 | 307 | if($priority===null) |
308 | 308 | $priority=$this->getDefaultPriority(); |
309 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
309 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
310 | 310 | |
311 | 311 | if($preserveCache) { |
312 | 312 | $this->sortPriorities(); |
313 | 313 | $cc=0; |
314 | 314 | foreach($this->_d as $prioritykey=>$items) |
315 | - if($prioritykey>=$priority) |
|
315 | + if($prioritykey >= $priority) |
|
316 | 316 | break; |
317 | 317 | else |
318 | 318 | $cc+=count($items); |
319 | 319 | |
320 | - if($index===false&&isset($this->_d[$priority])) { |
|
320 | + if($index===false && isset($this->_d[$priority])) { |
|
321 | 321 | $c=count($this->_d[$priority]); |
322 | 322 | $c+=$cc; |
323 | 323 | $this->_d[$priority][]=$item; |
324 | 324 | } else if(isset($this->_d[$priority])) { |
325 | - $c=$index+$cc; |
|
326 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
325 | + $c=$index + $cc; |
|
326 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
327 | 327 | } else { |
328 | - $c = $cc; |
|
329 | - $this->_o = false; |
|
328 | + $c=$cc; |
|
329 | + $this->_o=false; |
|
330 | 330 | $this->_d[$priority]=array($item); |
331 | 331 | } |
332 | 332 | |
333 | - if($this->_fd&&is_array($this->_fd)) // if there is a flattened array cache |
|
334 | - array_splice($this->_fd,$c,0,array($item)); |
|
333 | + if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache |
|
334 | + array_splice($this->_fd, $c, 0, array($item)); |
|
335 | 335 | } else { |
336 | 336 | $c=null; |
337 | - if($index===false&&isset($this->_d[$priority])) { |
|
337 | + if($index===false && isset($this->_d[$priority])) { |
|
338 | 338 | $cc=count($this->_d[$priority]); |
339 | 339 | $this->_d[$priority][]=$item; |
340 | 340 | } else if(isset($this->_d[$priority])) { |
341 | 341 | $cc=$index; |
342 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
342 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
343 | 343 | } else { |
344 | 344 | $cc=0; |
345 | 345 | $this->_o=false; |
346 | 346 | $this->_d[$priority]=array($item); |
347 | 347 | } |
348 | - if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) |
|
349 | - array_splice($this->_fd,$cc,0,array($item)); |
|
348 | + if($this->_fd && is_array($this->_fd) && count($this->_d)==1) |
|
349 | + array_splice($this->_fd, $cc, 0, array($item)); |
|
350 | 350 | else |
351 | 351 | $this->_fd=null; |
352 | 352 | } |
@@ -367,22 +367,22 @@ discard block |
||
367 | 367 | * @return integer index within the flattened list at which the item is being removed |
368 | 368 | * @throws TInvalidDataValueException If the item does not exist |
369 | 369 | */ |
370 | - public function remove($item,$priority=false) |
|
370 | + public function remove($item, $priority=false) |
|
371 | 371 | { |
372 | 372 | if($this->getReadOnly()) |
373 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
373 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
374 | 374 | |
375 | - if(($p=$this->priorityOf($item,true))!==false) |
|
375 | + if(($p=$this->priorityOf($item, true))!==false) |
|
376 | 376 | { |
377 | 377 | if($priority!==false) { |
378 | 378 | if($priority===null) |
379 | 379 | $priority=$this->getDefaultPriority(); |
380 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
380 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
381 | 381 | |
382 | 382 | if($p[0]!=$priority) |
383 | 383 | throw new TInvalidDataValueException('list_item_inexistent'); |
384 | 384 | } |
385 | - $this->removeAtIndexInPriority($p[1],$p[0]); |
|
385 | + $this->removeAtIndexInPriority($p[1], $p[0]); |
|
386 | 386 | return $p[2]; |
387 | 387 | } |
388 | 388 | else |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | public function removeAt($index) |
400 | 400 | { |
401 | 401 | if($this->getReadOnly()) |
402 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
402 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
403 | 403 | |
404 | 404 | if(($priority=$this->priorityAt($index, true))!==false) |
405 | - return $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
406 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
405 | + return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
406 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | public function removeAtIndexInPriority($index, $priority=null) |
418 | 418 | { |
419 | 419 | if($this->getReadOnly()) |
420 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
420 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
421 | 421 | |
422 | 422 | if($priority===null) |
423 | 423 | $priority=$this->getDefaultPriority(); |
424 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
424 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
425 | 425 | |
426 | - if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) |
|
426 | + if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
|
427 | 427 | throw new TInvalidDataValueException('list_item_inexistent'); |
428 | 428 | |
429 | 429 | // $value is an array of elements removed, only one |
430 | - $value=array_splice($this->_d[$priority],$index,1); |
|
430 | + $value=array_splice($this->_d[$priority], $index, 1); |
|
431 | 431 | $value=$value[0]; |
432 | 432 | |
433 | 433 | if(!count($this->_d[$priority])) |
@@ -444,12 +444,12 @@ discard block |
||
444 | 444 | public function clear() |
445 | 445 | { |
446 | 446 | if($this->getReadOnly()) |
447 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
447 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
448 | 448 | |
449 | - $d=array_reverse($this->_d,true); |
|
449 | + $d=array_reverse($this->_d, true); |
|
450 | 450 | foreach($this->_d as $priority=>$items) { |
451 | - for($index=count($items)-1;$index>=0;$index--) |
|
452 | - $this->removeAtIndexInPriority($index,$priority); |
|
451 | + for($index=count($items) - 1; $index >= 0; $index--) |
|
452 | + $this->removeAtIndexInPriority($index, $priority); |
|
453 | 453 | unset($this->_d[$priority]); |
454 | 454 | } |
455 | 455 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | */ |
461 | 461 | public function contains($item) |
462 | 462 | { |
463 | - return $this->indexOf($item)>=0; |
|
463 | + return $this->indexOf($item) >= 0; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | public function indexOf($item) |
471 | 471 | { |
472 | - if(($index=array_search($item,$this->flattenPriorities(),true))===false) |
|
472 | + if(($index=array_search($item, $this->flattenPriorities(), true))===false) |
|
473 | 473 | return -1; |
474 | 474 | else |
475 | 475 | return $index; |
@@ -484,16 +484,16 @@ discard block |
||
484 | 484 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
485 | 485 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
486 | 486 | */ |
487 | - public function priorityOf($item,$withindex = false) |
|
487 | + public function priorityOf($item, $withindex=false) |
|
488 | 488 | { |
489 | 489 | $this->sortPriorities(); |
490 | 490 | |
491 | - $absindex = 0; |
|
491 | + $absindex=0; |
|
492 | 492 | foreach($this->_d as $priority=>$items) { |
493 | - if(($index=array_search($item,$items,true))!==false) { |
|
493 | + if(($index=array_search($item, $items, true))!==false) { |
|
494 | 494 | $absindex+=$index; |
495 | - return $withindex?array($priority,$index,$absindex, |
|
496 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
495 | + return $withindex ? array($priority, $index, $absindex, |
|
496 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
497 | 497 | } else |
498 | 498 | $absindex+=count($items); |
499 | 499 | } |
@@ -510,19 +510,19 @@ discard block |
||
510 | 510 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
511 | 511 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
512 | 512 | */ |
513 | - public function priorityAt($index,$withindex = false) |
|
513 | + public function priorityAt($index, $withindex=false) |
|
514 | 514 | { |
515 | - if($index<0||$index>=$this->getCount()) |
|
516 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
515 | + if($index < 0 || $index >= $this->getCount()) |
|
516 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
517 | 517 | |
518 | 518 | $absindex=$index; |
519 | 519 | $this->sortPriorities(); |
520 | 520 | foreach($this->_d as $priority=>$items) { |
521 | - if($index>=($c=count($items))) |
|
521 | + if($index >= ($c=count($items))) |
|
522 | 522 | $index-=$c; |
523 | 523 | else |
524 | - return $withindex?array($priority,$index,$absindex, |
|
525 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
524 | + return $withindex ? array($priority, $index, $absindex, |
|
525 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
526 | 526 | } |
527 | 527 | return false; |
528 | 528 | } |
@@ -538,12 +538,12 @@ discard block |
||
538 | 538 | public function insertBefore($indexitem, $item) |
539 | 539 | { |
540 | 540 | if($this->getReadOnly()) |
541 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
541 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
542 | 542 | |
543 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
543 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
544 | 544 | throw new TInvalidDataValueException('list_item_inexistent'); |
545 | 545 | |
546 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
546 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
547 | 547 | |
548 | 548 | return $priority[2]; |
549 | 549 | } |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | public function insertAfter($indexitem, $item) |
560 | 560 | { |
561 | 561 | if($this->getReadOnly()) |
562 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
562 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
563 | 563 | |
564 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
564 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
565 | 565 | throw new TInvalidDataValueException('list_item_inexistent'); |
566 | 566 | |
567 | - $this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]); |
|
567 | + $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
|
568 | 568 | |
569 | - return $priority[2]+1; |
|
569 | + return $priority[2] + 1; |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
@@ -593,15 +593,15 @@ discard block |
||
593 | 593 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
594 | 594 | * The priorities are sorted so important priorities, lower numerics, are first. |
595 | 595 | */ |
596 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
596 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
597 | 597 | { |
598 | 598 | $this->sortPriorities(); |
599 | 599 | $items=array(); |
600 | 600 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
601 | 601 | { |
602 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
602 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
603 | 603 | break; |
604 | - $items=array_merge($items,$itemsatpriority); |
|
604 | + $items=array_merge($items, $itemsatpriority); |
|
605 | 605 | } |
606 | 606 | return $items; |
607 | 607 | } |
@@ -613,15 +613,15 @@ discard block |
||
613 | 613 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
614 | 614 | * The priorities are sorted so important priorities, lower numerics, are first. |
615 | 615 | */ |
616 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
616 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
617 | 617 | { |
618 | 618 | $this->sortPriorities(); |
619 | 619 | $items=array(); |
620 | 620 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
621 | 621 | { |
622 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
622 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
623 | 623 | continue; |
624 | - $items=array_merge($items,$itemsatpriority); |
|
624 | + $items=array_merge($items, $itemsatpriority); |
|
625 | 625 | } |
626 | 626 | return $items; |
627 | 627 | } |
@@ -637,15 +637,15 @@ discard block |
||
637 | 637 | { |
638 | 638 | if($data instanceof TPriorityList) |
639 | 639 | { |
640 | - if($this->getCount()>0) |
|
640 | + if($this->getCount() > 0) |
|
641 | 641 | $this->clear(); |
642 | 642 | foreach($data->getPriorities() as $priority) |
643 | 643 | { |
644 | 644 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
645 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
645 | + $this->insertAtIndexInPriority($item, $index, $priority); |
|
646 | 646 | } |
647 | - } else if(is_array($data)||$data instanceof Traversable) { |
|
648 | - if($this->getCount()>0) |
|
647 | + } else if(is_array($data) || $data instanceof Traversable) { |
|
648 | + if($this->getCount() > 0) |
|
649 | 649 | $this->clear(); |
650 | 650 | foreach($data as $key=>$item) |
651 | 651 | $this->add($item); |
@@ -668,10 +668,10 @@ discard block |
||
668 | 668 | foreach($data->getPriorities() as $priority) |
669 | 669 | { |
670 | 670 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
671 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
671 | + $this->insertAtIndexInPriority($item, false, $priority); |
|
672 | 672 | } |
673 | 673 | } |
674 | - else if(is_array($data)||$data instanceof Traversable) |
|
674 | + else if(is_array($data) || $data instanceof Traversable) |
|
675 | 675 | { |
676 | 676 | foreach($data as $priority=>$item) |
677 | 677 | $this->add($item); |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | */ |
690 | 690 | public function offsetExists($offset) |
691 | 691 | { |
692 | - return ($offset>=0&&$offset<$this->getCount()); |
|
692 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
@@ -715,18 +715,18 @@ discard block |
||
715 | 715 | * @param integer the offset to set element |
716 | 716 | * @param mixed the element value |
717 | 717 | */ |
718 | - public function offsetSet($offset,$item) |
|
718 | + public function offsetSet($offset, $item) |
|
719 | 719 | { |
720 | 720 | if($offset===null) |
721 | 721 | return $this->add($item); |
722 | 722 | if($offset===$this->getCount()) { |
723 | - $priority=$this->priorityAt($offset-1,true); |
|
723 | + $priority=$this->priorityAt($offset - 1, true); |
|
724 | 724 | $priority[1]++; |
725 | 725 | } else { |
726 | - $priority=$this->priorityAt($offset,true); |
|
727 | - $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
726 | + $priority=$this->priorityAt($offset, true); |
|
727 | + $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
728 | 728 | } |
729 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
729 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @package System.Collections |
27 | 27 | * @since 3.0 |
28 | 28 | */ |
29 | -class TPagedDataSource extends TComponent implements IteratorAggregate,Countable |
|
29 | +class TPagedDataSource extends TComponent implements IteratorAggregate, Countable |
|
30 | 30 | { |
31 | 31 | /** |
32 | 32 | * @var mixed original data source |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function setPageSize($value) |
93 | 93 | { |
94 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
94 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
95 | 95 | $this->_pageSize=$value; |
96 | 96 | else |
97 | 97 | throw new TInvalidDataValueException('pageddatasource_pagesize_invalid'); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function setCurrentPageIndex($value) |
112 | 112 | { |
113 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
113 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
114 | 114 | $value=0; |
115 | 115 | $this->_currentPageIndex=$value; |
116 | 116 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function setVirtualItemCount($value) |
162 | 162 | { |
163 | - if(($value=TPropertyValue::ensureInteger($value))>=0) |
|
163 | + if(($value=TPropertyValue::ensureInteger($value)) >= 0) |
|
164 | 164 | $this->_virtualCount=$value; |
165 | 165 | else |
166 | 166 | throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid'); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if(!$this->_allowPaging) |
177 | 177 | return $this->getDataSourceCount(); |
178 | 178 | if(!$this->_allowCustomPaging && $this->getIsLastPage()) |
179 | - return $this->getDataSourceCount()-$this->getFirstIndexInPage(); |
|
179 | + return $this->getDataSourceCount() - $this->getFirstIndexInPage(); |
|
180 | 180 | return $this->_pageSize; |
181 | 181 | } |
182 | 182 | |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | if($this->_dataSource===null) |
199 | 199 | return 0; |
200 | 200 | $count=$this->getDataSourceCount(); |
201 | - if(!$this->_allowPaging || $count<=0) |
|
201 | + if(!$this->_allowPaging || $count <= 0) |
|
202 | 202 | return 1; |
203 | - return (int)(($count+$this->_pageSize-1)/$this->_pageSize); |
|
203 | + return (int) (($count + $this->_pageSize - 1) / $this->_pageSize); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public function getIsLastPage() |
221 | 221 | { |
222 | 222 | if($this->_allowPaging) |
223 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
223 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
224 | 224 | else |
225 | 225 | return true; |
226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function getFirstIndexInPage() |
233 | 233 | { |
234 | 234 | if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging) |
235 | - return $this->_currentPageIndex*$this->_pageSize; |
|
235 | + return $this->_currentPageIndex * $this->_pageSize; |
|
236 | 236 | else |
237 | 237 | return 0; |
238 | 238 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | public function getIterator() |
257 | 257 | { |
258 | 258 | if($this->_dataSource instanceof TList) |
259 | - return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
259 | + return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
260 | 260 | else if($this->_dataSource instanceof TMap) |
261 | - return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
261 | + return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
262 | 262 | else |
263 | 263 | return null; |
264 | 264 | } |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | * @param integer start index |
292 | 292 | * @param integer number of items to be iterated through |
293 | 293 | */ |
294 | - public function __construct(TList $list,$startIndex,$count) |
|
294 | + public function __construct(TList $list, $startIndex, $count) |
|
295 | 295 | { |
296 | 296 | $this->_list=$list; |
297 | 297 | $this->_index=0; |
298 | 298 | $this->_startIndex=$startIndex; |
299 | - if($startIndex+$count>$list->getCount()) |
|
300 | - $this->_count=$list->getCount()-$startIndex; |
|
299 | + if($startIndex + $count > $list->getCount()) |
|
300 | + $this->_count=$list->getCount() - $startIndex; |
|
301 | 301 | else |
302 | 302 | $this->_count=$count; |
303 | 303 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | public function current() |
330 | 330 | { |
331 | - return $this->_list->itemAt($this->_startIndex+$this->_index); |
|
331 | + return $this->_list->itemAt($this->_startIndex + $this->_index); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function valid() |
349 | 349 | { |
350 | - return $this->_index<$this->_count; |
|
350 | + return $this->_index < $this->_count; |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -375,13 +375,13 @@ discard block |
||
375 | 375 | * Constructor. |
376 | 376 | * @param array the data to be iterated through |
377 | 377 | */ |
378 | - public function __construct(TMap $map,$startIndex,$count) |
|
378 | + public function __construct(TMap $map, $startIndex, $count) |
|
379 | 379 | { |
380 | 380 | $this->_map=$map; |
381 | 381 | $this->_index=0; |
382 | 382 | $this->_startIndex=$startIndex; |
383 | - if($startIndex+$count>$map->getCount()) |
|
384 | - $this->_count=$map->getCount()-$startIndex; |
|
383 | + if($startIndex + $count > $map->getCount()) |
|
384 | + $this->_count=$map->getCount() - $startIndex; |
|
385 | 385 | else |
386 | 386 | $this->_count=$count; |
387 | 387 | $this->_iterator=$map->getIterator(); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | public function rewind() |
395 | 395 | { |
396 | 396 | $this->_iterator->rewind(); |
397 | - for($i=0;$i<$this->_startIndex;++$i) |
|
397 | + for($i=0; $i < $this->_startIndex; ++$i) |
|
398 | 398 | $this->_iterator->next(); |
399 | 399 | $this->_index=0; |
400 | 400 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | public function valid() |
438 | 438 | { |
439 | - return $this->_index<$this->_count; |
|
439 | + return $this->_index < $this->_count; |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 |
@@ -137,7 +137,7 @@ |
||
137 | 137 | */ |
138 | 138 | public function valid() |
139 | 139 | { |
140 | - return $this->_index<$this->_count; |
|
140 | + return $this->_index < $this->_count; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 |