@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * internal data storage |
| 41 | 41 | * @var array |
| 42 | 42 | */ |
| 43 | - private $_d = []; |
|
| 43 | + private $_d=[]; |
|
| 44 | 44 | /** |
| 45 | 45 | * number of items |
| 46 | 46 | * @var integer |
| 47 | 47 | */ |
| 48 | - private $_c = 0; |
|
| 48 | + private $_c=0; |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Constructor. |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @param array|Iterator the initial data. Default is null, meaning no initialization. |
| 54 | 54 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 55 | 55 | */ |
| 56 | - public function __construct($data = null) |
|
| 56 | + public function __construct($data=null) |
|
| 57 | 57 | { |
| 58 | - if($data !== null) |
|
| 58 | + if($data!==null) |
|
| 59 | 59 | $this->copyFrom($data); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | $this->clear(); |
| 81 | 81 | foreach($data as $item) |
| 82 | 82 | { |
| 83 | - $this->_d[] = $item; |
|
| 83 | + $this->_d[]=$item; |
|
| 84 | 84 | ++$this->_c; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - elseif($data !== null) |
|
| 87 | + elseif($data!==null) |
|
| 88 | 88 | throw new TInvalidDataTypeException('stack_data_not_iterable'); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function clear() |
| 95 | 95 | { |
| 96 | - $this->_c = 0; |
|
| 97 | - $this->_d = []; |
|
| 96 | + $this->_c=0; |
|
| 97 | + $this->_d=[]; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function contains($item) |
| 105 | 105 | { |
| 106 | - return array_search($item, $this->_d, true) !== false; |
|
| 106 | + return array_search($item, $this->_d, true)!==false; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function peek() |
| 116 | 116 | { |
| 117 | - if($this->_c === 0) |
|
| 117 | + if($this->_c===0) |
|
| 118 | 118 | throw new TInvalidOperationException('stack_empty'); |
| 119 | 119 | else |
| 120 | 120 | return $this->_d[$this->_c - 1]; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function pop() |
| 129 | 129 | { |
| 130 | - if($this->_c === 0) |
|
| 130 | + if($this->_c===0) |
|
| 131 | 131 | throw new TInvalidOperationException('stack_empty'); |
| 132 | 132 | else |
| 133 | 133 | { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function push($item) |
| 144 | 144 | { |
| 145 | 145 | ++$this->_c; |
| 146 | - $this->_d[] = $item; |
|
| 146 | + $this->_d[]=$item; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -65,15 +65,15 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * @var array internal data storage |
| 67 | 67 | */ |
| 68 | - private $_d = []; |
|
| 68 | + private $_d=[]; |
|
| 69 | 69 | /** |
| 70 | 70 | * @var boolean whether this list is read-only |
| 71 | 71 | */ |
| 72 | - private $_r = false; |
|
| 72 | + private $_r=false; |
|
| 73 | 73 | /** |
| 74 | 74 | * @var boolean indicates if the _d is currently ordered. |
| 75 | 75 | */ |
| 76 | - private $_o = false; |
|
| 76 | + private $_o=false; |
|
| 77 | 77 | /** |
| 78 | 78 | * @var array cached flattened internal data storage |
| 79 | 79 | */ |
@@ -81,15 +81,15 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @var integer number of items contain within the map |
| 83 | 83 | */ |
| 84 | - private $_c = 0; |
|
| 84 | + private $_c=0; |
|
| 85 | 85 | /** |
| 86 | 86 | * @var numeric the default priority of items without specified priorities |
| 87 | 87 | */ |
| 88 | - private $_dp = 10; |
|
| 88 | + private $_dp=10; |
|
| 89 | 89 | /** |
| 90 | 90 | * @var integer the precision of the numeric priorities within this priority list. |
| 91 | 91 | */ |
| 92 | - private $_p = 8; |
|
| 92 | + private $_p=8; |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * Constructor. |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | * @param integer the precision of the numeric priorities |
| 101 | 101 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 102 | 102 | */ |
| 103 | - public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8) |
|
| 103 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
| 104 | 104 | { |
| 105 | - if($data !== null) |
|
| 105 | + if($data!==null) |
|
| 106 | 106 | $this->copyFrom($data); |
| 107 | 107 | $this->setReadOnly($readOnly); |
| 108 | 108 | $this->setPrecision($precision); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | protected function setReadOnly($value) |
| 124 | 124 | { |
| 125 | - $this->_r = TPropertyValue::ensureBoolean($value); |
|
| 125 | + $this->_r=TPropertyValue::ensureBoolean($value); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function setDefaultPriority($value) |
| 141 | 141 | { |
| 142 | - $this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 142 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function setPrecision($value) |
| 158 | 158 | { |
| 159 | - $this->_p = TPropertyValue::ensureInteger($value); |
|
| 159 | + $this->_p=TPropertyValue::ensureInteger($value); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | protected function sortPriorities() { |
| 177 | 177 | if(!$this->_o) { |
| 178 | 178 | ksort($this->_d, SORT_NUMERIC); |
| 179 | - $this->_o = true; |
|
| 179 | + $this->_o=true; |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | return $this->_fd; |
| 190 | 190 | |
| 191 | 191 | $this->sortPriorities(); |
| 192 | - $this->_fd = []; |
|
| 192 | + $this->_fd=[]; |
|
| 193 | 193 | foreach($this->_d as $priority => $itemsatpriority) |
| 194 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
| 194 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
| 195 | 195 | return $this->_fd; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -219,11 +219,11 @@ discard block |
||
| 219 | 219 | * it will be set to the default {@link getDefaultPriority} |
| 220 | 220 | * @return integer the number of items in the map at the specified priority |
| 221 | 221 | */ |
| 222 | - public function getPriorityCount($priority = null) |
|
| 222 | + public function getPriorityCount($priority=null) |
|
| 223 | 223 | { |
| 224 | - if($priority === null) |
|
| 225 | - $priority = $this->getDefaultPriority(); |
|
| 226 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 224 | + if($priority===null) |
|
| 225 | + $priority=$this->getDefaultPriority(); |
|
| 226 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 227 | 227 | |
| 228 | 228 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
| 229 | 229 | return false; |
@@ -257,16 +257,16 @@ discard block |
||
| 257 | 257 | * and numeric is a specific priority. default: false, any priority. |
| 258 | 258 | * @return mixed the element at the offset, null if no element is found at the offset |
| 259 | 259 | */ |
| 260 | - public function itemAt($key, $priority = false) |
|
| 260 | + public function itemAt($key, $priority=false) |
|
| 261 | 261 | { |
| 262 | - if($priority === false){ |
|
| 263 | - $map = $this->flattenPriorities(); |
|
| 264 | - return isset($map[$key])?$map[$key]:null; |
|
| 262 | + if($priority===false) { |
|
| 263 | + $map=$this->flattenPriorities(); |
|
| 264 | + return isset($map[$key]) ? $map[$key] : null; |
|
| 265 | 265 | } else { |
| 266 | - if($priority === null) |
|
| 267 | - $priority = $this->getDefaultPriority(); |
|
| 268 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 269 | - return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null; |
|
| 266 | + if($priority===null) |
|
| 267 | + $priority=$this->getDefaultPriority(); |
|
| 268 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 269 | + return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key])) ? $this->_d[$priority][$key] : null; |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | * @param numeric|null the priority. default: null, filled in with the default priority numeric. |
| 278 | 278 | * @return numeric old priority of the item |
| 279 | 279 | */ |
| 280 | - public function setPriorityAt($key, $priority = null) |
|
| 280 | + public function setPriorityAt($key, $priority=null) |
|
| 281 | 281 | { |
| 282 | - if($priority === null) |
|
| 283 | - $priority = $this->getDefaultPriority(); |
|
| 284 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 282 | + if($priority===null) |
|
| 283 | + $priority=$this->getDefaultPriority(); |
|
| 284 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 285 | 285 | |
| 286 | - $oldpriority = $this->priorityAt($key); |
|
| 287 | - if($oldpriority !== false && $oldpriority != $priority) { |
|
| 288 | - $value = $this->remove($key, $oldpriority); |
|
| 286 | + $oldpriority=$this->priorityAt($key); |
|
| 287 | + if($oldpriority!==false && $oldpriority!=$priority) { |
|
| 288 | + $value=$this->remove($key, $oldpriority); |
|
| 289 | 289 | $this->add($key, $value, $priority); |
| 290 | 290 | } |
| 291 | 291 | return $oldpriority; |
@@ -296,13 +296,13 @@ discard block |
||
| 296 | 296 | * @param numeric priority of the items to get. Defaults to null, filled in with the default priority, if left blank. |
| 297 | 297 | * @return array all items at priority in index order, null if there are no items at that priority |
| 298 | 298 | */ |
| 299 | - public function itemsAtPriority($priority = null) |
|
| 299 | + public function itemsAtPriority($priority=null) |
|
| 300 | 300 | { |
| 301 | - if($priority === null) |
|
| 302 | - $priority = $this->getDefaultPriority(); |
|
| 303 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 301 | + if($priority===null) |
|
| 302 | + $priority=$this->getDefaultPriority(); |
|
| 303 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 304 | 304 | |
| 305 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
| 305 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | { |
| 315 | 315 | $this->sortPriorities(); |
| 316 | 316 | foreach($this->_d as $priority => $items) |
| 317 | - if(($index = array_search($item, $items, true)) !== false) |
|
| 317 | + if(($index=array_search($item, $items, true))!==false) |
|
| 318 | 318 | return $priority; |
| 319 | 319 | return false; |
| 320 | 320 | } |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | * @return numeric priority at which the pair was added |
| 347 | 347 | * @throws TInvalidOperationException if the map is read-only |
| 348 | 348 | */ |
| 349 | - public function add($key, $value, $priority = null) |
|
| 349 | + public function add($key, $value, $priority=null) |
|
| 350 | 350 | { |
| 351 | - if($priority === null) |
|
| 352 | - $priority = $this->getDefaultPriority(); |
|
| 353 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 351 | + if($priority===null) |
|
| 352 | + $priority=$this->getDefaultPriority(); |
|
| 353 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 354 | 354 | |
| 355 | 355 | if(!$this->_r) |
| 356 | 356 | { |
@@ -359,17 +359,17 @@ discard block |
||
| 359 | 359 | { |
| 360 | 360 | unset($this->_d[$innerpriority][$key]); |
| 361 | 361 | $this->_c--; |
| 362 | - if(count($this->_d[$innerpriority]) === 0) |
|
| 362 | + if(count($this->_d[$innerpriority])===0) |
|
| 363 | 363 | unset($this->_d[$innerpriority]); |
| 364 | 364 | } |
| 365 | 365 | if(!isset($this->_d[$priority])) { |
| 366 | - $this->_d[$priority] = [$key => $value]; |
|
| 367 | - $this->_o = false; |
|
| 366 | + $this->_d[$priority]=[$key => $value]; |
|
| 367 | + $this->_o=false; |
|
| 368 | 368 | } |
| 369 | 369 | else |
| 370 | - $this->_d[$priority][$key] = $value; |
|
| 370 | + $this->_d[$priority][$key]=$value; |
|
| 371 | 371 | $this->_c++; |
| 372 | - $this->_fd = null; |
|
| 372 | + $this->_fd=null; |
|
| 373 | 373 | } |
| 374 | 374 | else |
| 375 | 375 | throw new TInvalidOperationException('map_readonly', get_class($this)); |
@@ -388,45 +388,45 @@ discard block |
||
| 388 | 388 | * @return mixed the removed value, null if no such key exists. |
| 389 | 389 | * @throws TInvalidOperationException if the map is read-only |
| 390 | 390 | */ |
| 391 | - public function remove($key, $priority = false) |
|
| 391 | + public function remove($key, $priority=false) |
|
| 392 | 392 | { |
| 393 | 393 | if(!$this->_r) |
| 394 | 394 | { |
| 395 | - if($priority === null) |
|
| 396 | - $priority = $this->getDefaultPriority(); |
|
| 395 | + if($priority===null) |
|
| 396 | + $priority=$this->getDefaultPriority(); |
|
| 397 | 397 | |
| 398 | - if($priority === false) |
|
| 398 | + if($priority===false) |
|
| 399 | 399 | { |
| 400 | 400 | $this->sortPriorities(); |
| 401 | 401 | foreach($this->_d as $priority => $items) |
| 402 | 402 | if(array_key_exists($key, $items)) |
| 403 | 403 | { |
| 404 | - $value = $this->_d[$priority][$key]; |
|
| 404 | + $value=$this->_d[$priority][$key]; |
|
| 405 | 405 | unset($this->_d[$priority][$key]); |
| 406 | 406 | $this->_c--; |
| 407 | - if(count($this->_d[$priority]) === 0) |
|
| 407 | + if(count($this->_d[$priority])===0) |
|
| 408 | 408 | { |
| 409 | 409 | unset($this->_d[$priority]); |
| 410 | - $this->_o = false; |
|
| 410 | + $this->_o=false; |
|
| 411 | 411 | } |
| 412 | - $this->_fd = null; |
|
| 412 | + $this->_fd=null; |
|
| 413 | 413 | return $value; |
| 414 | 414 | } |
| 415 | 415 | return null; |
| 416 | 416 | } |
| 417 | 417 | else |
| 418 | 418 | { |
| 419 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 419 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 420 | 420 | if(isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority]))) |
| 421 | 421 | { |
| 422 | - $value = $this->_d[$priority][$key]; |
|
| 422 | + $value=$this->_d[$priority][$key]; |
|
| 423 | 423 | unset($this->_d[$priority][$key]); |
| 424 | 424 | $this->_c--; |
| 425 | - if(count($this->_d[$priority]) === 0) { |
|
| 425 | + if(count($this->_d[$priority])===0) { |
|
| 426 | 426 | unset($this->_d[$priority]); |
| 427 | - $this->_o = false; |
|
| 427 | + $this->_o=false; |
|
| 428 | 428 | } |
| 429 | - $this->_fd = null; |
|
| 429 | + $this->_fd=null; |
|
| 430 | 430 | return $value; |
| 431 | 431 | } |
| 432 | 432 | else |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | public function contains($key) |
| 455 | 455 | { |
| 456 | - $map = $this->flattenPriorities(); |
|
| 456 | + $map=$this->flattenPriorities(); |
|
| 457 | 457 | return isset($map[$key]) || array_key_exists($key, $map); |
| 458 | 458 | } |
| 459 | 459 | |
@@ -475,15 +475,15 @@ discard block |
||
| 475 | 475 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
| 476 | 476 | * The priorities are sorted so important priorities, lower numerics, are first. |
| 477 | 477 | */ |
| 478 | - public function toArrayBelowPriority($priority, $inclusive = false) |
|
| 478 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
| 479 | 479 | { |
| 480 | 480 | $this->sortPriorities(); |
| 481 | - $items = []; |
|
| 481 | + $items=[]; |
|
| 482 | 482 | foreach($this->_d as $itemspriority => $itemsatpriority) |
| 483 | 483 | { |
| 484 | 484 | if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
| 485 | 485 | break; |
| 486 | - $items = array_merge($items, $itemsatpriority); |
|
| 486 | + $items=array_merge($items, $itemsatpriority); |
|
| 487 | 487 | } |
| 488 | 488 | return $items; |
| 489 | 489 | } |
@@ -495,15 +495,15 @@ discard block |
||
| 495 | 495 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
| 496 | 496 | * The priorities are sorted so important priorities, lower numerics, are first. |
| 497 | 497 | */ |
| 498 | - public function toArrayAbovePriority($priority, $inclusive = true) |
|
| 498 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
| 499 | 499 | { |
| 500 | 500 | $this->sortPriorities(); |
| 501 | - $items = []; |
|
| 501 | + $items=[]; |
|
| 502 | 502 | foreach($this->_d as $itemspriority => $itemsatpriority) |
| 503 | 503 | { |
| 504 | 504 | if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
| 505 | 505 | continue; |
| 506 | - $items = array_merge($items, $itemsatpriority); |
|
| 506 | + $items=array_merge($items, $itemsatpriority); |
|
| 507 | 507 | } |
| 508 | 508 | return $items; |
| 509 | 509 | } |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | foreach($data as $key => $value) |
| 535 | 535 | $this->add($key, $value); |
| 536 | 536 | } |
| 537 | - elseif($data !== null) |
|
| 537 | + elseif($data!==null) |
|
| 538 | 538 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 539 | 539 | } |
| 540 | 540 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | foreach($data as $key => $value) |
| 561 | 561 | $this->add($key, $value); |
| 562 | 562 | } |
| 563 | - elseif($data !== null) |
|
| 563 | + elseif($data!==null) |
|
| 564 | 564 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 565 | 565 | } |
| 566 | 566 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | * If -1, the item will be appended to the end. |
| 36 | 36 | * @return TListItem list item object |
| 37 | 37 | */ |
| 38 | - public function createListItem($index = -1) |
|
| 38 | + public function createListItem($index=-1) |
|
| 39 | 39 | { |
| 40 | - $item = $this->createNewListItem(); |
|
| 40 | + $item=$this->createNewListItem(); |
|
| 41 | 41 | if($index < 0) |
| 42 | 42 | $this->add($item); |
| 43 | 43 | else |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * @return TListItem new item. |
| 50 | 50 | */ |
| 51 | - protected function createNewListItem($text = null) |
|
| 51 | + protected function createNewListItem($text=null) |
|
| 52 | 52 | { |
| 53 | - $item = new TListItem; |
|
| 54 | - if($text !== null) |
|
| 53 | + $item=new TListItem; |
|
| 54 | + if($text!==null) |
|
| 55 | 55 | $item->setText($text); |
| 56 | 56 | return $item; |
| 57 | 57 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 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 | 71 | throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this)); |
| 72 | 72 | parent::insertAt($index, $item); |
@@ -78,13 +78,13 @@ 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 | - $value = TPropertyValue::ensureString($value); |
|
| 84 | - $index = 0; |
|
| 83 | + $value=TPropertyValue::ensureString($value); |
|
| 84 | + $index=0; |
|
| 85 | 85 | foreach($this as $item) |
| 86 | 86 | { |
| 87 | - if($item->getValue() === $value && ($includeDisabled || $item->getEnabled())) |
|
| 87 | + if($item->getValue()===$value && ($includeDisabled || $item->getEnabled())) |
|
| 88 | 88 | return $index; |
| 89 | 89 | $index++; |
| 90 | 90 | } |
@@ -97,13 +97,13 @@ 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 | - $text = TPropertyValue::ensureString($text); |
|
| 103 | - $index = 0; |
|
| 102 | + $text=TPropertyValue::ensureString($text); |
|
| 103 | + $index=0; |
|
| 104 | 104 | foreach($this as $item) |
| 105 | 105 | { |
| 106 | - if($item->getText() === $text && ($includeDisabled || $item->getEnabled())) |
|
| 106 | + if($item->getText()===$text && ($includeDisabled || $item->getEnabled())) |
|
| 107 | 107 | return $index; |
| 108 | 108 | $index++; |
| 109 | 109 | } |
@@ -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; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | public function loadState($state) |
| 147 | 147 | { |
| 148 | 148 | $this->clear(); |
| 149 | - if($state !== null) |
|
| 149 | + if($state!==null) |
|
| 150 | 150 | $this->copyFrom($state); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct(TList $list, $startIndex, $count) |
| 40 | 40 | { |
| 41 | - $this->_list = $list; |
|
| 42 | - $this->_index = 0; |
|
| 43 | - $this->_startIndex = $startIndex; |
|
| 41 | + $this->_list=$list; |
|
| 42 | + $this->_index=0; |
|
| 43 | + $this->_startIndex=$startIndex; |
|
| 44 | 44 | if($startIndex + $count > $list->getCount()) |
| 45 | - $this->_count = $list->getCount() - $startIndex; |
|
| 45 | + $this->_count=$list->getCount() - $startIndex; |
|
| 46 | 46 | else |
| 47 | - $this->_count = $count; |
|
| 47 | + $this->_count=$count; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function rewind() |
| 55 | 55 | { |
| 56 | - $this->_index = 0; |
|
| 56 | + $this->_index=0; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -41,23 +41,23 @@ discard block |
||
| 41 | 41 | /** |
| 42 | 42 | * @var integer number of items in each page |
| 43 | 43 | */ |
| 44 | - private $_pageSize = 10; |
|
| 44 | + private $_pageSize=10; |
|
| 45 | 45 | /** |
| 46 | 46 | * @var integer current page index |
| 47 | 47 | */ |
| 48 | - private $_currentPageIndex = 0; |
|
| 48 | + private $_currentPageIndex=0; |
|
| 49 | 49 | /** |
| 50 | 50 | * @var boolean whether to allow paging |
| 51 | 51 | */ |
| 52 | - private $_allowPaging = false; |
|
| 52 | + private $_allowPaging=false; |
|
| 53 | 53 | /** |
| 54 | 54 | * @var boolean whether to allow custom paging |
| 55 | 55 | */ |
| 56 | - private $_allowCustomPaging = false; |
|
| 56 | + private $_allowCustomPaging=false; |
|
| 57 | 57 | /** |
| 58 | 58 | * @var integer user-assigned number of items in data source |
| 59 | 59 | */ |
| 60 | - private $_virtualCount = 0; |
|
| 60 | + private $_virtualCount=0; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @return mixed original data source. Defaults to null. |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | if(!($value instanceof TMap) && !($value instanceof TList)) |
| 76 | 76 | { |
| 77 | 77 | if(is_array($value)) |
| 78 | - $value = new TMap($value); |
|
| 78 | + $value=new TMap($value); |
|
| 79 | 79 | elseif($value instanceof \Traversable) |
| 80 | - $value = new TList($value); |
|
| 81 | - elseif($value !== null) |
|
| 80 | + $value=new TList($value); |
|
| 81 | + elseif($value!==null) |
|
| 82 | 82 | throw new TInvalidDataTypeException('pageddatasource_datasource_invalid'); |
| 83 | 83 | } |
| 84 | - $this->_dataSource = $value; |
|
| 84 | + $this->_dataSource=$value; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function setPageSize($value) |
| 99 | 99 | { |
| 100 | - if(($value = TPropertyValue::ensureInteger($value)) > 0) |
|
| 101 | - $this->_pageSize = $value; |
|
| 100 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
| 101 | + $this->_pageSize=$value; |
|
| 102 | 102 | else |
| 103 | 103 | throw new TInvalidDataValueException('pageddatasource_pagesize_invalid'); |
| 104 | 104 | } |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function setCurrentPageIndex($value) |
| 118 | 118 | { |
| 119 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
| 120 | - $value = 0; |
|
| 121 | - $this->_currentPageIndex = $value; |
|
| 119 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
| 120 | + $value=0; |
|
| 121 | + $this->_currentPageIndex=$value; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function setAllowPaging($value) |
| 136 | 136 | { |
| 137 | - $this->_allowPaging = TPropertyValue::ensureBoolean($value); |
|
| 137 | + $this->_allowPaging=TPropertyValue::ensureBoolean($value); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function setAllowCustomPaging($value) |
| 152 | 152 | { |
| 153 | - $this->_allowCustomPaging = TPropertyValue::ensureBoolean($value); |
|
| 153 | + $this->_allowCustomPaging=TPropertyValue::ensureBoolean($value); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function setVirtualItemCount($value) |
| 168 | 168 | { |
| 169 | - if(($value = TPropertyValue::ensureInteger($value)) >= 0) |
|
| 170 | - $this->_virtualCount = $value; |
|
| 169 | + if(($value=TPropertyValue::ensureInteger($value)) >= 0) |
|
| 170 | + $this->_virtualCount=$value; |
|
| 171 | 171 | else |
| 172 | 172 | throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid'); |
| 173 | 173 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function getCount() |
| 179 | 179 | { |
| 180 | - if($this->_dataSource === null) |
|
| 180 | + if($this->_dataSource===null) |
|
| 181 | 181 | return 0; |
| 182 | 182 | if(!$this->_allowPaging) |
| 183 | 183 | return $this->getDataSourceCount(); |
@@ -201,12 +201,12 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function getPageCount() |
| 203 | 203 | { |
| 204 | - if($this->_dataSource === null) |
|
| 204 | + if($this->_dataSource===null) |
|
| 205 | 205 | return 0; |
| 206 | - $count = $this->getDataSourceCount(); |
|
| 206 | + $count=$this->getDataSourceCount(); |
|
| 207 | 207 | if(!$this->_allowPaging || $count <= 0) |
| 208 | 208 | return 1; |
| 209 | - return (int)(($count + $this->_pageSize - 1) / $this->_pageSize); |
|
| 209 | + return (int) (($count + $this->_pageSize - 1) / $this->_pageSize); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | public function getIsFirstPage() |
| 216 | 216 | { |
| 217 | 217 | if($this->_allowPaging) |
| 218 | - return $this->_currentPageIndex === 0; |
|
| 218 | + return $this->_currentPageIndex===0; |
|
| 219 | 219 | else |
| 220 | 220 | return true; |
| 221 | 221 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | public function getIsLastPage() |
| 227 | 227 | { |
| 228 | 228 | if($this->_allowPaging) |
| 229 | - return $this->_currentPageIndex === $this->getPageCount() - 1; |
|
| 229 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
| 230 | 230 | else |
| 231 | 231 | return true; |
| 232 | 232 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function getFirstIndexInPage() |
| 239 | 239 | { |
| 240 | - if($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging) |
|
| 240 | + if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging) |
|
| 241 | 241 | return $this->_currentPageIndex * $this->_pageSize; |
| 242 | 242 | else |
| 243 | 243 | return 0; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function getDataSourceCount() |
| 250 | 250 | { |
| 251 | - if($this->_dataSource === null) |
|
| 251 | + if($this->_dataSource===null) |
|
| 252 | 252 | return 0; |
| 253 | 253 | elseif($this->_allowCustomPaging) |
| 254 | 254 | return $this->_virtualCount; |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @var array internal data storage |
| 59 | 59 | */ |
| 60 | - private $_d = []; |
|
| 60 | + private $_d=[]; |
|
| 61 | 61 | /** |
| 62 | 62 | * @var boolean indicates if the _d is currently ordered. |
| 63 | 63 | */ |
| 64 | - private $_o = false; |
|
| 64 | + private $_o=false; |
|
| 65 | 65 | /** |
| 66 | 66 | * @var array cached flattened internal data storage |
| 67 | 67 | */ |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | /** |
| 70 | 70 | * @var integer number of items contain within the list |
| 71 | 71 | */ |
| 72 | - private $_c = 0; |
|
| 72 | + private $_c=0; |
|
| 73 | 73 | /** |
| 74 | 74 | * @var numeric the default priority of items without specified priorities |
| 75 | 75 | */ |
| 76 | - private $_dp = 10; |
|
| 76 | + private $_dp=10; |
|
| 77 | 77 | /** |
| 78 | 78 | * @var integer the precision of the numeric priorities within this priority list. |
| 79 | 79 | */ |
| 80 | - private $_p = 8; |
|
| 80 | + private $_p=8; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Constructor. |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | * @param integer the precision of the numeric priorities |
| 89 | 89 | * @throws TInvalidDataTypeException If data is not null and is neither an array nor an iterator. |
| 90 | 90 | */ |
| 91 | - public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8) |
|
| 91 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
| 92 | 92 | { |
| 93 | 93 | parent::__construct(); |
| 94 | - if($data !== null) |
|
| 94 | + if($data!==null) |
|
| 95 | 95 | $this->copyFrom($data); |
| 96 | 96 | $this->setReadOnly($readOnly); |
| 97 | 97 | $this->setPrecision($precision); |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | * @param numeric optional priority at which to count items. if no parameter, it will be set to the default {@link getDefaultPriority} |
| 123 | 123 | * @return integer the number of items in the list at the specified priority |
| 124 | 124 | */ |
| 125 | - public function getPriorityCount($priority = null) |
|
| 125 | + public function getPriorityCount($priority=null) |
|
| 126 | 126 | { |
| 127 | - if($priority === null) |
|
| 128 | - $priority = $this->getDefaultPriority(); |
|
| 129 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 127 | + if($priority===null) |
|
| 128 | + $priority=$this->getDefaultPriority(); |
|
| 129 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 130 | 130 | |
| 131 | 131 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
| 132 | 132 | return false; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | protected function setDefaultPriority($value) |
| 149 | 149 | { |
| 150 | - $this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 150 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | protected function setPrecision($value) |
| 166 | 166 | { |
| 167 | - $this->_p = TPropertyValue::ensureInteger($value); |
|
| 167 | + $this->_p=TPropertyValue::ensureInteger($value); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | protected function sortPriorities() { |
| 195 | 195 | if(!$this->_o) { |
| 196 | 196 | ksort($this->_d, SORT_NUMERIC); |
| 197 | - $this->_o = true; |
|
| 197 | + $this->_o=true; |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | return $this->_fd; |
| 208 | 208 | |
| 209 | 209 | $this->sortPriorities(); |
| 210 | - $this->_fd = []; |
|
| 210 | + $this->_fd=[]; |
|
| 211 | 211 | foreach($this->_d as $priority => $itemsatpriority) |
| 212 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
| 212 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
| 213 | 213 | return $this->_fd; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | public function itemAt($index) |
| 225 | 225 | { |
| 226 | 226 | if($index >= 0 && $index < $this->getCount()) { |
| 227 | - $arr = $this->flattenPriorities(); |
|
| 227 | + $arr=$this->flattenPriorities(); |
|
| 228 | 228 | return $arr[$index]; |
| 229 | 229 | } else |
| 230 | 230 | throw new TInvalidDataValueException('list_index_invalid', $index); |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | * @param numeric priority of the items to get. Defaults to null, filled in with the default priority, if left blank. |
| 236 | 236 | * @return array all items at priority in index order, null if there are no items at that priority |
| 237 | 237 | */ |
| 238 | - public function itemsAtPriority($priority = null) |
|
| 238 | + public function itemsAtPriority($priority=null) |
|
| 239 | 239 | { |
| 240 | - if($priority === null) |
|
| 241 | - $priority = $this->getDefaultPriority(); |
|
| 242 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 240 | + if($priority===null) |
|
| 241 | + $priority=$this->getDefaultPriority(); |
|
| 242 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 243 | 243 | |
| 244 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
| 244 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * @param numeric the priority which to index. no parameter or null will result in the default priority |
| 251 | 251 | * @return mixed the element at the offset, false if no element is found at the offset |
| 252 | 252 | */ |
| 253 | - public function itemAtIndexInPriority($index, $priority = null) |
|
| 253 | + public function itemAtIndexInPriority($index, $priority=null) |
|
| 254 | 254 | { |
| 255 | - if($priority === null) |
|
| 256 | - $priority = $this->getDefaultPriority(); |
|
| 257 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 255 | + if($priority===null) |
|
| 256 | + $priority=$this->getDefaultPriority(); |
|
| 257 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 258 | 258 | |
| 259 | - return !isset($this->_d[$priority])?false:( |
|
| 260 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
| 259 | + return !isset($this->_d[$priority]) ?false:( |
|
| 260 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
| 261 | 261 | ); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @return int the index within the flattened array |
| 270 | 270 | * @throws TInvalidOperationException if the map is read-only |
| 271 | 271 | */ |
| 272 | - public function add($item, $priority = null) |
|
| 272 | + public function add($item, $priority=null) |
|
| 273 | 273 | { |
| 274 | 274 | if($this->getReadOnly()) |
| 275 | 275 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | if($this->getReadOnly()) |
| 291 | 291 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 292 | 292 | |
| 293 | - if(($priority = $this->priorityAt($index, true)) !== false) |
|
| 293 | + if(($priority=$this->priorityAt($index, true))!==false) |
|
| 294 | 294 | $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
| 295 | 295 | else |
| 296 | 296 | throw new TInvalidDataValueException('list_index_invalid', $index); |
@@ -306,56 +306,56 @@ discard block |
||
| 306 | 306 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
| 307 | 307 | * @throws TInvalidOperationException if the list is read-only |
| 308 | 308 | */ |
| 309 | - public function insertAtIndexInPriority($item, $index = false, $priority = null, $preserveCache = false) |
|
| 309 | + public function insertAtIndexInPriority($item, $index=false, $priority=null, $preserveCache=false) |
|
| 310 | 310 | { |
| 311 | 311 | if($this->getReadOnly()) |
| 312 | 312 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 313 | 313 | |
| 314 | - if($priority === null) |
|
| 315 | - $priority = $this->getDefaultPriority(); |
|
| 316 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 314 | + if($priority===null) |
|
| 315 | + $priority=$this->getDefaultPriority(); |
|
| 316 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 317 | 317 | |
| 318 | 318 | if($preserveCache) { |
| 319 | 319 | $this->sortPriorities(); |
| 320 | - $cc = 0; |
|
| 320 | + $cc=0; |
|
| 321 | 321 | foreach($this->_d as $prioritykey => $items) |
| 322 | 322 | if($prioritykey >= $priority) |
| 323 | 323 | break; |
| 324 | 324 | else |
| 325 | - $cc += count($items); |
|
| 325 | + $cc+=count($items); |
|
| 326 | 326 | |
| 327 | - if($index === false && isset($this->_d[$priority])) { |
|
| 328 | - $c = count($this->_d[$priority]); |
|
| 329 | - $c += $cc; |
|
| 330 | - $this->_d[$priority][] = $item; |
|
| 327 | + if($index===false && isset($this->_d[$priority])) { |
|
| 328 | + $c=count($this->_d[$priority]); |
|
| 329 | + $c+=$cc; |
|
| 330 | + $this->_d[$priority][]=$item; |
|
| 331 | 331 | } elseif(isset($this->_d[$priority])) { |
| 332 | - $c = $index + $cc; |
|
| 332 | + $c=$index + $cc; |
|
| 333 | 333 | array_splice($this->_d[$priority], $index, 0, [$item]); |
| 334 | 334 | } else { |
| 335 | - $c = $cc; |
|
| 336 | - $this->_o = false; |
|
| 337 | - $this->_d[$priority] = [$item]; |
|
| 335 | + $c=$cc; |
|
| 336 | + $this->_o=false; |
|
| 337 | + $this->_d[$priority]=[$item]; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache |
| 341 | 341 | array_splice($this->_fd, $c, 0, [$item]); |
| 342 | 342 | } else { |
| 343 | - $c = null; |
|
| 344 | - if($index === false && isset($this->_d[$priority])) { |
|
| 345 | - $cc = count($this->_d[$priority]); |
|
| 346 | - $this->_d[$priority][] = $item; |
|
| 343 | + $c=null; |
|
| 344 | + if($index===false && isset($this->_d[$priority])) { |
|
| 345 | + $cc=count($this->_d[$priority]); |
|
| 346 | + $this->_d[$priority][]=$item; |
|
| 347 | 347 | } elseif(isset($this->_d[$priority])) { |
| 348 | - $cc = $index; |
|
| 348 | + $cc=$index; |
|
| 349 | 349 | array_splice($this->_d[$priority], $index, 0, [$item]); |
| 350 | 350 | } else { |
| 351 | - $cc = 0; |
|
| 352 | - $this->_o = false; |
|
| 353 | - $this->_d[$priority] = [$item]; |
|
| 351 | + $cc=0; |
|
| 352 | + $this->_o=false; |
|
| 353 | + $this->_d[$priority]=[$item]; |
|
| 354 | 354 | } |
| 355 | - if($this->_fd && is_array($this->_fd) && count($this->_d) == 1) |
|
| 355 | + if($this->_fd && is_array($this->_fd) && count($this->_d)==1) |
|
| 356 | 356 | array_splice($this->_fd, $cc, 0, [$item]); |
| 357 | 357 | else |
| 358 | - $this->_fd = null; |
|
| 358 | + $this->_fd=null; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | $this->_c++; |
@@ -374,19 +374,19 @@ discard block |
||
| 374 | 374 | * @return integer index within the flattened list at which the item is being removed |
| 375 | 375 | * @throws TInvalidDataValueException If the item does not exist |
| 376 | 376 | */ |
| 377 | - public function remove($item, $priority = false) |
|
| 377 | + public function remove($item, $priority=false) |
|
| 378 | 378 | { |
| 379 | 379 | if($this->getReadOnly()) |
| 380 | 380 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 381 | 381 | |
| 382 | - if(($p = $this->priorityOf($item, true)) !== false) |
|
| 382 | + if(($p=$this->priorityOf($item, true))!==false) |
|
| 383 | 383 | { |
| 384 | - if($priority !== false) { |
|
| 385 | - if($priority === null) |
|
| 386 | - $priority = $this->getDefaultPriority(); |
|
| 387 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 384 | + if($priority!==false) { |
|
| 385 | + if($priority===null) |
|
| 386 | + $priority=$this->getDefaultPriority(); |
|
| 387 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 388 | 388 | |
| 389 | - if($p[0] != $priority) |
|
| 389 | + if($p[0]!=$priority) |
|
| 390 | 390 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 391 | 391 | } |
| 392 | 392 | $this->removeAtIndexInPriority($p[1], $p[0]); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | if($this->getReadOnly()) |
| 409 | 409 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 410 | 410 | |
| 411 | - if(($priority = $this->priorityAt($index, true)) !== false) |
|
| 411 | + if(($priority=$this->priorityAt($index, true))!==false) |
|
| 412 | 412 | return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
| 413 | 413 | throw new TInvalidDataValueException('list_index_invalid', $index); |
| 414 | 414 | } |
@@ -421,27 +421,27 @@ discard block |
||
| 421 | 421 | * @return mixed the removed item. |
| 422 | 422 | * @throws TInvalidDataValueException If the item does not exist |
| 423 | 423 | */ |
| 424 | - public function removeAtIndexInPriority($index, $priority = null) |
|
| 424 | + public function removeAtIndexInPriority($index, $priority=null) |
|
| 425 | 425 | { |
| 426 | 426 | if($this->getReadOnly()) |
| 427 | 427 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 428 | 428 | |
| 429 | - if($priority === null) |
|
| 430 | - $priority = $this->getDefaultPriority(); |
|
| 431 | - $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 429 | + if($priority===null) |
|
| 430 | + $priority=$this->getDefaultPriority(); |
|
| 431 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 432 | 432 | |
| 433 | 433 | if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
| 434 | 434 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 435 | 435 | |
| 436 | 436 | // $value is an array of elements removed, only one |
| 437 | - $value = array_splice($this->_d[$priority], $index, 1); |
|
| 438 | - $value = $value[0]; |
|
| 437 | + $value=array_splice($this->_d[$priority], $index, 1); |
|
| 438 | + $value=$value[0]; |
|
| 439 | 439 | |
| 440 | 440 | if(!count($this->_d[$priority])) |
| 441 | 441 | unset($this->_d[$priority]); |
| 442 | 442 | |
| 443 | 443 | $this->_c--; |
| 444 | - $this->_fd = null; |
|
| 444 | + $this->_fd=null; |
|
| 445 | 445 | return $value; |
| 446 | 446 | } |
| 447 | 447 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 455 | 455 | |
| 456 | 456 | foreach($this->_d as $priority => $items) { |
| 457 | - for($index = count($items) - 1;$index >= 0;$index--) |
|
| 457 | + for($index=count($items) - 1; $index >= 0; $index--) |
|
| 458 | 458 | $this->removeAtIndexInPriority($index, $priority); |
| 459 | 459 | unset($this->_d[$priority]); |
| 460 | 460 | } |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | */ |
| 476 | 476 | public function indexOf($item) |
| 477 | 477 | { |
| 478 | - if(($index = array_search($item, $this->flattenPriorities(), true)) === false) |
|
| 478 | + if(($index=array_search($item, $this->flattenPriorities(), true))===false) |
|
| 479 | 479 | return -1; |
| 480 | 480 | else |
| 481 | 481 | return $index; |
@@ -490,18 +490,18 @@ discard block |
||
| 490 | 490 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
| 491 | 491 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
| 492 | 492 | */ |
| 493 | - public function priorityOf($item, $withindex = false) |
|
| 493 | + public function priorityOf($item, $withindex=false) |
|
| 494 | 494 | { |
| 495 | 495 | $this->sortPriorities(); |
| 496 | 496 | |
| 497 | - $absindex = 0; |
|
| 497 | + $absindex=0; |
|
| 498 | 498 | foreach($this->_d as $priority => $items) { |
| 499 | - if(($index = array_search($item, $items, true)) !== false) { |
|
| 500 | - $absindex += $index; |
|
| 501 | - return $withindex?[$priority,$index,$absindex, |
|
| 502 | - 'priority' => $priority,'index' => $index,'absindex' => $absindex]:$priority; |
|
| 499 | + if(($index=array_search($item, $items, true))!==false) { |
|
| 500 | + $absindex+=$index; |
|
| 501 | + return $withindex ? [$priority, $index, $absindex, |
|
| 502 | + 'priority' => $priority, 'index' => $index, 'absindex' => $absindex] : $priority; |
|
| 503 | 503 | } else |
| 504 | - $absindex += count($items); |
|
| 504 | + $absindex+=count($items); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | return false; |
@@ -516,19 +516,19 @@ discard block |
||
| 516 | 516 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
| 517 | 517 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
| 518 | 518 | */ |
| 519 | - public function priorityAt($index, $withindex = false) |
|
| 519 | + public function priorityAt($index, $withindex=false) |
|
| 520 | 520 | { |
| 521 | 521 | if($index < 0 || $index >= $this->getCount()) |
| 522 | 522 | throw new TInvalidDataValueException('list_index_invalid', $index); |
| 523 | 523 | |
| 524 | - $absindex = $index; |
|
| 524 | + $absindex=$index; |
|
| 525 | 525 | $this->sortPriorities(); |
| 526 | 526 | foreach($this->_d as $priority => $items) { |
| 527 | - if($index >= ($c = count($items))) |
|
| 528 | - $index -= $c; |
|
| 527 | + if($index >= ($c=count($items))) |
|
| 528 | + $index-=$c; |
|
| 529 | 529 | else |
| 530 | - return $withindex?[$priority,$index,$absindex, |
|
| 531 | - 'priority' => $priority,'index' => $index,'absindex' => $absindex]:$priority; |
|
| 530 | + return $withindex ? [$priority, $index, $absindex, |
|
| 531 | + 'priority' => $priority, 'index' => $index, 'absindex' => $absindex] : $priority; |
|
| 532 | 532 | } |
| 533 | 533 | return false; |
| 534 | 534 | } |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | if($this->getReadOnly()) |
| 547 | 547 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 548 | 548 | |
| 549 | - if(($priority = $this->priorityOf($indexitem, true)) === false) |
|
| 549 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
| 550 | 550 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 551 | 551 | |
| 552 | 552 | $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | if($this->getReadOnly()) |
| 568 | 568 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
| 569 | 569 | |
| 570 | - if(($priority = $this->priorityOf($indexitem, true)) === false) |
|
| 570 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
| 571 | 571 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 572 | 572 | |
| 573 | 573 | $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
@@ -599,15 +599,15 @@ discard block |
||
| 599 | 599 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
| 600 | 600 | * The priorities are sorted so important priorities, lower numerics, are first. |
| 601 | 601 | */ |
| 602 | - public function toArrayBelowPriority($priority, $inclusive = false) |
|
| 602 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
| 603 | 603 | { |
| 604 | 604 | $this->sortPriorities(); |
| 605 | - $items = []; |
|
| 605 | + $items=[]; |
|
| 606 | 606 | foreach($this->_d as $itemspriority => $itemsatpriority) |
| 607 | 607 | { |
| 608 | 608 | if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
| 609 | 609 | break; |
| 610 | - $items = array_merge($items, $itemsatpriority); |
|
| 610 | + $items=array_merge($items, $itemsatpriority); |
|
| 611 | 611 | } |
| 612 | 612 | return $items; |
| 613 | 613 | } |
@@ -619,15 +619,15 @@ discard block |
||
| 619 | 619 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
| 620 | 620 | * The priorities are sorted so important priorities, lower numerics, are first. |
| 621 | 621 | */ |
| 622 | - public function toArrayAbovePriority($priority, $inclusive = true) |
|
| 622 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
| 623 | 623 | { |
| 624 | 624 | $this->sortPriorities(); |
| 625 | - $items = []; |
|
| 625 | + $items=[]; |
|
| 626 | 626 | foreach($this->_d as $itemspriority => $itemsatpriority) |
| 627 | 627 | { |
| 628 | 628 | if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
| 629 | 629 | continue; |
| 630 | - $items = array_merge($items, $itemsatpriority); |
|
| 630 | + $items=array_merge($items, $itemsatpriority); |
|
| 631 | 631 | } |
| 632 | 632 | return $items; |
| 633 | 633 | } |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | $this->clear(); |
| 656 | 656 | foreach($data as $key => $item) |
| 657 | 657 | $this->add($item); |
| 658 | - } elseif($data !== null) |
|
| 658 | + } elseif($data!==null) |
|
| 659 | 659 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 660 | 660 | } |
| 661 | 661 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $this->add($item); |
| 684 | 684 | |
| 685 | 685 | } |
| 686 | - elseif($data !== null) |
|
| 686 | + elseif($data!==null) |
|
| 687 | 687 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 688 | 688 | } |
| 689 | 689 | |
@@ -723,13 +723,13 @@ discard block |
||
| 723 | 723 | */ |
| 724 | 724 | public function offsetSet($offset, $item) |
| 725 | 725 | { |
| 726 | - if($offset === null) |
|
| 726 | + if($offset===null) |
|
| 727 | 727 | return $this->add($item); |
| 728 | - if($offset === $this->getCount()) { |
|
| 729 | - $priority = $this->priorityAt($offset - 1, true); |
|
| 728 | + if($offset===$this->getCount()) { |
|
| 729 | + $priority=$this->priorityAt($offset - 1, true); |
|
| 730 | 730 | $priority[1]++; |
| 731 | 731 | } else { |
| 732 | - $priority = $this->priorityAt($offset, true); |
|
| 732 | + $priority=$this->priorityAt($offset, true); |
|
| 733 | 733 | $this->removeAtIndexInPriority($priority[1], $priority[0]); |
| 734 | 734 | } |
| 735 | 735 | $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function __construct($oldPage) |
| 33 | 33 | { |
| 34 | - $this->_oldPage = $oldPage; |
|
| 34 | + $this->_oldPage=$oldPage; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -47,16 +47,16 @@ discard block |
||
| 47 | 47 | * internal data storage |
| 48 | 48 | * @var array |
| 49 | 49 | */ |
| 50 | - private $_d = []; |
|
| 50 | + private $_d=[]; |
|
| 51 | 51 | /** |
| 52 | 52 | * number of items |
| 53 | 53 | * @var integer |
| 54 | 54 | */ |
| 55 | - private $_c = 0; |
|
| 55 | + private $_c=0; |
|
| 56 | 56 | /** |
| 57 | 57 | * @var boolean whether this list is read-only |
| 58 | 58 | */ |
| 59 | - private $_r = false; |
|
| 59 | + private $_r=false; |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Constructor. |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @param boolean whether the list is read-only |
| 66 | 66 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 67 | 67 | */ |
| 68 | - public function __construct($data = null, $readOnly = false) |
|
| 68 | + public function __construct($data=null, $readOnly=false) |
|
| 69 | 69 | { |
| 70 | - if($data !== null) |
|
| 70 | + if($data!==null) |
|
| 71 | 71 | $this->copyFrom($data); |
| 72 | 72 | $this->setReadOnly($readOnly); |
| 73 | 73 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | protected function setReadOnly($value) |
| 87 | 87 | { |
| 88 | - $this->_r = TPropertyValue::ensureBoolean($value); |
|
| 88 | + $this->_r=TPropertyValue::ensureBoolean($value); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | if(!$this->_r) |
| 158 | 158 | { |
| 159 | - if($index === $this->_c) |
|
| 160 | - $this->_d[$this->_c++] = $item; |
|
| 159 | + if($index===$this->_c) |
|
| 160 | + $this->_d[$this->_c++]=$item; |
|
| 161 | 161 | elseif($index >= 0 && $index < $this->_c) |
| 162 | 162 | { |
| 163 | 163 | array_splice($this->_d, $index, 0, [$item]); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | if(!$this->_r) |
| 185 | 185 | { |
| 186 | - if(($index = $this->indexOf($item)) >= 0) |
|
| 186 | + if(($index=$this->indexOf($item)) >= 0) |
|
| 187 | 187 | { |
| 188 | 188 | $this->removeAt($index); |
| 189 | 189 | return $index; |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | if($index >= 0 && $index < $this->_c) |
| 210 | 210 | { |
| 211 | 211 | $this->_c--; |
| 212 | - if($index === $this->_c) |
|
| 212 | + if($index===$this->_c) |
|
| 213 | 213 | return array_pop($this->_d); |
| 214 | 214 | else |
| 215 | 215 | { |
| 216 | - $item = $this->_d[$index]; |
|
| 216 | + $item=$this->_d[$index]; |
|
| 217 | 217 | array_splice($this->_d, $index, 1); |
| 218 | 218 | return $item; |
| 219 | 219 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function clear() |
| 233 | 233 | { |
| 234 | - for($i = $this->_c - 1;$i >= 0;--$i) |
|
| 234 | + for($i=$this->_c - 1; $i >= 0; --$i) |
|
| 235 | 235 | $this->removeAt($i); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function indexOf($item) |
| 252 | 252 | { |
| 253 | - if(($index = array_search($item, $this->_d, true)) === false) |
|
| 253 | + if(($index=array_search($item, $this->_d, true))===false) |
|
| 254 | 254 | return -1; |
| 255 | 255 | else |
| 256 | 256 | return $index; |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | if(!$this->_r) |
| 271 | 271 | { |
| 272 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
| 272 | + if(($index=$this->indexOf($baseitem))==-1) |
|
| 273 | 273 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 274 | 274 | |
| 275 | 275 | $this->insertAt($index, $item); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | { |
| 294 | 294 | if(!$this->_r) |
| 295 | 295 | { |
| 296 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
| 296 | + if(($index=$this->indexOf($baseitem))==-1) |
|
| 297 | 297 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 298 | 298 | |
| 299 | 299 | $this->insertAt($index + 1, $item); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | foreach($data as $item) |
| 328 | 328 | $this->add($item); |
| 329 | 329 | } |
| 330 | - elseif($data !== null) |
|
| 330 | + elseif($data!==null) |
|
| 331 | 331 | throw new TInvalidDataTypeException('list_data_not_iterable'); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | foreach($data as $item) |
| 345 | 345 | $this->add($item); |
| 346 | 346 | } |
| 347 | - elseif($data !== null) |
|
| 347 | + elseif($data!==null) |
|
| 348 | 348 | throw new TInvalidDataTypeException('list_data_not_iterable'); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | public function offsetSet($offset, $item) |
| 381 | 381 | { |
| 382 | - if($offset === null || $offset === $this->_c) |
|
| 382 | + if($offset===null || $offset===$this->_c) |
|
| 383 | 383 | $this->insertAt($this->_c, $item); |
| 384 | 384 | else |
| 385 | 385 | { |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct($count) |
| 38 | 38 | { |
| 39 | - $this->_count = $count; |
|
| 39 | + $this->_count=$count; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |