@@ -75,7 +75,7 @@ |
||
75 | 75 | protected $maxChunkLength = 4194304; |
76 | 76 | |
77 | 77 | /** |
78 | - * @param array $options passed to the xml parser |
|
78 | + * @param string[] $options passed to the xml parser |
|
79 | 79 | */ |
80 | 80 | public function __construct(array $options = array()) |
81 | 81 | { |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | $this->accept = $accept; |
134 | 134 | |
135 | 135 | // @see ticket #70 - we have to parse big xml docks in chunks to avoid errors |
136 | - for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) { |
|
136 | + for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) { |
|
137 | 137 | $chunk = substr($data, $offset, $this->maxChunkLength); |
138 | 138 | // error handling: xml not well formed |
139 | - if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) { |
|
139 | + if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) { |
|
140 | 140 | $errCode = xml_get_error_code($parser); |
141 | 141 | $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode), |
142 | 142 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) |
161 | 161 | { |
162 | 162 | // if invalid xmlrpc already detected, skip all processing |
163 | - if ($this->_xh['isf'] < 2) { |
|
163 | + if ($this->_xh['isf']<2) { |
|
164 | 164 | |
165 | 165 | // check for correct element nesting |
166 | 166 | if (count($this->_xh['stack']) == 0) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $this->_xh['rt'] = strtolower($name); |
180 | 180 | } else { |
181 | 181 | $this->_xh['isf'] = 2; |
182 | - $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name; |
|
182 | + $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name; |
|
183 | 183 | |
184 | 184 | return; |
185 | 185 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | break; |
274 | 274 | case 'MEMBER': |
275 | 275 | // set member name to null, in case we do not find in the xml later on |
276 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = ''; |
|
276 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = ''; |
|
277 | 277 | //$this->_xh['ac']=''; |
278 | 278 | // Drop trough intentionally |
279 | 279 | case 'PARAM': |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = true) |
335 | 335 | { |
336 | - if ($this->_xh['isf'] < 2) { |
|
336 | + if ($this->_xh['isf']<2) { |
|
337 | 337 | // push this element name from stack |
338 | 338 | // NB: if XML validates, correct opening/closing is guaranteed and |
339 | 339 | // we do not have to check for $name == $currElem. |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | // check if we are inside an array or struct: |
360 | 360 | // if value just built is inside an array, let's move it into array on the stack |
361 | 361 | $vscount = count($this->_xh['valuestack']); |
362 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
363 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $temp; |
|
362 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
363 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $temp; |
|
364 | 364 | } else { |
365 | 365 | $this->_xh['value'] = $temp; |
366 | 366 | } |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | // check if we are inside an array or struct: |
375 | 375 | // if value just built is inside an array, let's move it into array on the stack |
376 | 376 | $vscount = count($this->_xh['valuestack']); |
377 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
378 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value']; |
|
377 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
378 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value']; |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | break; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $this->_xh['value'] = $this->_xh['ac']; |
396 | 396 | } elseif ($name == 'DATETIME.ISO8601') { |
397 | 397 | if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) { |
398 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']); |
|
398 | + error_log('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']); |
|
399 | 399 | } |
400 | 400 | $this->_xh['vt'] = Value::$xmlrpcDateTime; |
401 | 401 | $this->_xh['value'] = $this->_xh['ac']; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } else { |
415 | 415 | // log if receiving something strange, even though we set the value to false anyway |
416 | 416 | if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) { |
417 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']); |
|
417 | + error_log('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']); |
|
418 | 418 | } |
419 | 419 | $this->_xh['value'] = false; |
420 | 420 | } |
@@ -424,37 +424,37 @@ discard block |
||
424 | 424 | // NOTE: regexp could be much stricter than this... |
425 | 425 | if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) { |
426 | 426 | /// @todo: find a better way of throwing an error than this! |
427 | - error_log('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']); |
|
427 | + error_log('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']); |
|
428 | 428 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
429 | 429 | } else { |
430 | 430 | // it's ok, add it on |
431 | - $this->_xh['value'] = (double)$this->_xh['ac']; |
|
431 | + $this->_xh['value'] = (double) $this->_xh['ac']; |
|
432 | 432 | } |
433 | 433 | } else { |
434 | 434 | // we have an I4/I8/INT |
435 | 435 | // we must check that only 0123456789-<space> are characters here |
436 | 436 | if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) { |
437 | 437 | /// @todo find a better way of throwing an error than this! |
438 | - error_log('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']); |
|
438 | + error_log('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']); |
|
439 | 439 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
440 | 440 | } else { |
441 | 441 | // it's ok, add it on |
442 | - $this->_xh['value'] = (int)$this->_xh['ac']; |
|
442 | + $this->_xh['value'] = (int) $this->_xh['ac']; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | $this->_xh['lv'] = 3; // indicate we've found a value |
446 | 446 | break; |
447 | 447 | case 'NAME': |
448 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac']; |
|
448 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac']; |
|
449 | 449 | break; |
450 | 450 | case 'MEMBER': |
451 | 451 | // add to array in the stack the last element built, |
452 | 452 | // unless no VALUE was found |
453 | 453 | if ($this->_xh['vt']) { |
454 | 454 | $vscount = count($this->_xh['valuestack']); |
455 | - $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value']; |
|
455 | + $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value']; |
|
456 | 456 | } else { |
457 | - error_log('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml'); |
|
457 | + error_log('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml'); |
|
458 | 458 | } |
459 | 459 | break; |
460 | 460 | case 'DATA': |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $this->_xh['params'][] = $this->_xh['value']; |
478 | 478 | $this->_xh['pt'][] = $this->_xh['vt']; |
479 | 479 | } else { |
480 | - error_log('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml'); |
|
480 | + error_log('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml'); |
|
481 | 481 | } |
482 | 482 | break; |
483 | 483 | case 'METHODNAME': |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | public function xmlrpc_cd($parser, $data) |
524 | 524 | { |
525 | 525 | // skip processing if xml fault already detected |
526 | - if ($this->_xh['isf'] < 2) { |
|
526 | + if ($this->_xh['isf']<2) { |
|
527 | 527 | // "lookforvalue==3" means that we've found an entire value |
528 | 528 | // and should discard any further character data |
529 | 529 | if ($this->_xh['lv'] != 3) { |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | public function xmlrpc_dh($parser, $data) |
542 | 542 | { |
543 | 543 | // skip processing if xml fault already detected |
544 | - if ($this->_xh['isf'] < 2) { |
|
544 | + if ($this->_xh['isf']<2) { |
|
545 | 545 | if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') { |
546 | 546 | $this->_xh['ac'] .= $data; |
547 | 547 | } |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | // Details: |
613 | 613 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
614 | 614 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
615 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
616 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
615 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
616 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
617 | 617 | $xmlChunk, $matches)) { |
618 | 618 | return strtoupper(substr($matches[2], 1, -1)); |
619 | 619 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
632 | 632 | // IANA also likes better US-ASCII, so go with it |
633 | 633 | if ($enc == 'ASCII') { |
634 | - $enc = 'US-' . $enc; |
|
634 | + $enc = 'US-'.$enc; |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | return $enc; |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | // Details: |
667 | 667 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
668 | 668 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
669 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
670 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
669 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
670 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
671 | 671 | $xmlChunk, $matches)) { |
672 | 672 | return true; |
673 | 673 | } |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * NB: do not let your IDE fool you. The correct encoding for this file is NOT UTF8. |
4 | 4 | */ |
5 | -include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
6 | -include_once __DIR__ . '/../lib/xmlrpcs.inc'; |
|
5 | +include_once __DIR__.'/../lib/xmlrpc.inc'; |
|
6 | +include_once __DIR__.'/../lib/xmlrpcs.inc'; |
|
7 | 7 | |
8 | -include_once __DIR__ . '/parse_args.php'; |
|
8 | +include_once __DIR__.'/parse_args.php'; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Tests involving parsing of xml and handling of xmlrpc values |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function testUnicodeInMemberName() |
63 | 63 | { |
64 | - $str = "G" . chr(252) . "nter, El" . chr(232) . "ne"; |
|
64 | + $str = "G".chr(252)."nter, El".chr(232)."ne"; |
|
65 | 65 | $v = array($str => new xmlrpcval(1)); |
66 | 66 | $r = new xmlrpcresp(new xmlrpcval($v, 'struct')); |
67 | 67 | $r = $r->serialize(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <!-- $Id --> |
79 | 79 | <!-- found by G. giunta, covers what happens when lib receives |
80 | 80 | UTF8 chars in response text and comments --> |
81 | -<!-- ' . chr(224) . chr(252) . chr(232) . 'àüè --> |
|
81 | +<!-- ' . chr(224).chr(252).chr(232).'àüè --> |
|
82 | 82 | <methodResponse> |
83 | 83 | <fault> |
84 | 84 | <value> |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | </member> |
90 | 90 | <member> |
91 | 91 | <name>faultString</name> |
92 | -<value><string>' . chr(224) . chr(252) . chr(232) . 'àüè</string></value> |
|
92 | +<value><string>' . chr(224).chr(252).chr(232).'àüè</string></value> |
|
93 | 93 | </member> |
94 | 94 | </struct> |
95 | 95 | </value> |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $m = $this->newMsg('dummy'); |
99 | 99 | $r = $m->parseResponse($response); |
100 | 100 | $v = $r->faultString(); |
101 | - $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v); |
|
101 | + $this->assertEquals(chr(224).chr(252).chr(232).chr(224).chr(252).chr(232), $v); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | public function testValidNumbers() |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function testI8() |
161 | 161 | { |
162 | - if (PHP_INT_SIZE == 4 ) { |
|
162 | + if (PHP_INT_SIZE == 4) { |
|
163 | 163 | $this->markTestSkipped('did not find a locale which sets decimal separator to comma'); |
164 | 164 | return; |
165 | 165 | } |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | |
483 | 483 | public function testUTF8Response() |
484 | 484 | { |
485 | - $string = chr(224) . chr(252) . chr(232); |
|
485 | + $string = chr(224).chr(252).chr(232); |
|
486 | 486 | |
487 | 487 | $s = $this->newMsg('dummy'); |
488 | - $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
489 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
488 | + $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
489 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string).'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
490 | 490 | '; |
491 | 491 | $r = $s->parseResponse($f, false, 'phpvals'); |
492 | 492 | $v = $r->value(); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $this->assertEquals($string, $v); |
495 | 495 | |
496 | 496 | $f = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
497 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
497 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string).'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
498 | 498 | '; |
499 | 499 | $r = $s->parseResponse($f, false, 'phpvals'); |
500 | 500 | $v = $r->value(); |
@@ -509,11 +509,11 @@ discard block |
||
509 | 509 | |
510 | 510 | public function testLatin1Response() |
511 | 511 | { |
512 | - $string = chr(224) . chr(252) . chr(232); |
|
512 | + $string = chr(224).chr(252).chr(232); |
|
513 | 513 | |
514 | 514 | $s = $this->newMsg('dummy'); |
515 | - $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
516 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
515 | + $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
516 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string.'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
517 | 517 | '; |
518 | 518 | $r = $s->parseResponse($f, false, 'phpvals'); |
519 | 519 | $v = $r->value(); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | $this->assertEquals($string, $v); |
522 | 522 | |
523 | 523 | $f = '<?xml version="1.0" encoding="ISO-8859-1"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
524 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
524 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string.'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
525 | 525 | '; |
526 | 526 | $r = $s->parseResponse($f, false, 'phpvals'); |
527 | 527 | $v = $r->value(); |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $this->assertequals(1, count($v1)); |
617 | 617 | $out = array('me' => array(), 'mytype' => 2, '_php_class' => null); |
618 | 618 | |
619 | - foreach($v1 as $key => $val) |
|
619 | + foreach ($v1 as $key => $val) |
|
620 | 620 | { |
621 | 621 | $this->assertArrayHasKey($key, $out); |
622 | 622 | $expected = $out[$key]; |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | $this->assertequals(2, count($v2)); |
632 | 632 | $out = array(array('key' => 0, 'value' => 'object'), array('key' => 1, 'value' => 'object')); |
633 | 633 | $i = 0; |
634 | - foreach($v2 as $key => $val) |
|
634 | + foreach ($v2 as $key => $val) |
|
635 | 635 | { |
636 | 636 | $expected = $out[$i]; |
637 | 637 | $this->assertequals($expected['key'], $key); |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | { |
645 | 645 | // nb: make sure that the serialized xml corresponding to this is > 10MB in size |
646 | 646 | $data = array(); |
647 | - for ($i = 0; $i < 500000; $i++ ) { |
|
647 | + for ($i = 0; $i<500000; $i++) { |
|
648 | 648 | $data[] = 'hello world'; |
649 | 649 | } |
650 | 650 |