@@ -50,27 +50,27 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @var array internal data storage |
| 52 | 52 | */ |
| 53 | - private $_d=array(); |
|
| 53 | + private $_d = array(); |
|
| 54 | 54 | /** |
| 55 | 55 | * @var boolean indicates if the _d is currently ordered. |
| 56 | 56 | */ |
| 57 | - private $_o=false; |
|
| 57 | + private $_o = false; |
|
| 58 | 58 | /** |
| 59 | 59 | * @var array cached flattened internal data storage |
| 60 | 60 | */ |
| 61 | - private $_fd=null; |
|
| 61 | + private $_fd = null; |
|
| 62 | 62 | /** |
| 63 | 63 | * @var integer number of items contain within the list |
| 64 | 64 | */ |
| 65 | - private $_c=0; |
|
| 65 | + private $_c = 0; |
|
| 66 | 66 | /** |
| 67 | 67 | * @var numeric the default priority of items without specified priorities |
| 68 | 68 | */ |
| 69 | - private $_dp=10; |
|
| 69 | + private $_dp = 10; |
|
| 70 | 70 | /** |
| 71 | 71 | * @var integer the precision of the numeric priorities within this priority list. |
| 72 | 72 | */ |
| 73 | - private $_p=8; |
|
| 73 | + private $_p = 8; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Constructor. |
@@ -81,10 +81,10 @@ 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 | - if($data!==null) |
|
| 87 | + if ($data !== null) |
|
| 88 | 88 | $this->copyFrom($data); |
| 89 | 89 | $this->setReadOnly($readOnly); |
| 90 | 90 | $this->setPrecision($precision); |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | * @param numeric optional priority at which to count items. if no parameter, it will be set to the default {@link getDefaultPriority} |
| 116 | 116 | * @return integer the number of items in the list at the specified priority |
| 117 | 117 | */ |
| 118 | - public function getPriorityCount($priority=null) |
|
| 118 | + public function getPriorityCount($priority = null) |
|
| 119 | 119 | { |
| 120 | - if($priority===null) |
|
| 121 | - $priority=$this->getDefaultPriority(); |
|
| 122 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 120 | + if ($priority === null) |
|
| 121 | + $priority = $this->getDefaultPriority(); |
|
| 122 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 123 | 123 | |
| 124 | - if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
| 124 | + if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
| 125 | 125 | return false; |
| 126 | 126 | return count($this->_d[$priority]); |
| 127 | 127 | } |
@@ -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 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function setPrecision($value) |
| 159 | 159 | { |
| 160 | - $this->_p=TPropertyValue::ensureInteger($value); |
|
| 160 | + $this->_p = TPropertyValue::ensureInteger($value); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * This orders the priority list internally. |
| 186 | 186 | */ |
| 187 | 187 | protected function sortPriorities() { |
| 188 | - if(!$this->_o) { |
|
| 189 | - ksort($this->_d,SORT_NUMERIC); |
|
| 190 | - $this->_o=true; |
|
| 188 | + if (!$this->_o) { |
|
| 189 | + ksort($this->_d, SORT_NUMERIC); |
|
| 190 | + $this->_o = true; |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | * @return array array of items in the list in priority and index order |
| 197 | 197 | */ |
| 198 | 198 | protected function flattenPriorities() { |
| 199 | - if(is_array($this->_fd)) |
|
| 199 | + if (is_array($this->_fd)) |
|
| 200 | 200 | return $this->_fd; |
| 201 | 201 | |
| 202 | 202 | $this->sortPriorities(); |
| 203 | - $this->_fd=array(); |
|
| 204 | - foreach($this->_d as $priority => $itemsatpriority) |
|
| 205 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
| 203 | + $this->_fd = array(); |
|
| 204 | + foreach ($this->_d as $priority => $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()) { |
|
| 220 | - $arr=$this->flattenPriorities(); |
|
| 219 | + if ($index >= 0 && $index < $this->getCount()) { |
|
| 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 | /** |
@@ -228,13 +228,13 @@ discard block |
||
| 228 | 228 | * @param numeric priority of the items to get. Defaults to null, filled in with the default priority, if left blank. |
| 229 | 229 | * @return array all items at priority in index order, null if there are no items at that priority |
| 230 | 230 | */ |
| 231 | - public function itemsAtPriority($priority=null) |
|
| 231 | + public function itemsAtPriority($priority = null) |
|
| 232 | 232 | { |
| 233 | - if($priority===null) |
|
| 234 | - $priority=$this->getDefaultPriority(); |
|
| 235 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 233 | + if ($priority === null) |
|
| 234 | + $priority = $this->getDefaultPriority(); |
|
| 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 | - if($priority===null) |
|
| 249 | - $priority=$this->getDefaultPriority(); |
|
| 250 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 248 | + if ($priority === null) |
|
| 249 | + $priority = $this->getDefaultPriority(); |
|
| 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 | - if($this->getReadOnly()) |
|
| 268 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 267 | + if ($this->getReadOnly()) |
|
| 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 | - if($this->getReadOnly()) |
|
| 284 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 283 | + if ($this->getReadOnly()) |
|
| 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,56 +299,56 @@ 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 | - if($this->getReadOnly()) |
|
| 305 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 304 | + if ($this->getReadOnly()) |
|
| 305 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 306 | 306 | |
| 307 | - if($priority===null) |
|
| 308 | - $priority=$this->getDefaultPriority(); |
|
| 309 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 307 | + if ($priority === null) |
|
| 308 | + $priority = $this->getDefaultPriority(); |
|
| 309 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 310 | 310 | |
| 311 | - if($preserveCache) { |
|
| 311 | + if ($preserveCache) { |
|
| 312 | 312 | $this->sortPriorities(); |
| 313 | - $cc=0; |
|
| 314 | - foreach($this->_d as $prioritykey=>$items) |
|
| 315 | - if($prioritykey>=$priority) |
|
| 313 | + $cc = 0; |
|
| 314 | + foreach ($this->_d as $prioritykey=>$items) |
|
| 315 | + if ($prioritykey >= $priority) |
|
| 316 | 316 | break; |
| 317 | 317 | else |
| 318 | - $cc+=count($items); |
|
| 319 | - |
|
| 320 | - if($index===false&&isset($this->_d[$priority])) { |
|
| 321 | - $c=count($this->_d[$priority]); |
|
| 322 | - $c+=$cc; |
|
| 323 | - $this->_d[$priority][]=$item; |
|
| 324 | - } else if(isset($this->_d[$priority])) { |
|
| 325 | - $c=$index+$cc; |
|
| 326 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
| 318 | + $cc += count($items); |
|
| 319 | + |
|
| 320 | + if ($index === false && isset($this->_d[$priority])) { |
|
| 321 | + $c = count($this->_d[$priority]); |
|
| 322 | + $c += $cc; |
|
| 323 | + $this->_d[$priority][] = $item; |
|
| 324 | + } else if (isset($this->_d[$priority])) { |
|
| 325 | + $c = $index + $cc; |
|
| 326 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
| 327 | 327 | } else { |
| 328 | 328 | $c = $cc; |
| 329 | 329 | $this->_o = false; |
| 330 | - $this->_d[$priority]=array($item); |
|
| 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 | - $c=null; |
|
| 337 | - if($index===false&&isset($this->_d[$priority])) { |
|
| 338 | - $cc=count($this->_d[$priority]); |
|
| 339 | - $this->_d[$priority][]=$item; |
|
| 340 | - } else if(isset($this->_d[$priority])) { |
|
| 341 | - $cc=$index; |
|
| 342 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
| 336 | + $c = null; |
|
| 337 | + if ($index === false && isset($this->_d[$priority])) { |
|
| 338 | + $cc = count($this->_d[$priority]); |
|
| 339 | + $this->_d[$priority][] = $item; |
|
| 340 | + } else if (isset($this->_d[$priority])) { |
|
| 341 | + $cc = $index; |
|
| 342 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
| 343 | 343 | } else { |
| 344 | - $cc=0; |
|
| 345 | - $this->_o=false; |
|
| 346 | - $this->_d[$priority]=array($item); |
|
| 344 | + $cc = 0; |
|
| 345 | + $this->_o = false; |
|
| 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 | - $this->_fd=null; |
|
| 351 | + $this->_fd = null; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | $this->_c++; |
@@ -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 | - if($this->getReadOnly()) |
|
| 373 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 372 | + if ($this->getReadOnly()) |
|
| 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 | - if($priority!==false) { |
|
| 378 | - if($priority===null) |
|
| 379 | - $priority=$this->getDefaultPriority(); |
|
| 380 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 377 | + if ($priority !== false) { |
|
| 378 | + if ($priority === null) |
|
| 379 | + $priority = $this->getDefaultPriority(); |
|
| 380 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 381 | 381 | |
| 382 | - if($p[0]!=$priority) |
|
| 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 |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function removeAt($index) |
| 400 | 400 | { |
| 401 | - if($this->getReadOnly()) |
|
| 402 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 401 | + if ($this->getReadOnly()) |
|
| 402 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 403 | 403 | |
| 404 | - if(($priority=$this->priorityAt($index, true))!==false) |
|
| 405 | - return $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
| 406 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 404 | + if (($priority = $this->priorityAt($index, true)) !== false) |
|
| 405 | + return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
| 406 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -414,27 +414,27 @@ discard block |
||
| 414 | 414 | * @return mixed the removed item. |
| 415 | 415 | * @throws TInvalidDataValueException If the item does not exist |
| 416 | 416 | */ |
| 417 | - public function removeAtIndexInPriority($index, $priority=null) |
|
| 417 | + public function removeAtIndexInPriority($index, $priority = null) |
|
| 418 | 418 | { |
| 419 | - if($this->getReadOnly()) |
|
| 420 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 419 | + if ($this->getReadOnly()) |
|
| 420 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 421 | 421 | |
| 422 | - if($priority===null) |
|
| 423 | - $priority=$this->getDefaultPriority(); |
|
| 424 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 422 | + if ($priority === null) |
|
| 423 | + $priority = $this->getDefaultPriority(); |
|
| 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); |
|
| 431 | - $value=$value[0]; |
|
| 430 | + $value = array_splice($this->_d[$priority], $index, 1); |
|
| 431 | + $value = $value[0]; |
|
| 432 | 432 | |
| 433 | - if(!count($this->_d[$priority])) |
|
| 433 | + if (!count($this->_d[$priority])) |
|
| 434 | 434 | unset($this->_d[$priority]); |
| 435 | 435 | |
| 436 | 436 | $this->_c--; |
| 437 | - $this->_fd=null; |
|
| 437 | + $this->_fd = null; |
|
| 438 | 438 | return $value; |
| 439 | 439 | } |
| 440 | 440 | |
@@ -443,13 +443,13 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function clear() |
| 445 | 445 | { |
| 446 | - if($this->getReadOnly()) |
|
| 447 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 446 | + if ($this->getReadOnly()) |
|
| 447 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 448 | 448 | |
| 449 | - $d=array_reverse($this->_d,true); |
|
| 450 | - foreach($this->_d as $priority=>$items) { |
|
| 451 | - for($index=count($items)-1;$index>=0;$index--) |
|
| 452 | - $this->removeAtIndexInPriority($index,$priority); |
|
| 449 | + $d = array_reverse($this->_d, true); |
|
| 450 | + foreach ($this->_d as $priority=>$items) { |
|
| 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,18 +484,18 @@ 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 | 491 | $absindex = 0; |
| 492 | - foreach($this->_d as $priority=>$items) { |
|
| 493 | - if(($index=array_search($item,$items,true))!==false) { |
|
| 494 | - $absindex+=$index; |
|
| 495 | - return $withindex?array($priority,$index,$absindex, |
|
| 496 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
| 492 | + foreach ($this->_d as $priority=>$items) { |
|
| 493 | + if (($index = array_search($item, $items, true)) !== false) { |
|
| 494 | + $absindex += $index; |
|
| 495 | + return $withindex ? array($priority, $index, $absindex, |
|
| 496 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
| 497 | 497 | } else |
| 498 | - $absindex+=count($items); |
|
| 498 | + $absindex += count($items); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | return false; |
@@ -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 | - $absindex=$index; |
|
| 518 | + $absindex = $index; |
|
| 519 | 519 | $this->sortPriorities(); |
| 520 | - foreach($this->_d as $priority=>$items) { |
|
| 521 | - if($index>=($c=count($items))) |
|
| 522 | - $index-=$c; |
|
| 520 | + foreach ($this->_d as $priority=>$items) { |
|
| 521 | + if ($index >= ($c = count($items))) |
|
| 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 | } |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | */ |
| 538 | 538 | public function insertBefore($indexitem, $item) |
| 539 | 539 | { |
| 540 | - if($this->getReadOnly()) |
|
| 541 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 540 | + if ($this->getReadOnly()) |
|
| 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 | } |
@@ -558,15 +558,15 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | public function insertAfter($indexitem, $item) |
| 560 | 560 | { |
| 561 | - if($this->getReadOnly()) |
|
| 562 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 561 | + if ($this->getReadOnly()) |
|
| 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 | - $items=array(); |
|
| 600 | - foreach($this->_d as $itemspriority=>$itemsatpriority) |
|
| 599 | + $items = array(); |
|
| 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 | - $items=array(); |
|
| 620 | - foreach($this->_d as $itemspriority=>$itemsatpriority) |
|
| 619 | + $items = array(); |
|
| 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 | } |
@@ -635,21 +635,21 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function copyFrom($data) |
| 637 | 637 | { |
| 638 | - if($data instanceof TPriorityList) |
|
| 638 | + if ($data instanceof TPriorityList) |
|
| 639 | 639 | { |
| 640 | - if($this->getCount()>0) |
|
| 640 | + if ($this->getCount() > 0) |
|
| 641 | 641 | $this->clear(); |
| 642 | - foreach($data->getPriorities() as $priority) |
|
| 642 | + foreach ($data->getPriorities() as $priority) |
|
| 643 | 643 | { |
| 644 | - foreach($data->itemsAtPriority($priority) as $index=>$item) |
|
| 645 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
| 644 | + foreach ($data->itemsAtPriority($priority) as $index=>$item) |
|
| 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 | - foreach($data as $key=>$item) |
|
| 650 | + foreach ($data as $key=>$item) |
|
| 651 | 651 | $this->add($item); |
| 652 | - } else if($data!==null) |
|
| 652 | + } else if ($data !== null) |
|
| 653 | 653 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 654 | 654 | } |
| 655 | 655 | |
@@ -663,21 +663,21 @@ discard block |
||
| 663 | 663 | */ |
| 664 | 664 | public function mergeWith($data) |
| 665 | 665 | { |
| 666 | - if($data instanceof TPriorityList) |
|
| 666 | + if ($data instanceof TPriorityList) |
|
| 667 | 667 | { |
| 668 | - foreach($data->getPriorities() as $priority) |
|
| 668 | + foreach ($data->getPriorities() as $priority) |
|
| 669 | 669 | { |
| 670 | - foreach($data->itemsAtPriority($priority) as $index=>$item) |
|
| 671 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
| 670 | + foreach ($data->itemsAtPriority($priority) as $index=>$item) |
|
| 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 | - foreach($data as $priority=>$item) |
|
| 676 | + foreach ($data as $priority=>$item) |
|
| 677 | 677 | $this->add($item); |
| 678 | 678 | |
| 679 | 679 | } |
| 680 | - else if($data!==null) |
|
| 680 | + else if ($data !== null) |
|
| 681 | 681 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 682 | 682 | } |
| 683 | 683 | |
@@ -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 | - if($offset===null) |
|
| 720 | + if ($offset === null) |
|
| 721 | 721 | return $this->add($item); |
| 722 | - if($offset===$this->getCount()) { |
|
| 723 | - $priority=$this->priorityAt($offset-1,true); |
|
| 722 | + if ($offset === $this->getCount()) { |
|
| 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 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | class TAttributeCollection extends TMap |
| 44 | 44 | { |
| 45 | - private $_caseSensitive=false; |
|
| 45 | + private $_caseSensitive = false; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Returns an array with the names of all variables of this object that should NOT be serialized |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | protected function __getZappableSleepProps(&$exprops) |
| 54 | 54 | { |
| 55 | 55 | parent::__getZappableSleepProps($exprops); |
| 56 | - if ($this->_caseSensitive===false) |
|
| 56 | + if ($this->_caseSensitive === false) |
|
| 57 | 57 | $exprops[] = "\0TAttributeCollection\0_caseSensitive"; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function __get($name) |
| 69 | 69 | { |
| 70 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
| 70 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | * @param mixed the property value or event handler |
| 79 | 79 | * @throws TInvalidOperationException If the property is not defined or read-only. |
| 80 | 80 | */ |
| 81 | - public function __set($name,$value) |
|
| 81 | + public function __set($name, $value) |
|
| 82 | 82 | { |
| 83 | - $this->add($name,$value); |
|
| 83 | + $this->add($name, $value); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function setCaseSensitive($value) |
| 98 | 98 | { |
| 99 | - $this->_caseSensitive=TPropertyValue::ensureBoolean($value); |
|
| 99 | + $this->_caseSensitive = TPropertyValue::ensureBoolean($value); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function itemAt($key) |
| 109 | 109 | { |
| 110 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
| 110 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | * @param mixed key |
| 118 | 118 | * @param mixed value |
| 119 | 119 | */ |
| 120 | - public function add($key,$value) |
|
| 120 | + public function add($key, $value) |
|
| 121 | 121 | { |
| 122 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
| 122 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function remove($key) |
| 132 | 132 | { |
| 133 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
| 133 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function contains($key) |
| 143 | 143 | { |
| 144 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
| 144 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct($count) |
| 36 | 36 | { |
| 37 | - $this->_count=$count; |
|
| 37 | + $this->_count = $count; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function __construct($count) |
| 90 | 90 | { |
| 91 | - $this->_count=$count; |
|
| 92 | - $this->_index=0; |
|
| 91 | + $this->_count = $count; |
|
| 92 | + $this->_index = 0; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function rewind() |
| 100 | 100 | { |
| 101 | - $this->_index=0; |
|
| 101 | + $this->_index = 0; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 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 | |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | public function setID($value) |
| 50 | 50 | { |
| 51 | - $this->_id=$value; |
|
| 51 | + $this->_id = $value; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | private $outputMessage; |
| 46 | 46 | |
| 47 | - public function __construct($name, $doc='') |
|
| 47 | + public function __construct($name, $doc = '') |
|
| 48 | 48 | { |
| 49 | 49 | $this->operationName = $name; |
| 50 | 50 | $this->documentation = $doc; |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $documentation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:documentation', htmlentities($this->documentation)); |
| 89 | 89 | $input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input'); |
| 90 | - $input->setAttribute('message', 'tns:'.$this->inputMessage->getName()); |
|
| 90 | + $input->setAttribute('message', 'tns:' . $this->inputMessage->getName()); |
|
| 91 | 91 | $output = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:output'); |
| 92 | - $output->setAttribute('message', 'tns:'.$this->outputMessage->getName()); |
|
| 92 | + $output->setAttribute('message', 'tns:' . $this->outputMessage->getName()); |
|
| 93 | 93 | |
| 94 | 94 | $operation->appendChild($documentation); |
| 95 | 95 | $operation->appendChild($input); |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | * @param string $namespace The namespace this binding is in. |
| 107 | 107 | * @return DomElement The dom element representing this binding. |
| 108 | 108 | */ |
| 109 | - public function getBindingOperation(DomDocument $dom, $namespace, $style='rpc') |
|
| 109 | + public function getBindingOperation(DomDocument $dom, $namespace, $style = 'rpc') |
|
| 110 | 110 | { |
| 111 | 111 | $operation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:operation'); |
| 112 | 112 | $operation->setAttribute('name', $this->operationName); |
| 113 | 113 | |
| 114 | 114 | $soapOperation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:operation'); |
| 115 | 115 | $method = $this->operationName; |
| 116 | - $soapOperation->setAttribute('soapAction', $namespace.'#'.$method); |
|
| 116 | + $soapOperation->setAttribute('soapAction', $namespace . '#' . $method); |
|
| 117 | 117 | $soapOperation->setAttribute('style', $style); |
| 118 | 118 | |
| 119 | 119 | $input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input'); |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | * @package System.Web.Services.SOAP |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -require_once(dirname(__FILE__).'/Wsdl.php'); |
|
| 18 | -require_once(dirname(__FILE__).'/WsdlMessage.php'); |
|
| 19 | -require_once(dirname(__FILE__).'/WsdlOperation.php'); |
|
| 17 | +require_once(dirname(__FILE__) . '/Wsdl.php'); |
|
| 18 | +require_once(dirname(__FILE__) . '/WsdlMessage.php'); |
|
| 19 | +require_once(dirname(__FILE__) . '/WsdlOperation.php'); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Generator for the wsdl. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $encoding character encoding. |
| 92 | 92 | * @return void |
| 93 | 93 | */ |
| 94 | - public function generateWsdl($className, $serviceUri='',$encoding='') |
|
| 94 | + public function generateWsdl($className, $serviceUri = '', $encoding = '') |
|
| 95 | 95 | { |
| 96 | 96 | $this->wsdlDocument = new Wsdl($className, $serviceUri, $encoding); |
| 97 | 97 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - foreach($this->types as $type => $elements) { |
|
| 108 | + foreach ($this->types as $type => $elements) { |
|
| 109 | 109 | $this->wsdlDocument->addComplexType($type, $elements); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | * @param string $serviceUri The URI of the service that handles this WSDL |
| 119 | 119 | * @param string $encoding character encoding. |
| 120 | 120 | */ |
| 121 | - public static function generate($className, $serviceUri='', $encoding='') |
|
| 121 | + public static function generate($className, $serviceUri = '', $encoding = '') |
|
| 122 | 122 | { |
| 123 | 123 | $generator = WsdlGenerator::getInstance(); |
| 124 | - $generator->generateWsdl($className, $serviceUri,$encoding); |
|
| 124 | + $generator->generateWsdl($className, $serviceUri, $encoding); |
|
| 125 | 125 | //header('Content-type: text/xml'); |
| 126 | 126 | return $generator->getWsdl(); |
| 127 | 127 | //exit(); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $methodDoc .= trim($line); |
| 178 | 178 | } |
| 179 | 179 | else if (!$gotParams) { |
| 180 | - $params[count($params)-1]['desc'] .= trim($line); |
|
| 180 | + $params[count($params) - 1]['desc'] .= trim($line); |
|
| 181 | 181 | } |
| 182 | 182 | else { |
| 183 | 183 | if ($line == '*/') continue; |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | $methodName = $method->getName(); |
| 190 | 190 | $operation = new WsdlOperation($methodName, $methodDoc); |
| 191 | 191 | |
| 192 | - $operation->setInputMessage(new WsdlMessage($methodName.'Request', $params)); |
|
| 193 | - $operation->setOutputMessage(new WsdlMessage($methodName.'Response', array($return))); |
|
| 192 | + $operation->setInputMessage(new WsdlMessage($methodName . 'Request', $params)); |
|
| 193 | + $operation->setOutputMessage(new WsdlMessage($methodName . 'Response', array($return))); |
|
| 194 | 194 | |
| 195 | 195 | $this->wsdlDocument->addOperation($operation); |
| 196 | 196 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | case 'void': |
| 245 | 245 | return ''; |
| 246 | 246 | default: |
| 247 | - if(strpos($type, '[]')) // if it is an array |
|
| 247 | + if (strpos($type, '[]')) // if it is an array |
|
| 248 | 248 | { |
| 249 | 249 | $className = substr($type, 0, strlen($type) - 2); |
| 250 | 250 | $type = $className . 'Array'; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | else |
| 255 | 255 | { |
| 256 | - if(!isset($this->types[$type])) |
|
| 256 | + if (!isset($this->types[$type])) |
|
| 257 | 257 | $this->extractClassProperties($type); |
| 258 | 258 | } |
| 259 | 259 | return 'tns:' . $type; |
@@ -276,28 +276,28 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | $reflection = new ReflectionClass($className); |
| 278 | 278 | $properties = $reflection->getProperties(); |
| 279 | - foreach($properties as $property) |
|
| 279 | + foreach ($properties as $property) |
|
| 280 | 280 | { |
| 281 | 281 | $comment = $property->getDocComment(); |
| 282 | - if(strpos($comment, '@soapproperty') !== false) |
|
| 282 | + if (strpos($comment, '@soapproperty') !== false) |
|
| 283 | 283 | { |
| 284 | - if(preg_match('/@var\s+([\w\.]+(\[\s*\])?)\s*?\$(.*)$/mi',$comment,$matches)) |
|
| 284 | + if (preg_match('/@var\s+([\w\.]+(\[\s*\])?)\s*?\$(.*)$/mi', $comment, $matches)) |
|
| 285 | 285 | { |
| 286 | 286 | // support nillable, minOccurs, maxOccurs attributes |
| 287 | - $nillable=$minOccurs=$maxOccurs=false; |
|
| 288 | - if(preg_match('/{(.+)}/',$matches[3],$attr)) |
|
| 287 | + $nillable = $minOccurs = $maxOccurs = false; |
|
| 288 | + if (preg_match('/{(.+)}/', $matches[3], $attr)) |
|
| 289 | 289 | { |
| 290 | - $matches[3]=str_replace($attr[0],'',$matches[3]); |
|
| 291 | - if(preg_match_all('/((\w+)\s*=\s*(\w+))/mi',$attr[1],$attr)) |
|
| 290 | + $matches[3] = str_replace($attr[0], '', $matches[3]); |
|
| 291 | + if (preg_match_all('/((\w+)\s*=\s*(\w+))/mi', $attr[1], $attr)) |
|
| 292 | 292 | { |
| 293 | - foreach($attr[2] as $id=>$prop) |
|
| 293 | + foreach ($attr[2] as $id=>$prop) |
|
| 294 | 294 | { |
| 295 | - if(strcasecmp($prop,'nillable')===0) |
|
| 296 | - $nillable=$attr[3][$id] ? 'true' : 'false'; |
|
| 297 | - elseif(strcasecmp($prop,'minOccurs')===0) |
|
| 298 | - $minOccurs=(int)$attr[3][$id]; |
|
| 299 | - elseif(strcasecmp($prop,'maxOccurs')===0) |
|
| 300 | - $maxOccurs=(int)$attr[3][$id]; |
|
| 295 | + if (strcasecmp($prop, 'nillable') === 0) |
|
| 296 | + $nillable = $attr[3][$id] ? 'true' : 'false'; |
|
| 297 | + elseif (strcasecmp($prop, 'minOccurs') === 0) |
|
| 298 | + $minOccurs = (int) $attr[3][$id]; |
|
| 299 | + elseif (strcasecmp($prop, 'maxOccurs') === 0) |
|
| 300 | + $maxOccurs = (int) $attr[3][$id]; |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * A collection of SOAP operations |
| 49 | 49 | * @var array |
| 50 | 50 | */ |
| 51 | - private $operations=array(); |
|
| 51 | + private $operations = array(); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Wsdl DOMDocument that's generated. |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * The target namespace variable? |
| 65 | 65 | */ |
| 66 | - private $targetNamespace =''; |
|
| 66 | + private $targetNamespace = ''; |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * The binding style (default at the moment) |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | private $bindingTransport = 'http://schemas.xmlsoap.org/soap/http'; |
| 77 | 77 | |
| 78 | - private $_encoding=''; |
|
| 78 | + private $_encoding = ''; |
|
| 79 | 79 | |
| 80 | 80 | private static $_primitiveTypes = array('string', 'int', 'float', 'boolean', 'date', 'time', 'dateTime'); |
| 81 | 81 | |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | * @param string $serviceUri The URI of the service that handles this WSDL |
| 86 | 86 | * @param string character encoding |
| 87 | 87 | */ |
| 88 | - public function __construct($name, $serviceUri='', $encoding='') |
|
| 88 | + public function __construct($name, $serviceUri = '', $encoding = '') |
|
| 89 | 89 | { |
| 90 | 90 | $this->_encoding = $encoding; |
| 91 | 91 | $this->serviceName = $name; |
| 92 | - $protocol=(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!=='off'))?'https://':'http://'; |
|
| 93 | - if ($serviceUri === '') $serviceUri = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; |
|
| 92 | + $protocol = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) ? 'https://' : 'http://'; |
|
| 93 | + if ($serviceUri === '') $serviceUri = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; |
|
| 94 | 94 | $this->serviceUri = str_replace('&', '&', $serviceUri); |
| 95 | 95 | $this->types = new ArrayObject(); |
| 96 | - $this->targetNamespace = 'urn:'.$name.'wsdl'; |
|
| 96 | + $this->targetNamespace = 'urn:' . $name . 'wsdl'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function getWsdl() |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | protected function buildWsdl() |
| 109 | 109 | { |
| 110 | - $encoding = $this->_encoding==='' ? '' : 'encoding="'.$this->_encoding.'"'; |
|
| 110 | + $encoding = $this->_encoding === '' ? '' : 'encoding="' . $this->_encoding . '"'; |
|
| 111 | 111 | |
| 112 | - $xml = '<?xml version="1.0" '.$encoding.'?> |
|
| 113 | - <definitions name="'.$this->serviceName.'" targetNamespace="'.$this->targetNamespace.'" |
|
| 112 | + $xml = '<?xml version="1.0" ' . $encoding . '?> |
|
| 113 | + <definitions name="'.$this->serviceName . '" targetNamespace="' . $this->targetNamespace . '" |
|
| 114 | 114 | xmlns="http://schemas.xmlsoap.org/wsdl/" |
| 115 | - xmlns:tns="'.$this->targetNamespace.'" |
|
| 115 | + xmlns:tns="'.$this->targetNamespace . '" |
|
| 116 | 116 | xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" |
| 117 | 117 | xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
| 118 | 118 | xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" |
@@ -142,37 +142,37 @@ discard block |
||
| 142 | 142 | $types = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:types'); |
| 143 | 143 | $schema = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:schema'); |
| 144 | 144 | $schema->setAttribute('targetNamespace', $this->targetNamespace); |
| 145 | - foreach($this->types as $type => $elements) |
|
| 145 | + foreach ($this->types as $type => $elements) |
|
| 146 | 146 | { |
| 147 | 147 | $complexType = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType'); |
| 148 | 148 | $complexType->setAttribute('name', $type); |
| 149 | - if(substr($type, strlen($type) - 5, 5) == 'Array') // if it's an array |
|
| 149 | + if (substr($type, strlen($type) - 5, 5) == 'Array') // if it's an array |
|
| 150 | 150 | { |
| 151 | 151 | $sequence = $dom->createElement("xsd:sequence"); |
| 152 | 152 | |
| 153 | 153 | $singularType = substr($type, 0, strlen($type) - 5); |
| 154 | 154 | $e = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element'); |
| 155 | 155 | $e->setAttribute('name', $singularType); |
| 156 | - $e->setAttribute('type', sprintf('tns:%s',$singularType)); |
|
| 157 | - $e->setAttribute('minOccurs','0'); |
|
| 158 | - $e->setAttribute('maxOccurs','unbounded'); |
|
| 156 | + $e->setAttribute('type', sprintf('tns:%s', $singularType)); |
|
| 157 | + $e->setAttribute('minOccurs', '0'); |
|
| 158 | + $e->setAttribute('maxOccurs', 'unbounded'); |
|
| 159 | 159 | $sequence->appendChild($e); |
| 160 | 160 | $complexType->appendChild($sequence); |
| 161 | 161 | } |
| 162 | 162 | else |
| 163 | 163 | { |
| 164 | 164 | $all = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all'); |
| 165 | - foreach($elements as $elem) |
|
| 165 | + foreach ($elements as $elem) |
|
| 166 | 166 | { |
| 167 | 167 | $e = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element'); |
| 168 | 168 | $e->setAttribute('name', $elem['name']); |
| 169 | 169 | $e->setAttribute('type', $elem['type']); |
| 170 | - if($elem['minOc']!==false) |
|
| 171 | - $e->setAttribute('minOccurs',$elem['minOc']); |
|
| 172 | - if($elem['maxOc']!==false) |
|
| 173 | - $e->setAttribute('maxOccurs',$elem['maxOc']); |
|
| 174 | - if($elem['nil']!==false) |
|
| 175 | - $e->setAttribute('nillable',$elem['nil']); |
|
| 170 | + if ($elem['minOc'] !== false) |
|
| 171 | + $e->setAttribute('minOccurs', $elem['minOc']); |
|
| 172 | + if ($elem['maxOc'] !== false) |
|
| 173 | + $e->setAttribute('maxOccurs', $elem['maxOc']); |
|
| 174 | + if ($elem['nil'] !== false) |
|
| 175 | + $e->setAttribute('nillable', $elem['nil']); |
|
| 176 | 176 | $all->appendChild($e); |
| 177 | 177 | } |
| 178 | 178 | $complexType->appendChild($all); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | protected function addPortTypes(DOMDocument $dom) |
| 212 | 212 | { |
| 213 | 213 | $portType = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:portType'); |
| 214 | - $portType->setAttribute('name', $this->serviceName.'PortType'); |
|
| 214 | + $portType->setAttribute('name', $this->serviceName . 'PortType'); |
|
| 215 | 215 | |
| 216 | 216 | $this->definitions->appendChild($portType); |
| 217 | 217 | foreach ($this->operations as $operation) { |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | protected function addBindings(DOMDocument $dom) |
| 228 | 228 | { |
| 229 | 229 | $binding = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:binding'); |
| 230 | - $binding->setAttribute('name', $this->serviceName.'Binding'); |
|
| 231 | - $binding->setAttribute('type', 'tns:'.$this->serviceName.'PortType'); |
|
| 230 | + $binding->setAttribute('name', $this->serviceName . 'Binding'); |
|
| 231 | + $binding->setAttribute('type', 'tns:' . $this->serviceName . 'PortType'); |
|
| 232 | 232 | |
| 233 | 233 | $soapBinding = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:binding'); |
| 234 | 234 | $soapBinding->setAttribute('style', $this->bindingStyle); |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | protected function addService(DomDocument $dom) |
| 251 | 251 | { |
| 252 | 252 | $service = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:service'); |
| 253 | - $service->setAttribute('name', $this->serviceName.'Service'); |
|
| 253 | + $service->setAttribute('name', $this->serviceName . 'Service'); |
|
| 254 | 254 | |
| 255 | 255 | $port = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:port'); |
| 256 | - $port->setAttribute('name', $this->serviceName.'Port'); |
|
| 257 | - $port->setAttribute('binding', 'tns:'.$this->serviceName.'Binding'); |
|
| 256 | + $port->setAttribute('name', $this->serviceName . 'Port'); |
|
| 257 | + $port->setAttribute('binding', 'tns:' . $this->serviceName . 'Binding'); |
|
| 258 | 258 | |
| 259 | 259 | $soapAddress = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:address'); |
| 260 | 260 | $soapAddress->setAttribute('location', $this->serviceUri); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @return array |
| 230 | 230 | */ |
| 231 | 231 | public function __sleep() { |
| 232 | - return array('options','objectFilters','enabled'); |
|
| 232 | + return array('options', 'objectFilters', 'enabled'); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * @param boolean $AutoCreate |
| 239 | 239 | * @return FirePHP |
| 240 | 240 | */ |
| 241 | - public static function getInstance($AutoCreate=false) { |
|
| 242 | - if($AutoCreate===true && !self::$instance) { |
|
| 241 | + public static function getInstance($AutoCreate = false) { |
|
| 242 | + if ($AutoCreate === true && !self::$instance) { |
|
| 243 | 243 | self::init(); |
| 244 | 244 | } |
| 245 | 245 | return self::$instance; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return void |
| 300 | 300 | */ |
| 301 | 301 | public function setOptions($Options) { |
| 302 | - $this->options = array_merge($this->options,$Options); |
|
| 302 | + $this->options = array_merge($this->options, $Options); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return mixed Returns a string containing the previously defined error handler (if any) |
| 320 | 320 | */ |
| 321 | - public function registerErrorHandler($throwErrorExceptions=true) |
|
| 321 | + public function registerErrorHandler($throwErrorExceptions = true) |
|
| 322 | 322 | { |
| 323 | 323 | //NOTE: The following errors will not be caught by this error handler: |
| 324 | 324 | // E_ERROR, E_PARSE, E_CORE_ERROR, |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | $this->throwErrorExceptions = $throwErrorExceptions; |
| 329 | 329 | |
| 330 | - return set_error_handler(array($this,'errorHandler')); |
|
| 330 | + return set_error_handler(array($this, 'errorHandler')); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | if (error_reporting() & $errno) { |
| 352 | 352 | |
| 353 | 353 | $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); |
| 354 | - if($this->throwErrorExceptions) { |
|
| 354 | + if ($this->throwErrorExceptions) { |
|
| 355 | 355 | throw $exception; |
| 356 | 356 | } else { |
| 357 | 357 | $this->fb($exception); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | public function registerExceptionHandler() |
| 370 | 370 | { |
| 371 | - return set_exception_handler(array($this,'exceptionHandler')); |
|
| 371 | + return set_exception_handler(array($this, 'exceptionHandler')); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | * @param boolean $throwAssertionExceptions |
| 398 | 398 | * @return mixed Returns the original setting or FALSE on errors |
| 399 | 399 | */ |
| 400 | - public function registerAssertionHandler($convertAssertionErrorsToExceptions=true, $throwAssertionExceptions=false) |
|
| 400 | + public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) |
|
| 401 | 401 | { |
| 402 | 402 | $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; |
| 403 | 403 | $this->throwAssertionExceptions = $throwAssertionExceptions; |
| 404 | 404 | |
| 405 | - if($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { |
|
| 405 | + if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { |
|
| 406 | 406 | throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); |
| 407 | 407 | } |
| 408 | 408 | |
@@ -421,11 +421,11 @@ discard block |
||
| 421 | 421 | public function assertionHandler($file, $line, $code) |
| 422 | 422 | { |
| 423 | 423 | |
| 424 | - if($this->convertAssertionErrorsToExceptions) { |
|
| 424 | + if ($this->convertAssertionErrorsToExceptions) { |
|
| 425 | 425 | |
| 426 | - $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); |
|
| 426 | + $exception = new ErrorException('Assertion Failed - Code[ ' . $code . ' ]', 0, null, $file, $line); |
|
| 427 | 427 | |
| 428 | - if($this->throwAssertionExceptions) { |
|
| 428 | + if ($this->throwAssertionExceptions) { |
|
| 429 | 429 | throw $exception; |
| 430 | 430 | } else { |
| 431 | 431 | $this->fb($exception); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | } else { |
| 435 | 435 | |
| 436 | - $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); |
|
| 436 | + $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file, 'Line'=>$line)); |
|
| 437 | 437 | |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -470,18 +470,18 @@ discard block |
||
| 470 | 470 | * @return true |
| 471 | 471 | * @throws Exception |
| 472 | 472 | */ |
| 473 | - public function group($Name, $Options=null) { |
|
| 473 | + public function group($Name, $Options = null) { |
|
| 474 | 474 | |
| 475 | - if(!$Name) { |
|
| 475 | + if (!$Name) { |
|
| 476 | 476 | throw $this->newException('You must specify a label for the group!'); |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - if($Options) { |
|
| 480 | - if(!is_array($Options)) { |
|
| 479 | + if ($Options) { |
|
| 480 | + if (!is_array($Options)) { |
|
| 481 | 481 | throw $this->newException('Options must be defined as an array!'); |
| 482 | 482 | } |
| 483 | - if(array_key_exists('Collapsed', $Options)) { |
|
| 484 | - $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; |
|
| 483 | + if (array_key_exists('Collapsed', $Options)) { |
|
| 484 | + $Options['Collapsed'] = ($Options['Collapsed']) ? 'true' : 'false'; |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @return true |
| 508 | 508 | * @throws Exception |
| 509 | 509 | */ |
| 510 | - public function log($Object, $Label=null) { |
|
| 510 | + public function log($Object, $Label = null) { |
|
| 511 | 511 | return $this->fb($Object, $Label, FirePHP::LOG); |
| 512 | 512 | } |
| 513 | 513 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @return true |
| 521 | 521 | * @throws Exception |
| 522 | 522 | */ |
| 523 | - public function info($Object, $Label=null) { |
|
| 523 | + public function info($Object, $Label = null) { |
|
| 524 | 524 | return $this->fb($Object, $Label, FirePHP::INFO); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @return true |
| 534 | 534 | * @throws Exception |
| 535 | 535 | */ |
| 536 | - public function warn($Object, $Label=null) { |
|
| 536 | + public function warn($Object, $Label = null) { |
|
| 537 | 537 | return $this->fb($Object, $Label, FirePHP::WARN); |
| 538 | 538 | } |
| 539 | 539 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @return true |
| 547 | 547 | * @throws Exception |
| 548 | 548 | */ |
| 549 | - public function error($Object, $Label=null) { |
|
| 549 | + public function error($Object, $Label = null) { |
|
| 550 | 550 | return $this->fb($Object, $Label, FirePHP::ERROR); |
| 551 | 551 | } |
| 552 | 552 | |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | */ |
| 596 | 596 | public function detectClientExtension() { |
| 597 | 597 | /* Check if FirePHP is installed on client */ |
| 598 | - if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) || |
|
| 599 | - !version_compare($m[1][0],'0.0.6','>=')) { |
|
| 598 | + if (!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si', $this->getUserAgent(), $m) || |
|
| 599 | + !version_compare($m[1][0], '0.0.6', '>=')) { |
|
| 600 | 600 | return false; |
| 601 | 601 | } |
| 602 | 602 | return true; |
@@ -612,17 +612,17 @@ discard block |
||
| 612 | 612 | */ |
| 613 | 613 | public function fb($Object) { |
| 614 | 614 | |
| 615 | - if(!$this->enabled) { |
|
| 615 | + if (!$this->enabled) { |
|
| 616 | 616 | return false; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | if (headers_sent($filename, $linenum)) { |
| 620 | 620 | // If we are logging from within the exception handler we cannot throw another exception |
| 621 | - if($this->inExceptionHandler) { |
|
| 621 | + if ($this->inExceptionHandler) { |
|
| 622 | 622 | // Simply echo the error out to the page |
| 623 | - echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>'.$filename.'</b> on line <b>'.$linenum.'</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; |
|
| 623 | + echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>' . $filename . '</b> on line <b>' . $linenum . '</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; |
|
| 624 | 624 | } else { |
| 625 | - throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); |
|
| 625 | + throw $this->newException('Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); |
|
| 626 | 626 | } |
| 627 | 627 | } |
| 628 | 628 | |
@@ -630,10 +630,10 @@ discard block |
||
| 630 | 630 | $Label = null; |
| 631 | 631 | $Options = array(); |
| 632 | 632 | |
| 633 | - if(func_num_args()==1) { |
|
| 633 | + if (func_num_args() == 1) { |
|
| 634 | 634 | } else |
| 635 | - if(func_num_args()==2) { |
|
| 636 | - switch(func_get_arg(1)) { |
|
| 635 | + if (func_num_args() == 2) { |
|
| 636 | + switch (func_get_arg(1)) { |
|
| 637 | 637 | case self::LOG: |
| 638 | 638 | case self::INFO: |
| 639 | 639 | case self::WARN: |
@@ -651,11 +651,11 @@ discard block |
||
| 651 | 651 | break; |
| 652 | 652 | } |
| 653 | 653 | } else |
| 654 | - if(func_num_args()==3) { |
|
| 654 | + if (func_num_args() == 3) { |
|
| 655 | 655 | $Type = func_get_arg(2); |
| 656 | 656 | $Label = func_get_arg(1); |
| 657 | 657 | } else |
| 658 | - if(func_num_args()==4) { |
|
| 658 | + if (func_num_args() == 4) { |
|
| 659 | 659 | $Type = func_get_arg(2); |
| 660 | 660 | $Label = func_get_arg(1); |
| 661 | 661 | $Options = func_get_arg(3); |
@@ -664,27 +664,27 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | |
| 667 | - if(!$this->detectClientExtension()) { |
|
| 667 | + if (!$this->detectClientExtension()) { |
|
| 668 | 668 | return false; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | $meta = array(); |
| 672 | 672 | $skipFinalObjectEncode = false; |
| 673 | 673 | |
| 674 | - if($Object instanceof Exception) { |
|
| 674 | + if ($Object instanceof Exception) { |
|
| 675 | 675 | |
| 676 | 676 | $meta['file'] = $this->_escapeTraceFile($Object->getFile()); |
| 677 | 677 | $meta['line'] = $Object->getLine(); |
| 678 | 678 | |
| 679 | 679 | $trace = $Object->getTrace(); |
| 680 | - if($Object instanceof ErrorException |
|
| 680 | + if ($Object instanceof ErrorException |
|
| 681 | 681 | && isset($trace[0]['function']) |
| 682 | - && $trace[0]['function']=='errorHandler' |
|
| 682 | + && $trace[0]['function'] == 'errorHandler' |
|
| 683 | 683 | && isset($trace[0]['class']) |
| 684 | - && $trace[0]['class']=='FirePHP') { |
|
| 684 | + && $trace[0]['class'] == 'FirePHP') { |
|
| 685 | 685 | |
| 686 | 686 | $severity = false; |
| 687 | - switch($Object->getSeverity()) { |
|
| 687 | + switch ($Object->getSeverity()) { |
|
| 688 | 688 | case E_WARNING: $severity = 'E_WARNING'; break; |
| 689 | 689 | case E_NOTICE: $severity = 'E_NOTICE'; break; |
| 690 | 690 | case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | $Object = array('Class'=>get_class($Object), |
| 700 | - 'Message'=>$severity.': '.$Object->getMessage(), |
|
| 700 | + 'Message'=>$severity . ': ' . $Object->getMessage(), |
|
| 701 | 701 | 'File'=>$this->_escapeTraceFile($Object->getFile()), |
| 702 | 702 | 'Line'=>$Object->getLine(), |
| 703 | 703 | 'Type'=>'trigger', |
| 704 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); |
|
| 704 | + 'Trace'=>$this->_escapeTrace(array_splice($trace, 2))); |
|
| 705 | 705 | $skipFinalObjectEncode = true; |
| 706 | 706 | } else { |
| 707 | 707 | $Object = array('Class'=>get_class($Object), |
@@ -715,49 +715,49 @@ discard block |
||
| 715 | 715 | $Type = self::EXCEPTION; |
| 716 | 716 | |
| 717 | 717 | } else |
| 718 | - if($Type==self::TRACE) { |
|
| 718 | + if ($Type == self::TRACE) { |
|
| 719 | 719 | |
| 720 | 720 | $trace = debug_backtrace(); |
| 721 | - if(!$trace) return false; |
|
| 722 | - for( $i=0 ; $i<sizeof($trace) ; $i++ ) { |
|
| 721 | + if (!$trace) return false; |
|
| 722 | + for ($i = 0; $i < sizeof($trace); $i++) { |
|
| 723 | 723 | |
| 724 | - if(isset($trace[$i]['class']) |
|
| 724 | + if (isset($trace[$i]['class']) |
|
| 725 | 725 | && isset($trace[$i]['file']) |
| 726 | - && ($trace[$i]['class']=='FirePHP' |
|
| 727 | - || $trace[$i]['class']=='FB') |
|
| 728 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
| 729 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
| 726 | + && ($trace[$i]['class'] == 'FirePHP' |
|
| 727 | + || $trace[$i]['class'] == 'FB') |
|
| 728 | + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' |
|
| 729 | + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { |
|
| 730 | 730 | /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
| 731 | 731 | } else |
| 732 | - if(isset($trace[$i]['class']) |
|
| 733 | - && isset($trace[$i+1]['file']) |
|
| 734 | - && $trace[$i]['class']=='FirePHP' |
|
| 735 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
| 732 | + if (isset($trace[$i]['class']) |
|
| 733 | + && isset($trace[$i + 1]['file']) |
|
| 734 | + && $trace[$i]['class'] == 'FirePHP' |
|
| 735 | + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { |
|
| 736 | 736 | /* Skip fb() */ |
| 737 | 737 | } else |
| 738 | - if($trace[$i]['function']=='fb' |
|
| 739 | - || $trace[$i]['function']=='trace' |
|
| 740 | - || $trace[$i]['function']=='send') { |
|
| 741 | - $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', |
|
| 742 | - 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', |
|
| 743 | - 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', |
|
| 738 | + if ($trace[$i]['function'] == 'fb' |
|
| 739 | + || $trace[$i]['function'] == 'trace' |
|
| 740 | + || $trace[$i]['function'] == 'send') { |
|
| 741 | + $Object = array('Class'=>isset($trace[$i]['class']) ? $trace[$i]['class'] : '', |
|
| 742 | + 'Type'=>isset($trace[$i]['type']) ? $trace[$i]['type'] : '', |
|
| 743 | + 'Function'=>isset($trace[$i]['function']) ? $trace[$i]['function'] : '', |
|
| 744 | 744 | 'Message'=>$trace[$i]['args'][0], |
| 745 | - 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', |
|
| 746 | - 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', |
|
| 747 | - 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', |
|
| 748 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); |
|
| 745 | + 'File'=>isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '', |
|
| 746 | + 'Line'=>isset($trace[$i]['line']) ? $trace[$i]['line'] : '', |
|
| 747 | + 'Args'=>isset($trace[$i]['args']) ? $this->encodeObject($trace[$i]['args']) : '', |
|
| 748 | + 'Trace'=>$this->_escapeTrace(array_splice($trace, $i + 1))); |
|
| 749 | 749 | |
| 750 | 750 | $skipFinalObjectEncode = true; |
| 751 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
| 752 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
| 751 | + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; |
|
| 752 | + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; |
|
| 753 | 753 | break; |
| 754 | 754 | } |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | } else |
| 758 | - if($Type==self::TABLE) { |
|
| 758 | + if ($Type == self::TABLE) { |
|
| 759 | 759 | |
| 760 | - if(isset($Object[0]) && is_string($Object[0])) { |
|
| 760 | + if (isset($Object[0]) && is_string($Object[0])) { |
|
| 761 | 761 | $Object[1] = $this->encodeTable($Object[1]); |
| 762 | 762 | } else { |
| 763 | 763 | $Object = $this->encodeTable($Object); |
@@ -766,44 +766,44 @@ discard block |
||
| 766 | 766 | $skipFinalObjectEncode = true; |
| 767 | 767 | |
| 768 | 768 | } else |
| 769 | - if($Type==self::GROUP_START) { |
|
| 769 | + if ($Type == self::GROUP_START) { |
|
| 770 | 770 | |
| 771 | - if(!$Label) { |
|
| 771 | + if (!$Label) { |
|
| 772 | 772 | throw $this->newException('You must specify a label for the group!'); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | } else { |
| 776 | - if($Type===null) { |
|
| 776 | + if ($Type === null) { |
|
| 777 | 777 | $Type = self::LOG; |
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - if($this->options['includeLineNumbers']) { |
|
| 782 | - if(!isset($meta['file']) || !isset($meta['line'])) { |
|
| 781 | + if ($this->options['includeLineNumbers']) { |
|
| 782 | + if (!isset($meta['file']) || !isset($meta['line'])) { |
|
| 783 | 783 | |
| 784 | 784 | $trace = debug_backtrace(); |
| 785 | - for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) { |
|
| 785 | + for ($i = 0; $trace && $i < sizeof($trace); $i++) { |
|
| 786 | 786 | |
| 787 | - if(isset($trace[$i]['class']) |
|
| 787 | + if (isset($trace[$i]['class']) |
|
| 788 | 788 | && isset($trace[$i]['file']) |
| 789 | - && ($trace[$i]['class']=='FirePHP' |
|
| 790 | - || $trace[$i]['class']=='FB') |
|
| 791 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
| 792 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
| 789 | + && ($trace[$i]['class'] == 'FirePHP' |
|
| 790 | + || $trace[$i]['class'] == 'FB') |
|
| 791 | + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' |
|
| 792 | + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { |
|
| 793 | 793 | /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
| 794 | 794 | } else |
| 795 | - if(isset($trace[$i]['class']) |
|
| 796 | - && isset($trace[$i+1]['file']) |
|
| 797 | - && $trace[$i]['class']=='FirePHP' |
|
| 798 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
| 795 | + if (isset($trace[$i]['class']) |
|
| 796 | + && isset($trace[$i + 1]['file']) |
|
| 797 | + && $trace[$i]['class'] == 'FirePHP' |
|
| 798 | + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { |
|
| 799 | 799 | /* Skip fb() */ |
| 800 | 800 | } else |
| 801 | - if(isset($trace[$i]['file']) |
|
| 802 | - && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
| 801 | + if (isset($trace[$i]['file']) |
|
| 802 | + && substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php') { |
|
| 803 | 803 | /* Skip FB::fb() */ |
| 804 | 804 | } else { |
| 805 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
| 806 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
| 805 | + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; |
|
| 806 | + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; |
|
| 807 | 807 | break; |
| 808 | 808 | } |
| 809 | 809 | } |
@@ -814,49 +814,49 @@ discard block |
||
| 814 | 814 | unset($meta['line']); |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); |
|
| 818 | - $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION); |
|
| 817 | + $this->setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); |
|
| 818 | + $this->setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/' . self::VERSION); |
|
| 819 | 819 | |
| 820 | 820 | $structure_index = 1; |
| 821 | - if($Type==self::DUMP) { |
|
| 821 | + if ($Type == self::DUMP) { |
|
| 822 | 822 | $structure_index = 2; |
| 823 | - $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); |
|
| 823 | + $this->setHeader('X-Wf-1-Structure-2', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); |
|
| 824 | 824 | } else { |
| 825 | - $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); |
|
| 825 | + $this->setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - if($Type==self::DUMP) { |
|
| 829 | - $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; |
|
| 828 | + if ($Type == self::DUMP) { |
|
| 829 | + $msg = '{"' . $Label . '":' . $this->jsonEncode($Object, $skipFinalObjectEncode) . '}'; |
|
| 830 | 830 | } else { |
| 831 | 831 | $msg_meta = $Options; |
| 832 | 832 | $msg_meta['Type'] = $Type; |
| 833 | - if($Label!==null) { |
|
| 833 | + if ($Label !== null) { |
|
| 834 | 834 | $msg_meta['Label'] = $Label; |
| 835 | 835 | } |
| 836 | - if(isset($meta['file']) && !isset($msg_meta['File'])) { |
|
| 836 | + if (isset($meta['file']) && !isset($msg_meta['File'])) { |
|
| 837 | 837 | $msg_meta['File'] = $meta['file']; |
| 838 | 838 | } |
| 839 | - if(isset($meta['line']) && !isset($msg_meta['Line'])) { |
|
| 839 | + if (isset($meta['line']) && !isset($msg_meta['Line'])) { |
|
| 840 | 840 | $msg_meta['Line'] = $meta['line']; |
| 841 | 841 | } |
| 842 | - $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; |
|
| 842 | + $msg = '[' . $this->jsonEncode($msg_meta) . ',' . $this->jsonEncode($Object, $skipFinalObjectEncode) . ']'; |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - $parts = explode("\n",chunk_split($msg, 5000, "\n")); |
|
| 845 | + $parts = explode("\n", chunk_split($msg, 5000, "\n")); |
|
| 846 | 846 | |
| 847 | - for( $i=0 ; $i<count($parts) ; $i++) { |
|
| 847 | + for ($i = 0; $i < count($parts); $i++) { |
|
| 848 | 848 | |
| 849 | 849 | $part = $parts[$i]; |
| 850 | 850 | if ($part) { |
| 851 | 851 | |
| 852 | - if(count($parts)>2) { |
|
| 852 | + if (count($parts) > 2) { |
|
| 853 | 853 | // Message needs to be split into multiple parts |
| 854 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
| 855 | - (($i==0)?strlen($msg):'') |
|
| 854 | + $this->setHeader('X-Wf-1-' . $structure_index . '-' . '1-' . $this->messageIndex, |
|
| 855 | + (($i == 0) ? strlen($msg) : '') |
|
| 856 | 856 | . '|' . $part . '|' |
| 857 | - . (($i<count($parts)-2)?'\\':'')); |
|
| 857 | + . (($i < count($parts) - 2) ? '\\' : '')); |
|
| 858 | 858 | } else { |
| 859 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
| 859 | + $this->setHeader('X-Wf-1-' . $structure_index . '-' . '1-' . $this->messageIndex, |
|
| 860 | 860 | strlen($part) . '|' . $part . '|'); |
| 861 | 861 | } |
| 862 | 862 | |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $this->setHeader('X-Wf-1-Index',$this->messageIndex-1); |
|
| 871 | + $this->setHeader('X-Wf-1-Index', $this->messageIndex - 1); |
|
| 872 | 872 | |
| 873 | 873 | return true; |
| 874 | 874 | } |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | * @return string |
| 881 | 881 | */ |
| 882 | 882 | protected function _standardizePath($Path) { |
| 883 | - return preg_replace('/\\\\+/','/',$Path); |
|
| 883 | + return preg_replace('/\\\\+/', '/', $Path); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | /** |
@@ -890,12 +890,12 @@ discard block |
||
| 890 | 890 | * @return array |
| 891 | 891 | */ |
| 892 | 892 | protected function _escapeTrace($Trace) { |
| 893 | - if(!$Trace) return $Trace; |
|
| 894 | - for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { |
|
| 895 | - if(isset($Trace[$i]['file'])) { |
|
| 893 | + if (!$Trace) return $Trace; |
|
| 894 | + for ($i = 0; $i < sizeof($Trace); $i++) { |
|
| 895 | + if (isset($Trace[$i]['file'])) { |
|
| 896 | 896 | $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); |
| 897 | 897 | } |
| 898 | - if(isset($Trace[$i]['args'])) { |
|
| 898 | + if (isset($Trace[$i]['args'])) { |
|
| 899 | 899 | $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); |
| 900 | 900 | } |
| 901 | 901 | } |
@@ -910,10 +910,10 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | protected function _escapeTraceFile($File) { |
| 912 | 912 | /* Check if we have a windows filepath */ |
| 913 | - if(strpos($File,'\\')) { |
|
| 913 | + if (strpos($File, '\\')) { |
|
| 914 | 914 | /* First strip down to single \ */ |
| 915 | 915 | |
| 916 | - $file = preg_replace('/\\\\+/','\\',$File); |
|
| 916 | + $file = preg_replace('/\\\\+/', '\\', $File); |
|
| 917 | 917 | |
| 918 | 918 | return $file; |
| 919 | 919 | } |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | * @param string_type $Value |
| 928 | 928 | */ |
| 929 | 929 | protected function setHeader($Name, $Value) { |
| 930 | - return header($Name.': '.$Value); |
|
| 930 | + return header($Name . ': ' . $Value); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | * @return string|false |
| 937 | 937 | */ |
| 938 | 938 | protected function getUserAgent() { |
| 939 | - if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
| 939 | + if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
| 940 | 940 | return $_SERVER['HTTP_USER_AGENT']; |
| 941 | 941 | } |
| 942 | 942 | |
@@ -958,14 +958,14 @@ discard block |
||
| 958 | 958 | * @param object $Object The object to be encoded |
| 959 | 959 | * @return string The JSON string |
| 960 | 960 | */ |
| 961 | - public function jsonEncode($Object, $skipObjectEncode=false) |
|
| 961 | + public function jsonEncode($Object, $skipObjectEncode = false) |
|
| 962 | 962 | { |
| 963 | - if(!$skipObjectEncode) { |
|
| 963 | + if (!$skipObjectEncode) { |
|
| 964 | 964 | $Object = $this->encodeObject($Object); |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if(function_exists('json_encode') |
|
| 968 | - && $this->options['useNativeJsonEncode']!=false) { |
|
| 967 | + if (function_exists('json_encode') |
|
| 968 | + && $this->options['useNativeJsonEncode'] != false) { |
|
| 969 | 969 | |
| 970 | 970 | return json_encode($Object); |
| 971 | 971 | } else { |
@@ -981,15 +981,15 @@ discard block |
||
| 981 | 981 | */ |
| 982 | 982 | protected function encodeTable($Table) { |
| 983 | 983 | |
| 984 | - if(!$Table) return $Table; |
|
| 984 | + if (!$Table) return $Table; |
|
| 985 | 985 | |
| 986 | 986 | $new_table = array(); |
| 987 | - foreach($Table as $row) { |
|
| 987 | + foreach ($Table as $row) { |
|
| 988 | 988 | |
| 989 | - if(is_array($row)) { |
|
| 989 | + if (is_array($row)) { |
|
| 990 | 990 | $new_row = array(); |
| 991 | 991 | |
| 992 | - foreach($row as $item) { |
|
| 992 | + foreach ($row as $item) { |
|
| 993 | 993 | $new_row[] = $this->encodeObject($item); |
| 994 | 994 | } |
| 995 | 995 | |
@@ -1014,18 +1014,18 @@ discard block |
||
| 1014 | 1014 | |
| 1015 | 1015 | if (is_resource($Object)) { |
| 1016 | 1016 | |
| 1017 | - return '** '.(string)$Object.' **'; |
|
| 1017 | + return '** ' . (string) $Object . ' **'; |
|
| 1018 | 1018 | |
| 1019 | 1019 | } else |
| 1020 | 1020 | if (is_object($Object)) { |
| 1021 | 1021 | |
| 1022 | 1022 | if ($ObjectDepth > $this->options['maxObjectDepth']) { |
| 1023 | - return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; |
|
| 1023 | + return '** Max Object Depth (' . $this->options['maxObjectDepth'] . ') **'; |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | foreach ($this->objectStack as $refVal) { |
| 1027 | 1027 | if ($refVal === $Object) { |
| 1028 | - return '** Recursion ('.get_class($Object).') **'; |
|
| 1028 | + return '** Recursion (' . get_class($Object) . ') **'; |
|
| 1029 | 1029 | } |
| 1030 | 1030 | } |
| 1031 | 1031 | array_push($this->objectStack, $Object); |
@@ -1034,45 +1034,45 @@ discard block |
||
| 1034 | 1034 | |
| 1035 | 1035 | $reflectionClass = new ReflectionClass($class); |
| 1036 | 1036 | $properties = array(); |
| 1037 | - foreach( $reflectionClass->getProperties() as $property) { |
|
| 1037 | + foreach ($reflectionClass->getProperties() as $property) { |
|
| 1038 | 1038 | $properties[$property->getName()] = $property; |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | - $members = (array)$Object; |
|
| 1041 | + $members = (array) $Object; |
|
| 1042 | 1042 | |
| 1043 | - foreach( $properties as $raw_name => $property ) { |
|
| 1043 | + foreach ($properties as $raw_name => $property) { |
|
| 1044 | 1044 | |
| 1045 | 1045 | $name = $raw_name; |
| 1046 | - if($property->isStatic()) { |
|
| 1047 | - $name = 'static:'.$name; |
|
| 1046 | + if ($property->isStatic()) { |
|
| 1047 | + $name = 'static:' . $name; |
|
| 1048 | 1048 | } |
| 1049 | - if($property->isPublic()) { |
|
| 1050 | - $name = 'public:'.$name; |
|
| 1049 | + if ($property->isPublic()) { |
|
| 1050 | + $name = 'public:' . $name; |
|
| 1051 | 1051 | } else |
| 1052 | - if($property->isPrivate()) { |
|
| 1053 | - $name = 'private:'.$name; |
|
| 1054 | - $raw_name = "\0".$class."\0".$raw_name; |
|
| 1052 | + if ($property->isPrivate()) { |
|
| 1053 | + $name = 'private:' . $name; |
|
| 1054 | + $raw_name = "\0" . $class . "\0" . $raw_name; |
|
| 1055 | 1055 | } else |
| 1056 | - if($property->isProtected()) { |
|
| 1057 | - $name = 'protected:'.$name; |
|
| 1058 | - $raw_name = "\0".'*'."\0".$raw_name; |
|
| 1056 | + if ($property->isProtected()) { |
|
| 1057 | + $name = 'protected:' . $name; |
|
| 1058 | + $raw_name = "\0" . '*' . "\0" . $raw_name; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if(!(isset($this->objectFilters[$class]) |
|
| 1061 | + if (!(isset($this->objectFilters[$class]) |
|
| 1062 | 1062 | && is_array($this->objectFilters[$class]) |
| 1063 | - && in_array($raw_name,$this->objectFilters[$class]))) { |
|
| 1063 | + && in_array($raw_name, $this->objectFilters[$class]))) { |
|
| 1064 | 1064 | |
| 1065 | - if(array_key_exists($raw_name,$members) |
|
| 1065 | + if (array_key_exists($raw_name, $members) |
|
| 1066 | 1066 | && !$property->isStatic()) { |
| 1067 | 1067 | |
| 1068 | 1068 | $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1); |
| 1069 | 1069 | |
| 1070 | 1070 | } else { |
| 1071 | - if(method_exists($property,'setAccessible')) { |
|
| 1071 | + if (method_exists($property, 'setAccessible')) { |
|
| 1072 | 1072 | $property->setAccessible(true); |
| 1073 | 1073 | $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
| 1074 | 1074 | } else |
| 1075 | - if($property->isPublic()) { |
|
| 1075 | + if ($property->isPublic()) { |
|
| 1076 | 1076 | $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
| 1077 | 1077 | } else { |
| 1078 | 1078 | $return[$name] = '** Need PHP 5.3 to get value **'; |
@@ -1085,7 +1085,7 @@ discard block |
||
| 1085 | 1085 | |
| 1086 | 1086 | // Include all members that are not defined in the class |
| 1087 | 1087 | // but exist in the object |
| 1088 | - foreach( $members as $raw_name => $value ) { |
|
| 1088 | + foreach ($members as $raw_name => $value) { |
|
| 1089 | 1089 | |
| 1090 | 1090 | $name = $raw_name; |
| 1091 | 1091 | |
@@ -1094,12 +1094,12 @@ discard block |
||
| 1094 | 1094 | $name = $parts[2]; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - if(!isset($properties[$name])) { |
|
| 1098 | - $name = 'undeclared:'.$name; |
|
| 1097 | + if (!isset($properties[$name])) { |
|
| 1098 | + $name = 'undeclared:' . $name; |
|
| 1099 | 1099 | |
| 1100 | - if(!(isset($this->objectFilters[$class]) |
|
| 1100 | + if (!(isset($this->objectFilters[$class]) |
|
| 1101 | 1101 | && is_array($this->objectFilters[$class]) |
| 1102 | - && in_array($raw_name,$this->objectFilters[$class]))) { |
|
| 1102 | + && in_array($raw_name, $this->objectFilters[$class]))) { |
|
| 1103 | 1103 | |
| 1104 | 1104 | $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1); |
| 1105 | 1105 | } else { |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | } elseif (is_array($Object)) { |
| 1114 | 1114 | |
| 1115 | 1115 | if ($ArrayDepth > $this->options['maxArrayDepth']) { |
| 1116 | - return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; |
|
| 1116 | + return '** Max Array Depth (' . $this->options['maxArrayDepth'] . ') **'; |
|
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | foreach ($Object as $key => $val) { |
@@ -1122,16 +1122,16 @@ discard block |
||
| 1122 | 1122 | // if the recursion is not reset here as it contains |
| 1123 | 1123 | // a reference to itself. This is the only way I have come up |
| 1124 | 1124 | // with to stop infinite recursion in this case. |
| 1125 | - if($key=='GLOBALS' |
|
| 1125 | + if ($key == 'GLOBALS' |
|
| 1126 | 1126 | && is_array($val) |
| 1127 | - && array_key_exists('GLOBALS',$val)) { |
|
| 1127 | + && array_key_exists('GLOBALS', $val)) { |
|
| 1128 | 1128 | $val['GLOBALS'] = '** Recursion (GLOBALS) **'; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1); |
| 1132 | 1132 | } |
| 1133 | 1133 | } else { |
| 1134 | - if(self::is_utf8($Object)) { |
|
| 1134 | + if (self::is_utf8($Object)) { |
|
| 1135 | 1135 | return $Object; |
| 1136 | 1136 | } else { |
| 1137 | 1137 | return utf8_encode($Object); |
@@ -1147,24 +1147,24 @@ discard block |
||
| 1147 | 1147 | * @return boolean |
| 1148 | 1148 | */ |
| 1149 | 1149 | protected static function is_utf8($str) { |
| 1150 | - $c=0; $b=0; |
|
| 1151 | - $bits=0; |
|
| 1152 | - $len=strlen($str); |
|
| 1153 | - for($i=0; $i<$len; $i++){ |
|
| 1154 | - $c=ord($str[$i]); |
|
| 1155 | - if($c > 128){ |
|
| 1156 | - if(($c >= 254)) return false; |
|
| 1157 | - elseif($c >= 252) $bits=6; |
|
| 1158 | - elseif($c >= 248) $bits=5; |
|
| 1159 | - elseif($c >= 240) $bits=4; |
|
| 1160 | - elseif($c >= 224) $bits=3; |
|
| 1161 | - elseif($c >= 192) $bits=2; |
|
| 1150 | + $c = 0; $b = 0; |
|
| 1151 | + $bits = 0; |
|
| 1152 | + $len = strlen($str); |
|
| 1153 | + for ($i = 0; $i < $len; $i++) { |
|
| 1154 | + $c = ord($str[$i]); |
|
| 1155 | + if ($c > 128) { |
|
| 1156 | + if (($c >= 254)) return false; |
|
| 1157 | + elseif ($c >= 252) $bits = 6; |
|
| 1158 | + elseif ($c >= 248) $bits = 5; |
|
| 1159 | + elseif ($c >= 240) $bits = 4; |
|
| 1160 | + elseif ($c >= 224) $bits = 3; |
|
| 1161 | + elseif ($c >= 192) $bits = 2; |
|
| 1162 | 1162 | else return false; |
| 1163 | - if(($i+$bits) > $len) return false; |
|
| 1164 | - while($bits > 1){ |
|
| 1163 | + if (($i + $bits) > $len) return false; |
|
| 1164 | + while ($bits > 1) { |
|
| 1165 | 1165 | $i++; |
| 1166 | - $b=ord($str[$i]); |
|
| 1167 | - if($b < 128 || $b > 191) return false; |
|
| 1166 | + $b = ord($str[$i]); |
|
| 1167 | + if ($b < 128 || $b > 191) return false; |
|
| 1168 | 1168 | $bits--; |
| 1169 | 1169 | } |
| 1170 | 1170 | } |
@@ -1249,11 +1249,11 @@ discard block |
||
| 1249 | 1249 | private function json_utf82utf16($utf8) |
| 1250 | 1250 | { |
| 1251 | 1251 | // oh please oh please oh please oh please oh please |
| 1252 | - if(function_exists('mb_convert_encoding')) { |
|
| 1252 | + if (function_exists('mb_convert_encoding')) { |
|
| 1253 | 1253 | return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - switch(strlen($utf8)) { |
|
| 1256 | + switch (strlen($utf8)) { |
|
| 1257 | 1257 | case 1: |
| 1258 | 1258 | // this case should never be reached, because we are in ASCII range |
| 1259 | 1259 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
@@ -1293,8 +1293,8 @@ discard block |
||
| 1293 | 1293 | private function json_encode($var) |
| 1294 | 1294 | { |
| 1295 | 1295 | |
| 1296 | - if(is_object($var)) { |
|
| 1297 | - if(in_array($var,$this->json_objectStack)) { |
|
| 1296 | + if (is_object($var)) { |
|
| 1297 | + if (in_array($var, $this->json_objectStack)) { |
|
| 1298 | 1298 | return '"** Recursion **"'; |
| 1299 | 1299 | } |
| 1300 | 1300 | } |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | case $ord_var_c == 0x2F: |
| 1348 | 1348 | case $ord_var_c == 0x5C: |
| 1349 | 1349 | // double quote, slash, slosh |
| 1350 | - $ascii .= '\\'.$var{$c}; |
|
| 1350 | + $ascii .= '\\' . $var{$c}; |
|
| 1351 | 1351 | break; |
| 1352 | 1352 | |
| 1353 | 1353 | case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): |
@@ -1416,7 +1416,7 @@ discard block |
||
| 1416 | 1416 | } |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | - return '"'.$ascii.'"'; |
|
| 1419 | + return '"' . $ascii . '"'; |
|
| 1420 | 1420 | |
| 1421 | 1421 | case 'array': |
| 1422 | 1422 | /* |
@@ -1448,8 +1448,8 @@ discard block |
||
| 1448 | 1448 | |
| 1449 | 1449 | array_pop($this->json_objectStack); |
| 1450 | 1450 | |
| 1451 | - foreach($properties as $property) { |
|
| 1452 | - if($property instanceof Exception) { |
|
| 1451 | + foreach ($properties as $property) { |
|
| 1452 | + if ($property instanceof Exception) { |
|
| 1453 | 1453 | return $property; |
| 1454 | 1454 | } |
| 1455 | 1455 | } |
@@ -1464,8 +1464,8 @@ discard block |
||
| 1464 | 1464 | |
| 1465 | 1465 | array_pop($this->json_objectStack); |
| 1466 | 1466 | |
| 1467 | - foreach($elements as $element) { |
|
| 1468 | - if($element instanceof Exception) { |
|
| 1467 | + foreach ($elements as $element) { |
|
| 1468 | + if ($element instanceof Exception) { |
|
| 1469 | 1469 | return $element; |
| 1470 | 1470 | } |
| 1471 | 1471 | } |
@@ -1483,8 +1483,8 @@ discard block |
||
| 1483 | 1483 | |
| 1484 | 1484 | array_pop($this->json_objectStack); |
| 1485 | 1485 | |
| 1486 | - foreach($properties as $property) { |
|
| 1487 | - if($property instanceof Exception) { |
|
| 1486 | + foreach ($properties as $property) { |
|
| 1487 | + if ($property instanceof Exception) { |
|
| 1488 | 1488 | return $property; |
| 1489 | 1489 | } |
| 1490 | 1490 | } |
@@ -1511,15 +1511,15 @@ discard block |
||
| 1511 | 1511 | // if the recursion is not reset here as it contains |
| 1512 | 1512 | // a reference to itself. This is the only way I have come up |
| 1513 | 1513 | // with to stop infinite recursion in this case. |
| 1514 | - if($name=='GLOBALS' |
|
| 1514 | + if ($name == 'GLOBALS' |
|
| 1515 | 1515 | && is_array($value) |
| 1516 | - && array_key_exists('GLOBALS',$value)) { |
|
| 1516 | + && array_key_exists('GLOBALS', $value)) { |
|
| 1517 | 1517 | $value['GLOBALS'] = '** Recursion **'; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | $encoded_value = $this->json_encode($value); |
| 1521 | 1521 | |
| 1522 | - if($encoded_value instanceof Exception) { |
|
| 1522 | + if ($encoded_value instanceof Exception) { |
|
| 1523 | 1523 | return $encoded_value; |
| 1524 | 1524 | } |
| 1525 | 1525 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @package FirePHP |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | -require_once dirname(__FILE__).'/FirePHP.class.php'; |
|
| 45 | +require_once dirname(__FILE__) . '/FirePHP.class.php'; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Sends the given data to the FirePHP Firefox Extension. |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $instance = FirePHP::getInstance(true); |
| 60 | 60 | |
| 61 | 61 | $args = func_get_args(); |
| 62 | - return call_user_func_array(array($instance,'fb'),$args); |
|
| 62 | + return call_user_func_array(array($instance, 'fb'), $args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $instance = FirePHP::getInstance(true); |
| 140 | 140 | $args = func_get_args(); |
| 141 | - return call_user_func_array(array($instance,'fb'),$args); |
|
| 141 | + return call_user_func_array(array($instance, 'fb'), $args); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param array $Options OPTIONAL Instructions on how to log the group |
| 153 | 153 | * @return true |
| 154 | 154 | */ |
| 155 | - public static function group($Name, $Options=null) { |
|
| 155 | + public static function group($Name, $Options = null) { |
|
| 156 | 156 | $instance = FirePHP::getInstance(true); |
| 157 | 157 | return $instance->group($Name, $Options); |
| 158 | 158 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @return true |
| 177 | 177 | * @throws Exception |
| 178 | 178 | */ |
| 179 | - public static function log($Object, $Label=null) { |
|
| 179 | + public static function log($Object, $Label = null) { |
|
| 180 | 180 | return self::send($Object, $Label, FirePHP::LOG); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @return true |
| 190 | 190 | * @throws Exception |
| 191 | 191 | */ |
| 192 | - public static function info($Object, $Label=null) { |
|
| 192 | + public static function info($Object, $Label = null) { |
|
| 193 | 193 | return self::send($Object, $Label, FirePHP::INFO); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return true |
| 203 | 203 | * @throws Exception |
| 204 | 204 | */ |
| 205 | - public static function warn($Object, $Label=null) { |
|
| 205 | + public static function warn($Object, $Label = null) { |
|
| 206 | 206 | return self::send($Object, $Label, FirePHP::WARN); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @return true |
| 216 | 216 | * @throws Exception |
| 217 | 217 | */ |
| 218 | - public static function error($Object, $Label=null) { |
|
| 218 | + public static function error($Object, $Label = null) { |
|
| 219 | 219 | return self::send($Object, $Label, FirePHP::ERROR); |
| 220 | 220 | } |
| 221 | 221 | |