@@ -50,7 +50,6 @@ discard block |
||
| 50 | 50 | * "Server" request tab. |
| 51 | 51 | * |
| 52 | 52 | * @see http://www.firephp.org/Wiki/Reference/Fb |
| 53 | - * @param mixed $Object |
|
| 54 | 53 | * @return true |
| 55 | 54 | * @throws Exception |
| 56 | 55 | */ |
@@ -130,7 +129,6 @@ discard block |
||
| 130 | 129 | * Log object to firebug |
| 131 | 130 | * |
| 132 | 131 | * @see http://www.firephp.org/Wiki/Reference/Fb |
| 133 | - * @param mixed $Object |
|
| 134 | 132 | * @return true |
| 135 | 133 | * @throws Exception |
| 136 | 134 | */ |
@@ -150,7 +148,7 @@ discard block |
||
| 150 | 148 | * |
| 151 | 149 | * @param string $Name |
| 152 | 150 | * @param array $Options OPTIONAL Instructions on how to log the group |
| 153 | - * @return true |
|
| 151 | + * @return boolean |
|
| 154 | 152 | */ |
| 155 | 153 | public static function group($Name, $Options=null) { |
| 156 | 154 | $instance = FirePHP::getInstance(true); |
@@ -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 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | /** |
| 227 | 227 | * When the object gets serialized only include specific object members. |
| 228 | 228 | * |
| 229 | - * @return array |
|
| 229 | + * @return string[] |
|
| 230 | 230 | */ |
| 231 | 231 | public function __sleep() { |
| 232 | 232 | return array('options','objectFilters','enabled'); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * Will throw exceptions for each php error. |
| 318 | 318 | * |
| 319 | - * @return mixed Returns a string containing the previously defined error handler (if any) |
|
| 319 | + * @return null|callable Returns a string containing the previously defined error handler (if any) |
|
| 320 | 320 | */ |
| 321 | 321 | public function registerErrorHandler($throwErrorExceptions=true) |
| 322 | 322 | { |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | /** |
| 363 | 363 | * Register FirePHP as your exception handler |
| 364 | 364 | * |
| 365 | - * @return mixed Returns the name of the previously defined exception handler, |
|
| 365 | + * @return callable Returns the name of the previously defined exception handler, |
|
| 366 | 366 | * or NULL on error. |
| 367 | 367 | * If no previous handler was defined, NULL is also returned. |
| 368 | 368 | */ |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | * |
| 468 | 468 | * @param string $Name |
| 469 | 469 | * @param array $Options OPTIONAL Instructions on how to log the group |
| 470 | - * @return true |
|
| 470 | + * @return boolean |
|
| 471 | 471 | * @throws Exception |
| 472 | 472 | */ |
| 473 | 473 | public function group($Name, $Options=null) { |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | /** |
| 492 | 492 | * Ends a group you have started before |
| 493 | 493 | * |
| 494 | - * @return true |
|
| 494 | + * @return boolean |
|
| 495 | 495 | * @throws Exception |
| 496 | 496 | */ |
| 497 | 497 | public function groupEnd() { |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | * Log object with label to firebug console |
| 503 | 503 | * |
| 504 | 504 | * @see FirePHP::LOG |
| 505 | - * @param mixes $Object |
|
| 505 | + * @param string $Object |
|
| 506 | 506 | * @param string $Label |
| 507 | - * @return true |
|
| 507 | + * @return boolean |
|
| 508 | 508 | * @throws Exception |
| 509 | 509 | */ |
| 510 | 510 | public function log($Object, $Label=null) { |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * @see FirePHP::INFO |
| 518 | 518 | * @param mixes $Object |
| 519 | 519 | * @param string $Label |
| 520 | - * @return true |
|
| 520 | + * @return boolean |
|
| 521 | 521 | * @throws Exception |
| 522 | 522 | */ |
| 523 | 523 | public function info($Object, $Label=null) { |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | * @see FirePHP::WARN |
| 531 | 531 | * @param mixes $Object |
| 532 | 532 | * @param string $Label |
| 533 | - * @return true |
|
| 533 | + * @return boolean |
|
| 534 | 534 | * @throws Exception |
| 535 | 535 | */ |
| 536 | 536 | public function warn($Object, $Label=null) { |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @see FirePHP::ERROR |
| 544 | 544 | * @param mixes $Object |
| 545 | 545 | * @param string $Label |
| 546 | - * @return true |
|
| 546 | + * @return boolean |
|
| 547 | 547 | * @throws Exception |
| 548 | 548 | */ |
| 549 | 549 | public function error($Object, $Label=null) { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | * @see FirePHP::DUMP |
| 557 | 557 | * @param string $Key |
| 558 | 558 | * @param mixed $Variable |
| 559 | - * @return true |
|
| 559 | + * @return boolean |
|
| 560 | 560 | * @throws Exception |
| 561 | 561 | */ |
| 562 | 562 | public function dump($Key, $Variable) { |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * |
| 569 | 569 | * @see FirePHP::TRACE |
| 570 | 570 | * @param string $Label |
| 571 | - * @return true |
|
| 571 | + * @return boolean |
|
| 572 | 572 | * @throws Exception |
| 573 | 573 | */ |
| 574 | 574 | public function trace($Label) { |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @see FirePHP::TABLE |
| 582 | 582 | * @param string $Label |
| 583 | 583 | * @param string $Table |
| 584 | - * @return true |
|
| 584 | + * @return boolean |
|
| 585 | 585 | * @throws Exception |
| 586 | 586 | */ |
| 587 | 587 | public function table($Label, $Table) { |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @see http://www.firephp.org/Wiki/Reference/Fb |
| 609 | 609 | * @param mixed $Object The variable to be logged |
| 610 | - * @return true Return TRUE if message was added to headers, FALSE otherwise |
|
| 610 | + * @return boolean Return TRUE if message was added to headers, FALSE otherwise |
|
| 611 | 611 | * @throws Exception |
| 612 | 612 | */ |
| 613 | 613 | public function fb($Object) { |
@@ -1005,7 +1005,6 @@ discard block |
||
| 1005 | 1005 | * protected and private visibility |
| 1006 | 1006 | * |
| 1007 | 1007 | * @param Object $Object The object to be encoded |
| 1008 | - * @param int $Depth The current traversal depth |
|
| 1009 | 1008 | * @return array All members of the object |
| 1010 | 1009 | */ |
| 1011 | 1010 | protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) |
@@ -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 | |
@@ -13,6 +13,10 @@ |
||
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | 15 | interface PHP_Shell_Extension { |
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * @return void |
|
| 19 | + */ |
|
| 16 | 20 | public function register(); |
| 17 | 21 | } |
| 18 | 22 | |
@@ -97,6 +97,8 @@ |
||
| 97 | 97 | * calls the setor for the :set <option> |
| 98 | 98 | * |
| 99 | 99 | * |
| 100 | + * @param string $key |
|
| 101 | + * @param string|null $value |
|
| 100 | 102 | */ |
| 101 | 103 | private function execute($key, $value) { |
| 102 | 104 | /* did we hit a alias (bg for backgroud) ? */ |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once(dirname(__FILE__)."/Extensions.php"); /* for the PHP_Shell_Interface */ |
|
| 3 | +require_once(dirname(__FILE__) . "/Extensions.php"); /* for the PHP_Shell_Interface */ |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | if (!isset($this->options[$opt_key])) { |
| 110 | - print (':set '.$key.' failed: unknown key'); |
|
| 110 | + print (':set ' . $key . ' failed: unknown key'); |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -211,6 +211,9 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | /* Mailhide related code */ |
| 213 | 213 | |
| 214 | +/** |
|
| 215 | + * @param string $ky |
|
| 216 | + */ |
|
| 214 | 217 | function _recaptcha_aes_encrypt($val,$ky) { |
| 215 | 218 | if (! function_exists ("mcrypt_encrypt")) { |
| 216 | 219 | die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); |
@@ -222,6 +225,9 @@ discard block |
||
| 222 | 225 | } |
| 223 | 226 | |
| 224 | 227 | |
| 228 | +/** |
|
| 229 | + * @param null|string $x |
|
| 230 | + */ |
|
| 225 | 231 | function _recaptcha_mailhide_urlbase64 ($x) { |
| 226 | 232 | return strtr(base64_encode ($x), '+/', '-_'); |
| 227 | 233 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * @param $data - array of string elements to be encoded |
| 45 | 45 | * @return string - encoded request |
| 46 | 46 | */ |
| 47 | -function _recaptcha_qsencode ($data) { |
|
| 47 | +function _recaptcha_qsencode($data) { |
|
| 48 | 48 | $req = ""; |
| 49 | - foreach ( $data as $key => $value ) |
|
| 50 | - $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; |
|
| 49 | + foreach ($data as $key => $value) |
|
| 50 | + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
| 51 | 51 | |
| 52 | 52 | // Cut the last '&' |
| 53 | - $req=substr($req,0,strlen($req)-1); |
|
| 53 | + $req = substr($req, 0, strlen($req) - 1); |
|
| 54 | 54 | return $req; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | function _recaptcha_http_post($host, $path, $data, $port = 80) { |
| 68 | 68 | |
| 69 | - $req = _recaptcha_qsencode ($data); |
|
| 69 | + $req = _recaptcha_qsencode($data); |
|
| 70 | 70 | |
| 71 | 71 | $http_request = "POST $path HTTP/1.0\r\n"; |
| 72 | 72 | $http_request .= "Host: $host\r\n"; |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | $http_request .= $req; |
| 78 | 78 | |
| 79 | 79 | $response = ''; |
| 80 | - if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { |
|
| 80 | + if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) { |
|
| 81 | 81 | die ('Could not open socket'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | fwrite($fs, $http_request); |
| 85 | 85 | |
| 86 | - while ( !feof($fs) ) |
|
| 86 | + while (!feof($fs)) |
|
| 87 | 87 | $response .= fgets($fs, 1160); // One TCP-IP packet |
| 88 | 88 | fclose($fs); |
| 89 | 89 | $response = explode("\r\n\r\n", $response, 2); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | * @return string - The HTML to be embedded in the user's form. |
| 105 | 105 | */ |
| 106 | -function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) |
|
| 106 | +function recaptcha_get_html($pubkey, $error = null, $use_ssl = false) |
|
| 107 | 107 | { |
| 108 | 108 | if ($pubkey == null || $pubkey == '') { |
| 109 | 109 | die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if ($error) { |
| 120 | 120 | $errorpart = "&error=" . $error; |
| 121 | 121 | } |
| 122 | - return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> |
|
| 122 | + return '<script type="text/javascript" src="' . $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> |
|
| 123 | 123 | |
| 124 | 124 | <noscript> |
| 125 | 125 | <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param array $extra_params an array of extra variables to post to the server |
| 150 | 150 | * @return ReCaptchaResponse |
| 151 | 151 | */ |
| 152 | -function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) |
|
| 152 | +function recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params = array()) |
|
| 153 | 153 | { |
| 154 | 154 | if ($privkey == null || $privkey == '') { |
| 155 | 155 | die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | return $recaptcha_response; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", |
|
| 173 | - array ( |
|
| 172 | + $response = _recaptcha_http_post(RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", |
|
| 173 | + array( |
|
| 174 | 174 | 'privatekey' => $privkey, |
| 175 | 175 | 'remoteip' => $remoteip, |
| 176 | 176 | 'challenge' => $challenge, |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | ) + $extra_params |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - $answers = explode ("\n", $response [1]); |
|
| 181 | + $answers = explode("\n", $response [1]); |
|
| 182 | 182 | $recaptcha_response = new ReCaptchaResponse(); |
| 183 | 183 | |
| 184 | - if (trim ($answers [0]) == 'true') { |
|
| 184 | + if (trim($answers [0]) == 'true') { |
|
| 185 | 185 | $recaptcha_response->is_valid = true; |
| 186 | 186 | } |
| 187 | 187 | else { |
@@ -199,31 +199,31 @@ discard block |
||
| 199 | 199 | * @param string $domain The domain where the page is hosted |
| 200 | 200 | * @param string $appname The name of your application |
| 201 | 201 | */ |
| 202 | -function recaptcha_get_signup_url ($domain = null, $appname = null) { |
|
| 203 | - return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); |
|
| 202 | +function recaptcha_get_signup_url($domain = null, $appname = null) { |
|
| 203 | + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode(array('domains' => $domain, 'app' => $appname)); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | function _recaptcha_aes_pad($val) { |
| 207 | 207 | $block_size = 16; |
| 208 | - $numpad = $block_size - (strlen ($val) % $block_size); |
|
| 209 | - return str_pad($val, strlen ($val) + $numpad, chr($numpad)); |
|
| 208 | + $numpad = $block_size - (strlen($val) % $block_size); |
|
| 209 | + return str_pad($val, strlen($val) + $numpad, chr($numpad)); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /* Mailhide related code */ |
| 213 | 213 | |
| 214 | -function _recaptcha_aes_encrypt($val,$ky) { |
|
| 215 | - if (! function_exists ("mcrypt_encrypt")) { |
|
| 214 | +function _recaptcha_aes_encrypt($val, $ky) { |
|
| 215 | + if (!function_exists("mcrypt_encrypt")) { |
|
| 216 | 216 | die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); |
| 217 | 217 | } |
| 218 | - $mode=MCRYPT_MODE_CBC; |
|
| 219 | - $enc=MCRYPT_RIJNDAEL_128; |
|
| 220 | - $val=_recaptcha_aes_pad($val); |
|
| 218 | + $mode = MCRYPT_MODE_CBC; |
|
| 219 | + $enc = MCRYPT_RIJNDAEL_128; |
|
| 220 | + $val = _recaptcha_aes_pad($val); |
|
| 221 | 221 | return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
| 225 | -function _recaptcha_mailhide_urlbase64 ($x) { |
|
| 226 | - return strtr(base64_encode ($x), '+/', '-_'); |
|
| 225 | +function _recaptcha_mailhide_urlbase64($x) { |
|
| 226 | + return strtr(base64_encode($x), '+/', '-_'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | |
| 237 | 237 | $ky = pack('H*', $privkey); |
| 238 | - $cryptmail = _recaptcha_aes_encrypt ($email, $ky); |
|
| 238 | + $cryptmail = _recaptcha_aes_encrypt($email, $ky); |
|
| 239 | 239 | |
| 240 | - return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); |
|
| 240 | + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64($cryptmail); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -245,15 +245,15 @@ discard block |
||
| 245 | 245 | * eg, given johndoe@example,com return ["john", "example.com"]. |
| 246 | 246 | * the email is then displayed as [email protected] |
| 247 | 247 | */ |
| 248 | -function _recaptcha_mailhide_email_parts ($email) { |
|
| 249 | - $arr = preg_split("/@/", $email ); |
|
| 248 | +function _recaptcha_mailhide_email_parts($email) { |
|
| 249 | + $arr = preg_split("/@/", $email); |
|
| 250 | 250 | |
| 251 | - if (strlen ($arr[0]) <= 4) { |
|
| 252 | - $arr[0] = substr ($arr[0], 0, 1); |
|
| 253 | - } else if (strlen ($arr[0]) <= 6) { |
|
| 254 | - $arr[0] = substr ($arr[0], 0, 3); |
|
| 251 | + if (strlen($arr[0]) <= 4) { |
|
| 252 | + $arr[0] = substr($arr[0], 0, 1); |
|
| 253 | + } else if (strlen($arr[0]) <= 6) { |
|
| 254 | + $arr[0] = substr($arr[0], 0, 3); |
|
| 255 | 255 | } else { |
| 256 | - $arr[0] = substr ($arr[0], 0, 4); |
|
| 256 | + $arr[0] = substr($arr[0], 0, 4); |
|
| 257 | 257 | } |
| 258 | 258 | return $arr; |
| 259 | 259 | } |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | * http://www.google.com/recaptcha/mailhide/apikey |
| 266 | 266 | */ |
| 267 | 267 | function recaptcha_mailhide_html($pubkey, $privkey, $email) { |
| 268 | - $emailparts = _recaptcha_mailhide_email_parts ($email); |
|
| 269 | - $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); |
|
| 268 | + $emailparts = _recaptcha_mailhide_email_parts($email); |
|
| 269 | + $url = recaptcha_mailhide_url($pubkey, $privkey, $email); |
|
| 270 | 270 | |
| 271 | - return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) . |
|
| 272 | - "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]); |
|
| 271 | + return htmlentities($emailparts[0]) . "<a href='" . htmlentities($url) . |
|
| 272 | + "' onclick=\"window.open('" . htmlentities($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities($emailparts [1]); |
|
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | /** |
| 197 | 197 | * Returns the next character from the XML document or void if at end |
| 198 | 198 | * @access protected |
| 199 | - * @return mixed |
|
| 199 | + * @return string|null |
|
| 200 | 200 | */ |
| 201 | 201 | function scanCharacter() { |
| 202 | 202 | if ($this->position < $this->length) { |
@@ -332,6 +332,7 @@ discard block |
||
| 332 | 332 | * parser options |
| 333 | 333 | * @var TSax3 instance of user front end class |
| 334 | 334 | * @access protected |
| 335 | + * @param TSax3 $htmlsax |
|
| 335 | 336 | */ |
| 336 | 337 | function __construct(& $htmlsax) { |
| 337 | 338 | parent::__construct($htmlsax); |
@@ -397,6 +398,7 @@ discard block |
||
| 397 | 398 | * parser options |
| 398 | 399 | * @var TSax3 instance of user front end class |
| 399 | 400 | * @access protected |
| 401 | + * @param TSax3 $htmlsax |
|
| 400 | 402 | */ |
| 401 | 403 | function __construct(& $htmlsax) { |
| 402 | 404 | parent::__construct($htmlsax); |
@@ -508,7 +510,7 @@ discard block |
||
| 508 | 510 | * if supplied argument is not an object. |
| 509 | 511 | * @param object handler object containing SAX callback methods |
| 510 | 512 | * @access public |
| 511 | - * @return mixed |
|
| 513 | + * @return boolean|null |
|
| 512 | 514 | */ |
| 513 | 515 | function set_object(&$object) { |
| 514 | 516 | if ( is_object($object) ) { |
@@ -546,7 +548,7 @@ discard block |
||
| 546 | 548 | * @param string name of parser option |
| 547 | 549 | * @param int (optional) 1 to switch on, 0 for off |
| 548 | 550 | * @access public |
| 549 | - * @return boolean |
|
| 551 | + * @return boolean|null |
|
| 550 | 552 | */ |
| 551 | 553 | function set_option($name, $value=1) { |
| 552 | 554 | if ( array_key_exists($name,$this->state_parser->parser_options) ) { |
@@ -568,6 +570,7 @@ discard block |
||
| 568 | 570 | * function myDataHander(& $parser,$data){} |
| 569 | 571 | * </pre> |
| 570 | 572 | * @param string name of method |
| 573 | + * @param string $data_method |
|
| 571 | 574 | * @access public |
| 572 | 575 | * @return void |
| 573 | 576 | * @see set_object |
@@ -591,6 +594,8 @@ discard block |
||
| 591 | 594 | * </pre> |
| 592 | 595 | * @param string name of open method |
| 593 | 596 | * @param string name of close method |
| 597 | + * @param string $opening_method |
|
| 598 | + * @param string $closing_method |
|
| 594 | 599 | * @access public |
| 595 | 600 | * @return void |
| 596 | 601 | * @see set_object |
@@ -610,6 +615,7 @@ discard block |
||
| 610 | 615 | * function myPIHander(& $parser,$target, $data){} |
| 611 | 616 | * </pre> |
| 612 | 617 | * @param string name of method |
| 618 | + * @param string $pi_method |
|
| 613 | 619 | * @access public |
| 614 | 620 | * @return void |
| 615 | 621 | * @see set_object |
@@ -628,6 +634,7 @@ discard block |
||
| 628 | 634 | * function myEscapeHander(& $parser, $data){} |
| 629 | 635 | * </pre> |
| 630 | 636 | * @param string name of method |
| 637 | + * @param string $escape_method |
|
| 631 | 638 | * @access public |
| 632 | 639 | * @return void |
| 633 | 640 | * @see set_object |
@@ -645,6 +652,7 @@ discard block |
||
| 645 | 652 | * function myJaspHander(& $parser, $data){} |
| 646 | 653 | * </pre> |
| 647 | 654 | * @param string name of method |
| 655 | + * @param string $jasp_method |
|
| 648 | 656 | * @access public |
| 649 | 657 | * @return void |
| 650 | 658 | * @see set_object |
@@ -684,6 +692,7 @@ discard block |
||
| 684 | 692 | /** |
| 685 | 693 | * Start parsing some XML |
| 686 | 694 | * @param string XML document |
| 695 | + * @param string $data |
|
| 687 | 696 | * @access public |
| 688 | 697 | * @return void |
| 689 | 698 | */ |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * Required classes |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | -require_once(dirname(__FILE__).'/HTMLSax3/States.php'); |
|
| 33 | -require_once(dirname(__FILE__).'/HTMLSax3/Decorators.php'); |
|
| 32 | +require_once(dirname(__FILE__) . '/HTMLSax3/States.php'); |
|
| 33 | +require_once(dirname(__FILE__) . '/HTMLSax3/Decorators.php'); |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Base State Parser |
@@ -246,56 +246,56 @@ discard block |
||
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | 248 | function parse($data) { |
| 249 | - if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES']==1) { |
|
| 249 | + if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES'] == 1) { |
|
| 250 | 250 | $decorator = new TSax3_Trim( |
| 251 | 251 | $this->handler_object_data, |
| 252 | 252 | $this->handler_method_data); |
| 253 | - $this->handler_object_data =& $decorator; |
|
| 253 | + $this->handler_object_data = & $decorator; |
|
| 254 | 254 | $this->handler_method_data = 'trimData'; |
| 255 | 255 | } |
| 256 | - if ($this->parser_options['XML_OPTION_CASE_FOLDING']==1) { |
|
| 256 | + if ($this->parser_options['XML_OPTION_CASE_FOLDING'] == 1) { |
|
| 257 | 257 | $open_decor = new TSax3_CaseFolding( |
| 258 | 258 | $this->handler_object_element, |
| 259 | 259 | $this->handler_method_opening, |
| 260 | 260 | $this->handler_method_closing); |
| 261 | - $this->handler_object_element =& $open_decor; |
|
| 262 | - $this->handler_method_opening ='foldOpen'; |
|
| 263 | - $this->handler_method_closing ='foldClose'; |
|
| 261 | + $this->handler_object_element = & $open_decor; |
|
| 262 | + $this->handler_method_opening = 'foldOpen'; |
|
| 263 | + $this->handler_method_closing = 'foldClose'; |
|
| 264 | 264 | } |
| 265 | - if ($this->parser_options['XML_OPTION_LINEFEED_BREAK']==1) { |
|
| 265 | + if ($this->parser_options['XML_OPTION_LINEFEED_BREAK'] == 1) { |
|
| 266 | 266 | $decorator = new TSax3_Linefeed( |
| 267 | 267 | $this->handler_object_data, |
| 268 | 268 | $this->handler_method_data); |
| 269 | - $this->handler_object_data =& $decorator; |
|
| 269 | + $this->handler_object_data = & $decorator; |
|
| 270 | 270 | $this->handler_method_data = 'breakData'; |
| 271 | 271 | } |
| 272 | - if ($this->parser_options['XML_OPTION_TAB_BREAK']==1) { |
|
| 272 | + if ($this->parser_options['XML_OPTION_TAB_BREAK'] == 1) { |
|
| 273 | 273 | $decorator = new TSax3_Tab( |
| 274 | 274 | $this->handler_object_data, |
| 275 | 275 | $this->handler_method_data); |
| 276 | - $this->handler_object_data =& $decorator; |
|
| 276 | + $this->handler_object_data = & $decorator; |
|
| 277 | 277 | $this->handler_method_data = 'breakData'; |
| 278 | 278 | } |
| 279 | - if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED']==1) { |
|
| 279 | + if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] == 1) { |
|
| 280 | 280 | $decorator = new TSax3_Entities_Unparsed( |
| 281 | 281 | $this->handler_object_data, |
| 282 | 282 | $this->handler_method_data); |
| 283 | - $this->handler_object_data =& $decorator; |
|
| 283 | + $this->handler_object_data = & $decorator; |
|
| 284 | 284 | $this->handler_method_data = 'breakData'; |
| 285 | 285 | } |
| 286 | - if ($this->parser_options['XML_OPTION_ENTITIES_PARSED']==1) { |
|
| 286 | + if ($this->parser_options['XML_OPTION_ENTITIES_PARSED'] == 1) { |
|
| 287 | 287 | $decorator = new TSax3_Entities_Parsed( |
| 288 | 288 | $this->handler_object_data, |
| 289 | 289 | $this->handler_method_data); |
| 290 | - $this->handler_object_data =& $decorator; |
|
| 290 | + $this->handler_object_data = & $decorator; |
|
| 291 | 291 | $this->handler_method_data = 'breakData'; |
| 292 | 292 | } |
| 293 | 293 | // Note switched on by default |
| 294 | - if ($this->parser_options['XML_OPTION_STRIP_ESCAPES']==1) { |
|
| 294 | + if ($this->parser_options['XML_OPTION_STRIP_ESCAPES'] == 1) { |
|
| 295 | 295 | $decorator = new TSax3_Escape_Stripper( |
| 296 | 296 | $this->handler_object_escape, |
| 297 | 297 | $this->handler_method_escape); |
| 298 | - $this->handler_object_escape =& $decorator; |
|
| 298 | + $this->handler_object_escape = & $decorator; |
|
| 299 | 299 | $this->handler_method_escape = 'strip'; |
| 300 | 300 | } |
| 301 | 301 | $this->rawtext = $data; |
@@ -511,12 +511,12 @@ discard block |
||
| 511 | 511 | * @return mixed |
| 512 | 512 | */ |
| 513 | 513 | function set_object(&$object) { |
| 514 | - if ( is_object($object) ) { |
|
| 515 | - $this->state_parser->handler_default =& $object; |
|
| 514 | + if (is_object($object)) { |
|
| 515 | + $this->state_parser->handler_default = & $object; |
|
| 516 | 516 | return true; |
| 517 | 517 | } else { |
| 518 | 518 | require_once('PEAR.php'); |
| 519 | - PEAR::raiseError('TSax3::set_object requires '. |
|
| 519 | + PEAR::raiseError('TSax3::set_object requires ' . |
|
| 520 | 520 | 'an object instance'); |
| 521 | 521 | } |
| 522 | 522 | } |
@@ -548,13 +548,13 @@ discard block |
||
| 548 | 548 | * @access public |
| 549 | 549 | * @return boolean |
| 550 | 550 | */ |
| 551 | - function set_option($name, $value=1) { |
|
| 552 | - if ( array_key_exists($name,$this->state_parser->parser_options) ) { |
|
| 551 | + function set_option($name, $value = 1) { |
|
| 552 | + if (array_key_exists($name, $this->state_parser->parser_options)) { |
|
| 553 | 553 | $this->state_parser->parser_options[$name] = $value; |
| 554 | 554 | return true; |
| 555 | 555 | } else { |
| 556 | 556 | require_once('PEAR.php'); |
| 557 | - PEAR::raiseError('TSax3::set_option('.$name.') illegal'); |
|
| 557 | + PEAR::raiseError('TSax3::set_option(' . $name . ') illegal'); |
|
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * @see set_object |
| 574 | 574 | */ |
| 575 | 575 | function set_data_handler($data_method) { |
| 576 | - $this->state_parser->handler_object_data =& $this->state_parser->handler_default; |
|
| 576 | + $this->state_parser->handler_object_data = & $this->state_parser->handler_default; |
|
| 577 | 577 | $this->state_parser->handler_method_data = $data_method; |
| 578 | 578 | } |
| 579 | 579 | |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @see set_object |
| 597 | 597 | */ |
| 598 | 598 | function set_element_handler($opening_method, $closing_method) { |
| 599 | - $this->state_parser->handler_object_element =& $this->state_parser->handler_default; |
|
| 599 | + $this->state_parser->handler_object_element = & $this->state_parser->handler_default; |
|
| 600 | 600 | $this->state_parser->handler_method_opening = $opening_method; |
| 601 | 601 | $this->state_parser->handler_method_closing = $closing_method; |
| 602 | 602 | } |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | * @see set_object |
| 616 | 616 | */ |
| 617 | 617 | function set_pi_handler($pi_method) { |
| 618 | - $this->state_parser->handler_object_pi =& $this->state_parser->handler_default; |
|
| 618 | + $this->state_parser->handler_object_pi = & $this->state_parser->handler_default; |
|
| 619 | 619 | $this->state_parser->handler_method_pi = $pi_method; |
| 620 | 620 | } |
| 621 | 621 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | * @see set_object |
| 634 | 634 | */ |
| 635 | 635 | function set_escape_handler($escape_method) { |
| 636 | - $this->state_parser->handler_object_escape =& $this->state_parser->handler_default; |
|
| 636 | + $this->state_parser->handler_object_escape = & $this->state_parser->handler_default; |
|
| 637 | 637 | $this->state_parser->handler_method_escape = $escape_method; |
| 638 | 638 | } |
| 639 | 639 | |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | * @return void |
| 650 | 650 | * @see set_object |
| 651 | 651 | */ |
| 652 | - function set_jasp_handler ($jasp_method) { |
|
| 653 | - $this->state_parser->handler_object_jasp =& $this->state_parser->handler_default; |
|
| 652 | + function set_jasp_handler($jasp_method) { |
|
| 653 | + $this->state_parser->handler_object_jasp = & $this->state_parser->handler_default; |
|
| 654 | 654 | $this->state_parser->handler_method_jasp = $jasp_method; |
| 655 | 655 | } |
| 656 | 656 | |
@@ -48,6 +48,7 @@ discard block |
||
| 48 | 48 | * Constructs TSax3_Trim |
| 49 | 49 | * @param object handler object being decorated |
| 50 | 50 | * @param string original handler method |
| 51 | + * @param string $orig_method |
|
| 51 | 52 | * @access protected |
| 52 | 53 | */ |
| 53 | 54 | function __construct(&$orig_obj, $orig_method) { |
@@ -96,6 +97,8 @@ discard block |
||
| 96 | 97 | * @param object handler object being decorated |
| 97 | 98 | * @param string original open handler method |
| 98 | 99 | * @param string original close handler method |
| 100 | + * @param string $orig_open_method |
|
| 101 | + * @param string $orig_close_method |
|
| 99 | 102 | * @access protected |
| 100 | 103 | */ |
| 101 | 104 | function __construct(&$orig_obj, $orig_open_method, $orig_close_method) { |
@@ -146,6 +149,7 @@ discard block |
||
| 146 | 149 | * Constructs TSax3_LineFeed |
| 147 | 150 | * @param object handler object being decorated |
| 148 | 151 | * @param string original handler method |
| 152 | + * @param string $orig_method |
|
| 149 | 153 | * @access protected |
| 150 | 154 | */ |
| 151 | 155 | function __construct(&$orig_obj, $orig_method) { |
@@ -188,6 +192,7 @@ discard block |
||
| 188 | 192 | * Constructs TSax3_Tab |
| 189 | 193 | * @param object handler object being decorated |
| 190 | 194 | * @param string original handler method |
| 195 | + * @param string $orig_method |
|
| 191 | 196 | * @access protected |
| 192 | 197 | */ |
| 193 | 198 | function __construct(&$orig_obj, $orig_method) { |
@@ -231,6 +236,7 @@ discard block |
||
| 231 | 236 | * Constructs TSax3_Entities_Parsed |
| 232 | 237 | * @param object handler object being decorated |
| 233 | 238 | * @param string original handler method |
| 239 | + * @param string $orig_method |
|
| 234 | 240 | * @access protected |
| 235 | 241 | */ |
| 236 | 242 | function __construct(&$orig_obj, $orig_method) { |
@@ -255,6 +261,10 @@ discard block |
||
| 255 | 261 | * Compatibility with older PHP versions |
| 256 | 262 | */ |
| 257 | 263 | if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode') ) { |
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * @param integer $style |
|
| 267 | + */ |
|
| 258 | 268 | function html_entity_decode($str, $style=ENT_NOQUOTES) { |
| 259 | 269 | return strtr($str, |
| 260 | 270 | array_flip(get_html_translation_table(HTML_ENTITIES,$style))); |
@@ -283,6 +293,7 @@ discard block |
||
| 283 | 293 | * Constructs TSax3_Entities_Unparsed |
| 284 | 294 | * @param object handler object being decorated |
| 285 | 295 | * @param string original handler method |
| 296 | + * @param string $orig_method |
|
| 286 | 297 | * @access protected |
| 287 | 298 | */ |
| 288 | 299 | function __construct(&$orig_obj, $orig_method) { |
@@ -326,6 +337,7 @@ discard block |
||
| 326 | 337 | * Constructs TSax3_Entities_Unparsed |
| 327 | 338 | * @param object handler object being decorated |
| 328 | 339 | * @param string original handler method |
| 340 | + * @param string $orig_method |
|
| 329 | 341 | * @access protected |
| 330 | 342 | */ |
| 331 | 343 | function __construct(&$orig_obj, $orig_method) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @access protected |
| 52 | 52 | */ |
| 53 | 53 | function __construct(&$orig_obj, $orig_method) { |
| 54 | - $this->orig_obj =& $orig_obj; |
|
| 54 | + $this->orig_obj = & $orig_obj; |
|
| 55 | 55 | $this->orig_method = $orig_method; |
| 56 | 56 | } |
| 57 | 57 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @access protected |
| 100 | 100 | */ |
| 101 | 101 | function __construct(&$orig_obj, $orig_open_method, $orig_close_method) { |
| 102 | - $this->orig_obj =& $orig_obj; |
|
| 102 | + $this->orig_obj = & $orig_obj; |
|
| 103 | 103 | $this->orig_open_method = $orig_open_method; |
| 104 | 104 | $this->orig_close_method = $orig_close_method; |
| 105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param array tag attributes |
| 111 | 111 | * @access protected |
| 112 | 112 | */ |
| 113 | - function foldOpen(&$parser, $tag, $attrs=array(), $empty = FALSE) { |
|
| 113 | + function foldOpen(&$parser, $tag, $attrs = array(), $empty = FALSE) { |
|
| 114 | 114 | $this->orig_obj->{$this->orig_open_method}($parser, strtoupper($tag), $attrs, $empty); |
| 115 | 115 | } |
| 116 | 116 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @access protected |
| 150 | 150 | */ |
| 151 | 151 | function __construct(&$orig_obj, $orig_method) { |
| 152 | - $this->orig_obj =& $orig_obj; |
|
| 152 | + $this->orig_obj = & $orig_obj; |
|
| 153 | 153 | $this->orig_method = $orig_method; |
| 154 | 154 | } |
| 155 | 155 | /** |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | * @access protected |
| 160 | 160 | */ |
| 161 | 161 | function breakData(&$parser, $data) { |
| 162 | - $data = explode("\n",$data); |
|
| 163 | - foreach ( $data as $chunk ) { |
|
| 162 | + $data = explode("\n", $data); |
|
| 163 | + foreach ($data as $chunk) { |
|
| 164 | 164 | $this->orig_obj->{$this->orig_method}($parser, $chunk); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @access protected |
| 192 | 192 | */ |
| 193 | 193 | function __construct(&$orig_obj, $orig_method) { |
| 194 | - $this->orig_obj =& $orig_obj; |
|
| 194 | + $this->orig_obj = & $orig_obj; |
|
| 195 | 195 | $this->orig_method = $orig_method; |
| 196 | 196 | } |
| 197 | 197 | /** |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | * @access protected |
| 202 | 202 | */ |
| 203 | 203 | function breakData(&$parser, $data) { |
| 204 | - $data = explode("\t",$data); |
|
| 205 | - foreach ( $data as $chunk ) { |
|
| 204 | + $data = explode("\t", $data); |
|
| 205 | + foreach ($data as $chunk) { |
|
| 206 | 206 | $this->orig_obj->{$this->orig_method}($this, $chunk); |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @access protected |
| 235 | 235 | */ |
| 236 | 236 | function __construct(&$orig_obj, $orig_method) { |
| 237 | - $this->orig_obj =& $orig_obj; |
|
| 237 | + $this->orig_obj = & $orig_obj; |
|
| 238 | 238 | $this->orig_method = $orig_method; |
| 239 | 239 | } |
| 240 | 240 | /** |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | * @access protected |
| 245 | 245 | */ |
| 246 | 246 | function breakData(&$parser, $data) { |
| 247 | - $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 248 | - foreach ( $data as $chunk ) { |
|
| 249 | - $chunk = html_entity_decode($chunk,ENT_NOQUOTES); |
|
| 247 | + $data = preg_split('/(&.+?;)/', $data, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 248 | + foreach ($data as $chunk) { |
|
| 249 | + $chunk = html_entity_decode($chunk, ENT_NOQUOTES); |
|
| 250 | 250 | $this->orig_obj->{$this->orig_method}($this, $chunk); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | /** |
| 255 | 255 | * Compatibility with older PHP versions |
| 256 | 256 | */ |
| 257 | -if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode') ) { |
|
| 258 | - function html_entity_decode($str, $style=ENT_NOQUOTES) { |
|
| 257 | +if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode')) { |
|
| 258 | + function html_entity_decode($str, $style = ENT_NOQUOTES) { |
|
| 259 | 259 | return strtr($str, |
| 260 | - array_flip(get_html_translation_table(HTML_ENTITIES,$style))); |
|
| 260 | + array_flip(get_html_translation_table(HTML_ENTITIES, $style))); |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | /** |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * @access protected |
| 287 | 287 | */ |
| 288 | 288 | function __construct(&$orig_obj, $orig_method) { |
| 289 | - $this->orig_obj =& $orig_obj; |
|
| 289 | + $this->orig_obj = & $orig_obj; |
|
| 290 | 290 | $this->orig_method = $orig_method; |
| 291 | 291 | } |
| 292 | 292 | /** |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | * @access protected |
| 297 | 297 | */ |
| 298 | 298 | function breakData(&$parser, $data) { |
| 299 | - $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 300 | - foreach ( $data as $chunk ) { |
|
| 299 | + $data = preg_split('/(&.+?;)/', $data, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 300 | + foreach ($data as $chunk) { |
|
| 301 | 301 | $this->orig_obj->{$this->orig_method}($this, $chunk); |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @access protected |
| 330 | 330 | */ |
| 331 | 331 | function __construct(&$orig_obj, $orig_method) { |
| 332 | - $this->orig_obj =& $orig_obj; |
|
| 332 | + $this->orig_obj = & $orig_obj; |
|
| 333 | 333 | $this->orig_method = $orig_method; |
| 334 | 334 | } |
| 335 | 335 | /** |
@@ -340,20 +340,20 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | function strip(&$parser, $data) { |
| 342 | 342 | // Check for HTML comments first |
| 343 | - if ( substr($data,0,2) == '--' ) { |
|
| 343 | + if (substr($data, 0, 2) == '--') { |
|
| 344 | 344 | $patterns = array( |
| 345 | - '/^\-\-/', // Opening comment: -- |
|
| 346 | - '/\-\-$/', // Closing comment: -- |
|
| 345 | + '/^\-\-/', // Opening comment: -- |
|
| 346 | + '/\-\-$/', // Closing comment: -- |
|
| 347 | 347 | ); |
| 348 | - $data = preg_replace($patterns,'',$data); |
|
| 348 | + $data = preg_replace($patterns, '', $data); |
|
| 349 | 349 | |
| 350 | 350 | // Check for XML CDATA sections (note: don't do both!) |
| 351 | - } else if ( substr($data,0,1) == '[' ) { |
|
| 351 | + } else if (substr($data, 0, 1) == '[') { |
|
| 352 | 352 | $patterns = array( |
| 353 | 353 | '/^\[.*CDATA.*\[/s', // Opening CDATA |
| 354 | - '/\].*\]$/s', // Closing CDATA |
|
| 354 | + '/\].*\]$/s', // Closing CDATA |
|
| 355 | 355 | ); |
| 356 | - $data = preg_replace($patterns,'',$data); |
|
| 356 | + $data = preg_replace($patterns, '', $data); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | $this->orig_obj->{$this->orig_method}($this, $data); |
@@ -480,7 +480,7 @@ |
||
| 480 | 480 | /** |
| 481 | 481 | * Closing tag handler - called from HTMLSax |
| 482 | 482 | * |
| 483 | - * @param object $parsers HTML parser |
|
| 483 | + * @param object $parser HTML parser |
|
| 484 | 484 | * @param string $name tag name |
| 485 | 485 | * @return boolean |
| 486 | 486 | * @access private |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @var array |
| 136 | 136 | * @access public |
| 137 | 137 | */ |
| 138 | - public $singleTags = array('area', 'br', 'img', 'input', 'hr', 'wbr', ); |
|
| 138 | + public $singleTags = array('area', 'br', 'img', 'input', 'hr', 'wbr',); |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * List of dangerous tags (such tags will be deleted) |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | * @access public |
| 145 | 145 | */ |
| 146 | 146 | public $deleteTags = array( |
| 147 | - 'applet', 'base', 'basefont', 'bgsound', 'blink', 'body', |
|
| 148 | - 'embed', 'frame', 'frameset', 'head', 'html', 'ilayer', |
|
| 149 | - 'iframe', 'layer', 'link', 'meta', 'object', 'style', |
|
| 150 | - 'title', 'script', |
|
| 147 | + 'applet', 'base', 'basefont', 'bgsound', 'blink', 'body', |
|
| 148 | + 'embed', 'frame', 'frameset', 'head', 'html', 'ilayer', |
|
| 149 | + 'iframe', 'layer', 'link', 'meta', 'object', 'style', |
|
| 150 | + 'title', 'script', |
|
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @var array |
| 158 | 158 | * @access public |
| 159 | 159 | */ |
| 160 | - public $deleteTagsContent = array('script', 'style', 'title', 'xml', ); |
|
| 160 | + public $deleteTagsContent = array('script', 'style', 'title', 'xml',); |
|
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Type of protocols filtering ('white' or 'black') |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | * @access public |
| 175 | 175 | */ |
| 176 | 176 | public $blackProtocols = array( |
| 177 | - 'about', 'chrome', 'data', 'disk', 'hcp', |
|
| 178 | - 'help', 'javascript', 'livescript', 'lynxcgi', 'lynxexec', |
|
| 179 | - 'ms-help', 'ms-its', 'mhtml', 'mocha', 'opera', |
|
| 180 | - 'res', 'resource', 'shell', 'vbscript', 'view-source', |
|
| 181 | - 'vnd.ms.radio', 'wysiwyg', |
|
| 177 | + 'about', 'chrome', 'data', 'disk', 'hcp', |
|
| 178 | + 'help', 'javascript', 'livescript', 'lynxcgi', 'lynxexec', |
|
| 179 | + 'ms-help', 'ms-its', 'mhtml', 'mocha', 'opera', |
|
| 180 | + 'res', 'resource', 'shell', 'vbscript', 'view-source', |
|
| 181 | + 'vnd.ms.radio', 'wysiwyg', |
|
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | * @access public |
| 189 | 189 | */ |
| 190 | 190 | public $whiteProtocols = array( |
| 191 | - 'ed2k', 'file', 'ftp', 'gopher', 'http', 'https', |
|
| 192 | - 'irc', 'mailto', 'news', 'nntp', 'telnet', 'webcal', |
|
| 193 | - 'xmpp', 'callto', |
|
| 191 | + 'ed2k', 'file', 'ftp', 'gopher', 'http', 'https', |
|
| 192 | + 'irc', 'mailto', 'news', 'nntp', 'telnet', 'webcal', |
|
| 193 | + 'xmpp', 'callto', |
|
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | * @access public |
| 214 | 214 | */ |
| 215 | 215 | public $cssKeywords = array( |
| 216 | - 'absolute', 'behavior', 'behaviour', 'content', 'expression', |
|
| 217 | - 'fixed', 'include-source', 'moz-binding', |
|
| 216 | + 'absolute', 'behavior', 'behaviour', 'content', 'expression', |
|
| 217 | + 'fixed', 'include-source', 'moz-binding', |
|
| 218 | 218 | ); |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | * @access public |
| 236 | 236 | */ |
| 237 | 237 | public $closeParagraph = array( |
| 238 | - 'address', 'blockquote', 'center', 'dd', 'dir', 'div', |
|
| 239 | - 'dl', 'dt', 'h1', 'h2', 'h3', 'h4', |
|
| 240 | - 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee', |
|
| 241 | - 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre', |
|
| 242 | - 'table', 'ul', 'xmp', |
|
| 238 | + 'address', 'blockquote', 'center', 'dd', 'dir', 'div', |
|
| 239 | + 'dl', 'dt', 'h1', 'h2', 'h3', 'h4', |
|
| 240 | + 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee', |
|
| 241 | + 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre', |
|
| 242 | + 'table', 'ul', 'xmp', |
|
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public $tableTags = array( |
| 252 | 252 | 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', |
| 253 | - 'thead', 'tr', |
|
| 253 | + 'thead', 'tr', |
|
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @var array |
| 260 | 260 | * @access public |
| 261 | 261 | */ |
| 262 | - public $listTags = array('dir', 'menu', 'ol', 'ul', 'dl', ); |
|
| 262 | + public $listTags = array('dir', 'menu', 'ol', 'ul', 'dl',); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * List of dangerous attributes |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @var array |
| 277 | 277 | * @access public |
| 278 | 278 | */ |
| 279 | - public $attributesNS = array('xml:lang', ); |
|
| 279 | + public $attributesNS = array('xml:lang',); |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Constructs class |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | //making regular expressions based on Proto & CSS arrays |
| 289 | 289 | foreach ($this->blackProtocols as $proto) { |
| 290 | 290 | $preg = "/[\s\x01-\x1F]*"; |
| 291 | - for ($i=0; $i<strlen($proto); $i++) { |
|
| 291 | + for ($i = 0; $i < strlen($proto); $i++) { |
|
| 292 | 292 | $preg .= $proto{$i} . "[\s\x01-\x1F]*"; |
| 293 | 293 | } |
| 294 | 294 | $preg .= ":/i"; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @return boolean |
| 309 | 309 | * @access private |
| 310 | 310 | */ |
| 311 | - private function _writeAttrs ($attrs) |
|
| 311 | + private function _writeAttrs($attrs) |
|
| 312 | 312 | { |
| 313 | 313 | if (is_array($attrs)) { |
| 314 | 314 | foreach ($attrs as $name => $value) { |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | $tempval = preg_replace_callback( |
| 368 | 368 | '/&#(\d+);?/m', |
| 369 | - function ($matches) { |
|
| 369 | + function($matches) { |
|
| 370 | 370 | return chr($matches[0]); |
| 371 | 371 | }, |
| 372 | 372 | $value |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | $tempval = preg_replace_callback( |
| 376 | 376 | '/&#x([0-9a-f]+);?/mi', |
| 377 | - function ($matches) { |
|
| 377 | + function($matches) { |
|
| 378 | 378 | return chr(hexdec($matches[0])); |
| 379 | 379 | }, |
| 380 | 380 | $tempval |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | if (in_array($name, $this->deleteTagsContent)) { |
| 420 | 420 | array_push($this->_dcStack, $name); |
| 421 | - $this->_dcCounter[$name] = isset($this->_dcCounter[$name]) ? $this->_dcCounter[$name]+1 : 1; |
|
| 421 | + $this->_dcCounter[$name] = isset($this->_dcCounter[$name]) ? $this->_dcCounter[$name] + 1 : 1; |
|
| 422 | 422 | } |
| 423 | 423 | if (count($this->_dcStack) != 0) { |
| 424 | 424 | return true; |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | // LISTS: we should close <li> if <li> of the same level opening |
| 458 | 458 | if ($name == 'li' && count($this->_liStack) && |
| 459 | - $this->_listScope == $this->_liStack[count($this->_liStack)-1]) |
|
| 459 | + $this->_listScope == $this->_liStack[count($this->_liStack) - 1]) |
|
| 460 | 460 | { |
| 461 | 461 | $this->_closeHandler($parser, 'li'); |
| 462 | 462 | } |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | $this->_xhtml .= '<' . $name; |
| 473 | 473 | $this->_writeAttrs($attrs); |
| 474 | 474 | $this->_xhtml .= '>'; |
| 475 | - array_push($this->_stack,$name); |
|
| 476 | - $this->_counter[$name] = isset($this->_counter[$name]) ? $this->_counter[$name]+1 : 1; |
|
| 475 | + array_push($this->_stack, $name); |
|
| 476 | + $this->_counter[$name] = isset($this->_counter[$name]) ? $this->_counter[$name] + 1 : 1; |
|
| 477 | 477 | return true; |
| 478 | 478 | } |
| 479 | 479 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * @return string Processed (X)HTML document |
| 575 | 575 | * @access public |
| 576 | 576 | */ |
| 577 | - public function getXHTML () |
|
| 577 | + public function getXHTML() |
|
| 578 | 578 | { |
| 579 | 579 | while ($tag = array_pop($this->_stack)) { |
| 580 | 580 | $this->_closeTag($tag); |
@@ -602,12 +602,12 @@ discard block |
||
| 602 | 602 | * @return string Processed (X)HTML document |
| 603 | 603 | * @access public |
| 604 | 604 | */ |
| 605 | - public function parse($doc, $isUTF7=false) |
|
| 605 | + public function parse($doc, $isUTF7 = false) |
|
| 606 | 606 | { |
| 607 | 607 | $this->clear(); |
| 608 | 608 | |
| 609 | 609 | // Save all '<' symbols |
| 610 | - $doc = preg_replace("/<(?=[^a-zA-Z\/\!\?\%])/", '<', (string)$doc); |
|
| 610 | + $doc = preg_replace("/<(?=[^a-zA-Z\/\!\?\%])/", '<', (string) $doc); |
|
| 611 | 611 | |
| 612 | 612 | // Web documents shouldn't contains \x00 symbol |
| 613 | 613 | $doc = str_replace("\x00", '', $doc); |
@@ -616,16 +616,16 @@ discard block |
||
| 616 | 616 | $doc = str_replace("\xC0\xBC", '<', $doc); |
| 617 | 617 | |
| 618 | 618 | // UTF-7 encoding ASCII decode |
| 619 | - if($isUTF7) |
|
| 619 | + if ($isUTF7) |
|
| 620 | 620 | $doc = $this->repackUTF7($doc); |
| 621 | 621 | |
| 622 | 622 | // Instantiate the parser |
| 623 | - $parser= new TSax3(); |
|
| 623 | + $parser = new TSax3(); |
|
| 624 | 624 | |
| 625 | 625 | // Set up the parser |
| 626 | 626 | $parser->set_object($this); |
| 627 | 627 | |
| 628 | - $parser->set_element_handler('_openHandler','_closeHandler'); |
|
| 628 | + $parser->set_element_handler('_openHandler', '_closeHandler'); |
|
| 629 | 629 | $parser->set_data_handler('_dataHandler'); |
| 630 | 630 | $parser->set_escape_handler('_escapeHandler'); |
| 631 | 631 | |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | */ |
| 672 | 672 | private function repackUTF7Back($str) |
| 673 | 673 | { |
| 674 | - return $str[1].'+'.rtrim(base64_encode($str[2]), '=').'-'; |
|
| 674 | + return $str[1] . '+' . rtrim(base64_encode($str[2]), '=') . '-'; |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
@@ -151,7 +151,6 @@ discard block |
||
| 151 | 151 | * Called by subclssses' constructors to enable/disable |
| 152 | 152 | * optional highlighter rules |
| 153 | 153 | * |
| 154 | - * @param array $defines Conditional defines |
|
| 155 | 154 | * |
| 156 | 155 | * @access protected |
| 157 | 156 | */ |
@@ -232,6 +231,7 @@ discard block |
||
| 232 | 231 | * Helper function to find matching brackets |
| 233 | 232 | * |
| 234 | 233 | * @access private |
| 234 | + * @param string $str |
|
| 235 | 235 | */ |
| 236 | 236 | function _matchingBrackets($str) |
| 237 | 237 | { |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * use numbered list |
| 34 | 34 | */ |
| 35 | - define ('HL_NUMBERS_LI' , 1); |
|
| 35 | + define('HL_NUMBERS_LI', 1); |
|
| 36 | 36 | /** |
| 37 | 37 | * Use 2-column table with line numbers in left column and code in right column. |
| 38 | 38 | * Forces $options['tag'] = HL_TAG_PRE |
| 39 | 39 | */ |
| 40 | - define ('HL_NUMBERS_TABLE' , 2); |
|
| 40 | + define('HL_NUMBERS_TABLE', 2); |
|
| 41 | 41 | /**#@-*/ |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * for our purpose, it is infinity |
| 48 | 48 | */ |
| 49 | -define ('HL_INFINITY', 1000000000); |
|
| 49 | +define('HL_INFINITY', 1000000000); |
|
| 50 | 50 | |
| 51 | 51 | // }}} |
| 52 | 52 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $defines = array(); |
| 164 | 164 | } |
| 165 | 165 | foreach ($this->_conditions as $name => $actions) { |
| 166 | - foreach($actions as $action) { |
|
| 166 | + foreach ($actions as $action) { |
|
| 167 | 167 | $present = in_array($name, $defines); |
| 168 | 168 | if (!$action[1]) { |
| 169 | 169 | $present = !$present; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public static function factory($lang, $options = array()) |
| 198 | 198 | { |
| 199 | 199 | $lang = strtoupper($lang); |
| 200 | - $langFile = dirname(__FILE__)."/Highlighter/$lang.php"; |
|
| 200 | + $langFile = dirname(__FILE__) . "/Highlighter/$lang.php"; |
|
| 201 | 201 | if (is_file($langFile)) |
| 202 | 202 | include_once $langFile; |
| 203 | 203 | else |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } else { |
| 257 | 257 | $endpos = -1; |
| 258 | 258 | } |
| 259 | - preg_match ($this->_regs[$this->_state], $this->_str, $m, PREG_OFFSET_CAPTURE, $this->_pos); |
|
| 259 | + preg_match($this->_regs[$this->_state], $this->_str, $m, PREG_OFFSET_CAPTURE, $this->_pos); |
|
| 260 | 260 | $n = 1; |
| 261 | 261 | |
| 262 | 262 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | if (!isset($m[$n])) { |
| 265 | 265 | break; |
| 266 | 266 | } |
| 267 | - if ($m[$n][1]>-1 && ($endpos == -1 || $m[$n][1] < $endpos)) { |
|
| 267 | + if ($m[$n][1] > -1 && ($endpos == -1 || $m[$n][1] < $endpos)) { |
|
| 268 | 268 | if ($this->_states[$this->_state][$i] != -1) { |
| 269 | 269 | $this->_tokenStack[] = array($this->_delim[$this->_state][$i], $m[$n][0]); |
| 270 | 270 | } else { |
@@ -272,17 +272,17 @@ discard block |
||
| 272 | 272 | if (isset($this->_parts[$this->_state][$i])) { |
| 273 | 273 | $parts = array(); |
| 274 | 274 | $partpos = $m[$n][1]; |
| 275 | - for ($j=1; $j<=$count; $j++) { |
|
| 276 | - if ($m[$j+$n][1] < 0) { |
|
| 275 | + for ($j = 1; $j <= $count; $j++) { |
|
| 276 | + if ($m[$j + $n][1] < 0) { |
|
| 277 | 277 | continue; |
| 278 | 278 | } |
| 279 | 279 | if (isset($this->_parts[$this->_state][$i][$j])) { |
| 280 | - if ($m[$j+$n][1] > $partpos) { |
|
| 281 | - array_unshift($parts, array($inner, substr($this->_str, $partpos, $m[$j+$n][1]-$partpos))); |
|
| 280 | + if ($m[$j + $n][1] > $partpos) { |
|
| 281 | + array_unshift($parts, array($inner, substr($this->_str, $partpos, $m[$j + $n][1] - $partpos))); |
|
| 282 | 282 | } |
| 283 | - array_unshift($parts, array($this->_parts[$this->_state][$i][$j], $m[$j+$n][0])); |
|
| 283 | + array_unshift($parts, array($this->_parts[$this->_state][$i][$j], $m[$j + $n][0])); |
|
| 284 | 284 | } |
| 285 | - $partpos = $m[$j+$n][1] + strlen($m[$j+$n][0]); |
|
| 285 | + $partpos = $m[$j + $n][1] + strlen($m[$j + $n][0]); |
|
| 286 | 286 | } |
| 287 | 287 | if ($partpos < $m[$n][1] + strlen($m[$n][0])) { |
| 288 | 288 | array_unshift($parts, array($inner, substr($this->_str, $partpos, $m[$n][1] - $partpos + strlen($m[$n][0])))); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | if ($m[$n][1] > $this->_pos) { |
| 305 | - $this->_tokenStack[] = array($this->_lastinner, substr($this->_str, $this->_pos, $m[$n][1]-$this->_pos)); |
|
| 305 | + $this->_tokenStack[] = array($this->_lastinner, substr($this->_str, $this->_pos, $m[$n][1] - $this->_pos)); |
|
| 306 | 306 | } |
| 307 | 307 | $this->_pos = $m[$n][1] + strlen($m[$n][0]); |
| 308 | 308 | if ($this->_states[$this->_state][$i] != -1) { |
@@ -313,13 +313,13 @@ discard block |
||
| 313 | 313 | $this->_state = $this->_states[$this->_state][$i]; |
| 314 | 314 | $this->_endpattern = $this->_end[$this->_state]; |
| 315 | 315 | if ($this->_subst[$l][$i]) { |
| 316 | - for ($k=0; $k<=$this->_counts[$l][$i]; $k++) { |
|
| 317 | - if (!isset($m[$i+$k])) { |
|
| 316 | + for ($k = 0; $k <= $this->_counts[$l][$i]; $k++) { |
|
| 317 | + if (!isset($m[$i + $k])) { |
|
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | - $quoted = preg_quote($m[$n+$k][0], '/'); |
|
| 321 | - $this->_endpattern = str_replace('%'.$k.'%', $quoted, $this->_endpattern); |
|
| 322 | - $this->_endpattern = str_replace('%b'.$k.'%', $this->_matchingBrackets($quoted), $this->_endpattern); |
|
| 320 | + $quoted = preg_quote($m[$n + $k][0], '/'); |
|
| 321 | + $this->_endpattern = str_replace('%' . $k . '%', $quoted, $this->_endpattern); |
|
| 322 | + $this->_endpattern = str_replace('%b' . $k . '%', $this->_matchingBrackets($quoted), $this->_endpattern); |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | if ($endpos > -1) { |
| 332 | 332 | $this->_tokenStack[] = array($this->_lastdelim, $endmatch); |
| 333 | 333 | if ($endpos > $this->_pos) { |
| 334 | - $this->_tokenStack[] = array($this->_lastinner, substr($this->_str, $this->_pos, $endpos-$this->_pos)); |
|
| 334 | + $this->_tokenStack[] = array($this->_lastinner, substr($this->_str, $this->_pos, $endpos - $this->_pos)); |
|
| 335 | 335 | } |
| 336 | 336 | list($this->_state, $this->_lastdelim, $this->_lastinner, $this->_endpattern) = array_pop($this->_stack); |
| 337 | 337 | $this->_pos = $endpos + strlen($endmatch); |