@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | */ |
60 | 60 | private function __construct() |
61 | 61 | { |
62 | - for ($i = 0; $i < 32; $i++) { |
|
62 | + for ($i = 0; $i<32; $i++) { |
|
63 | 63 | $this->xml_iso88591_Entities["in"][] = chr($i); |
64 | 64 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
65 | 65 | } |
66 | 66 | |
67 | - for ($i = 160; $i < 256; $i++) { |
|
67 | + for ($i = 160; $i<256; $i++) { |
|
68 | 68 | $this->xml_iso88591_Entities["in"][] = chr($i); |
69 | 69 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
70 | 70 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding; |
102 | 102 | } |
103 | 103 | |
104 | - $conversion = strtoupper($srcEncoding . '_' . $destEncoding); |
|
104 | + $conversion = strtoupper($srcEncoding.'_'.$destEncoding); |
|
105 | 105 | switch ($conversion) { |
106 | 106 | case 'ISO-8859-1_': |
107 | 107 | case 'ISO-8859-1_US-ASCII': |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
131 | 131 | $escapedData = ''; |
132 | 132 | // be kind to users creating string xmlrpc values out of different php types |
133 | - $data = (string)$data; |
|
133 | + $data = (string) $data; |
|
134 | 134 | $ns = strlen($data); |
135 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
135 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
136 | 136 | $ch = $data[$nn]; |
137 | 137 | $ii = ord($ch); |
138 | 138 | // 7 bits: 0bbbbbbb (127) |
139 | - if ($ii < 128) { |
|
139 | + if ($ii<128) { |
|
140 | 140 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
141 | 141 | switch ($ii) { |
142 | 142 | case 34: |
@@ -160,33 +160,33 @@ discard block |
||
160 | 160 | } // 11 bits: 110bbbbb 10bbbbbb (2047) |
161 | 161 | elseif ($ii >> 5 == 6) { |
162 | 162 | $b1 = ($ii & 31); |
163 | - $ii = ord($data[$nn + 1]); |
|
163 | + $ii = ord($data[$nn+1]); |
|
164 | 164 | $b2 = ($ii & 63); |
165 | - $ii = ($b1 * 64) + $b2; |
|
165 | + $ii = ($b1 * 64)+$b2; |
|
166 | 166 | $ent = sprintf('&#%d;', $ii); |
167 | 167 | $escapedData .= $ent; |
168 | 168 | $nn += 1; |
169 | 169 | } // 16 bits: 1110bbbb 10bbbbbb 10bbbbbb |
170 | 170 | elseif ($ii >> 4 == 14) { |
171 | 171 | $b1 = ($ii & 15); |
172 | - $ii = ord($data[$nn + 1]); |
|
172 | + $ii = ord($data[$nn+1]); |
|
173 | 173 | $b2 = ($ii & 63); |
174 | - $ii = ord($data[$nn + 2]); |
|
174 | + $ii = ord($data[$nn+2]); |
|
175 | 175 | $b3 = ($ii & 63); |
176 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
176 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
177 | 177 | $ent = sprintf('&#%d;', $ii); |
178 | 178 | $escapedData .= $ent; |
179 | 179 | $nn += 2; |
180 | 180 | } // 21 bits: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
181 | 181 | elseif ($ii >> 3 == 30) { |
182 | 182 | $b1 = ($ii & 7); |
183 | - $ii = ord($data[$nn + 1]); |
|
183 | + $ii = ord($data[$nn+1]); |
|
184 | 184 | $b2 = ($ii & 63); |
185 | - $ii = ord($data[$nn + 2]); |
|
185 | + $ii = ord($data[$nn+2]); |
|
186 | 186 | $b3 = ($ii & 63); |
187 | - $ii = ord($data[$nn + 3]); |
|
187 | + $ii = ord($data[$nn+3]); |
|
188 | 188 | $b4 = ($ii & 63); |
189 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
189 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
190 | 190 | $ent = sprintf('&#%d;', $ii); |
191 | 191 | $escapedData .= $ent; |
192 | 192 | $nn += 3; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | default: |
223 | 223 | $escapedData = ''; |
224 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
224 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $escapedData; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | case 'iso88591': |
276 | 276 | return $this->xml_iso88591_Entities; |
277 | 277 | default: |
278 | - throw new \Exception('Unsupported charset: ' . $charset); |
|
278 | + throw new \Exception('Unsupported charset: '.$charset); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | xml_set_object($parser, $this); |
125 | 125 | |
126 | - switch($returnType) { |
|
126 | + switch ($returnType) { |
|
127 | 127 | case self::RETURN_PHP: |
128 | 128 | xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); |
129 | 129 | break; |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | $this->accept = $accept; |
141 | 141 | |
142 | 142 | // @see ticket #70 - we have to parse big xml docks in chunks to avoid errors |
143 | - for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) { |
|
143 | + for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) { |
|
144 | 144 | $chunk = substr($data, $offset, $this->maxChunkLength); |
145 | 145 | // error handling: xml not well formed |
146 | - if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) { |
|
146 | + if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) { |
|
147 | 147 | $errCode = xml_get_error_code($parser); |
148 | 148 | $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode), |
149 | 149 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) |
168 | 168 | { |
169 | 169 | // if invalid xmlrpc already detected, skip all processing |
170 | - if ($this->_xh['isf'] < 2) { |
|
170 | + if ($this->_xh['isf']<2) { |
|
171 | 171 | |
172 | 172 | // check for correct element nesting |
173 | 173 | if (count($this->_xh['stack']) == 0) { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $this->_xh['rt'] = strtolower($name); |
188 | 188 | } else { |
189 | 189 | $this->_xh['isf'] = 2; |
190 | - $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name; |
|
190 | + $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name; |
|
191 | 191 | |
192 | 192 | return; |
193 | 193 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | break; |
282 | 282 | case 'MEMBER': |
283 | 283 | // set member name to null, in case we do not find in the xml later on |
284 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = ''; |
|
284 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = ''; |
|
285 | 285 | //$this->_xh['ac']=''; |
286 | 286 | // Drop trough intentionally |
287 | 287 | case 'PARAM': |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1) |
343 | 343 | { |
344 | - if ($this->_xh['isf'] < 2) { |
|
344 | + if ($this->_xh['isf']<2) { |
|
345 | 345 | // push this element name from stack |
346 | 346 | // NB: if XML validates, correct opening/closing is guaranteed and |
347 | 347 | // we do not have to check for $name == $currElem. |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $this->_xh['vt'] = Value::$xmlrpcString; |
357 | 357 | } |
358 | 358 | |
359 | - if ($rebuildXmlrpcvals > 0) { |
|
359 | + if ($rebuildXmlrpcvals>0) { |
|
360 | 360 | // build the xmlrpc val out of the data received, and substitute it |
361 | 361 | $temp = new Value($this->_xh['value'], $this->_xh['vt']); |
362 | 362 | // in case we got info about underlying php class, save it |
@@ -365,15 +365,15 @@ discard block |
||
365 | 365 | $temp->_php_class = $this->_xh['php_class']; |
366 | 366 | } |
367 | 367 | $this->_xh['value'] = $temp; |
368 | - } elseif ($rebuildXmlrpcvals < 0) { |
|
368 | + } elseif ($rebuildXmlrpcvals<0) { |
|
369 | 369 | if ($this->_xh['vt'] == Value::$xmlrpcDateTime) { |
370 | - $this->_xh['value'] = (object)array( |
|
370 | + $this->_xh['value'] = (object) array( |
|
371 | 371 | 'xmlrpc_type' => 'datetime', |
372 | 372 | 'scalar' => $this->_xh['value'], |
373 | 373 | 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($this->_xh['value']) |
374 | 374 | ); |
375 | 375 | } elseif ($this->_xh['vt'] == Value::$xmlrpcBase64) { |
376 | - $this->_xh['value'] = (object)array( |
|
376 | + $this->_xh['value'] = (object) array( |
|
377 | 377 | 'xmlrpc_type' => 'base64', |
378 | 378 | 'scalar' => $this->_xh['value'] |
379 | 379 | ); |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | // check if we are inside an array or struct: |
390 | 390 | // if value just built is inside an array, let's move it into array on the stack |
391 | 391 | $vscount = count($this->_xh['valuestack']); |
392 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
393 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value']; |
|
392 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
393 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value']; |
|
394 | 394 | } |
395 | 395 | break; |
396 | 396 | case 'BOOLEAN': |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | $this->_xh['value'] = $this->_xh['ac']; |
410 | 410 | } elseif ($name == 'DATETIME.ISO8601') { |
411 | 411 | if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) { |
412 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']); |
|
412 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']); |
|
413 | 413 | } |
414 | 414 | $this->_xh['vt'] = Value::$xmlrpcDateTime; |
415 | 415 | $this->_xh['value'] = $this->_xh['ac']; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | } else { |
429 | 429 | // log if receiving something strange, even though we set the value to false anyway |
430 | 430 | if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) { |
431 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']); |
|
431 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']); |
|
432 | 432 | } |
433 | 433 | $this->_xh['value'] = false; |
434 | 434 | } |
@@ -438,37 +438,37 @@ discard block |
||
438 | 438 | // NOTE: regexp could be much stricter than this... |
439 | 439 | if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) { |
440 | 440 | /// @todo: find a better way of throwing an error than this! |
441 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']); |
|
441 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']); |
|
442 | 442 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
443 | 443 | } else { |
444 | 444 | // it's ok, add it on |
445 | - $this->_xh['value'] = (double)$this->_xh['ac']; |
|
445 | + $this->_xh['value'] = (double) $this->_xh['ac']; |
|
446 | 446 | } |
447 | 447 | } else { |
448 | 448 | // we have an I4/I8/INT |
449 | 449 | // we must check that only 0123456789-<space> are characters here |
450 | 450 | if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) { |
451 | 451 | /// @todo find a better way of throwing an error than this! |
452 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']); |
|
452 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']); |
|
453 | 453 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
454 | 454 | } else { |
455 | 455 | // it's ok, add it on |
456 | - $this->_xh['value'] = (int)$this->_xh['ac']; |
|
456 | + $this->_xh['value'] = (int) $this->_xh['ac']; |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | $this->_xh['lv'] = 3; // indicate we've found a value |
460 | 460 | break; |
461 | 461 | case 'NAME': |
462 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac']; |
|
462 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac']; |
|
463 | 463 | break; |
464 | 464 | case 'MEMBER': |
465 | 465 | // add to array in the stack the last element built, |
466 | 466 | // unless no VALUE was found |
467 | 467 | if ($this->_xh['vt']) { |
468 | 468 | $vscount = count($this->_xh['valuestack']); |
469 | - $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value']; |
|
469 | + $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value']; |
|
470 | 470 | } else { |
471 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml'); |
|
471 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml'); |
|
472 | 472 | } |
473 | 473 | break; |
474 | 474 | case 'DATA': |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | $this->_xh['params'][] = $this->_xh['value']; |
492 | 492 | $this->_xh['pt'][] = $this->_xh['vt']; |
493 | 493 | } else { |
494 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml'); |
|
494 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml'); |
|
495 | 495 | } |
496 | 496 | break; |
497 | 497 | case 'METHODNAME': |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | public function xmlrpc_cd($parser, $data) |
548 | 548 | { |
549 | 549 | // skip processing if xml fault already detected |
550 | - if ($this->_xh['isf'] < 2) { |
|
550 | + if ($this->_xh['isf']<2) { |
|
551 | 551 | // "lookforvalue==3" means that we've found an entire value |
552 | 552 | // and should discard any further character data |
553 | 553 | if ($this->_xh['lv'] != 3) { |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | public function xmlrpc_dh($parser, $data) |
566 | 566 | { |
567 | 567 | // skip processing if xml fault already detected |
568 | - if ($this->_xh['isf'] < 2) { |
|
568 | + if ($this->_xh['isf']<2) { |
|
569 | 569 | if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') { |
570 | 570 | $this->_xh['ac'] .= $data; |
571 | 571 | } |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | // Details: |
637 | 637 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
638 | 638 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
639 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
640 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
639 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
640 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
641 | 641 | $xmlChunk, $matches)) { |
642 | 642 | return strtoupper(substr($matches[2], 1, -1)); |
643 | 643 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
656 | 656 | // IANA also likes better US-ASCII, so go with it |
657 | 657 | if ($enc == 'ASCII') { |
658 | - $enc = 'US-' . $enc; |
|
658 | + $enc = 'US-'.$enc; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | return $enc; |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | // Details: |
691 | 691 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
692 | 692 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
693 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
694 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
693 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
694 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
695 | 695 | $xmlChunk, $matches)) { |
696 | 696 | return true; |
697 | 697 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public static function xmlrpc_debugmsg($msg) |
154 | 154 | { |
155 | - static::$_xmlrpc_debuginfo .= $msg . "\n"; |
|
155 | + static::$_xmlrpc_debuginfo .= $msg."\n"; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public static function error_occurred($msg) |
162 | 162 | { |
163 | - static::$_xmlrpcs_occurred_errors .= $msg . "\n"; |
|
163 | + static::$_xmlrpcs_occurred_errors .= $msg."\n"; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | // user debug info should be encoded by the end user using the INTERNAL_ENCODING |
180 | 180 | $out = ''; |
181 | 181 | if ($this->debug_info != '') { |
182 | - $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n"; |
|
182 | + $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; |
|
183 | 183 | } |
184 | 184 | if (static::$_xmlrpc_debuginfo != '') { |
185 | - $out .= "<!-- DEBUG INFO:\n" . Charset::instance()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n"; |
|
185 | + $out .= "<!-- DEBUG INFO:\n".Charset::instance()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n"; |
|
186 | 186 | // NB: a better solution MIGHT be to use CDATA, but we need to insert it |
187 | 187 | // into return payload AFTER the beginning tag |
188 | 188 | //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n"; |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | $this->debug_info = ''; |
213 | 213 | |
214 | 214 | // Save what we received, before parsing it |
215 | - if ($this->debug > 1) { |
|
216 | - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); |
|
215 | + if ($this->debug>1) { |
|
216 | + $this->debugmsg("+++GOT+++\n".$data."\n+++END+++"); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | $r = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding); |
@@ -225,21 +225,21 @@ discard block |
||
225 | 225 | // save full body of request into response, for more debugging usages |
226 | 226 | $r->raw_data = $rawData; |
227 | 227 | |
228 | - if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors) { |
|
229 | - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . |
|
230 | - static::$_xmlrpcs_occurred_errors . "+++END+++"); |
|
228 | + if ($this->debug>2 && static::$_xmlrpcs_occurred_errors) { |
|
229 | + $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n". |
|
230 | + static::$_xmlrpcs_occurred_errors."+++END+++"); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | $payload = $this->xml_header($respCharset); |
234 | - if ($this->debug > 0) { |
|
235 | - $payload = $payload . $this->serializeDebug($respCharset); |
|
234 | + if ($this->debug>0) { |
|
235 | + $payload = $payload.$this->serializeDebug($respCharset); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // Do not create response serialization if it has already happened. Helps building json magic |
239 | 239 | if (empty($r->payload)) { |
240 | 240 | $r->serialize($respCharset); |
241 | 241 | } |
242 | - $payload = $payload . $r->payload; |
|
242 | + $payload = $payload.$r->payload; |
|
243 | 243 | |
244 | 244 | if ($returnPayload) { |
245 | 245 | return $payload; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | // if we get a warning/error that has output some text before here, then we cannot |
249 | 249 | // add a new header. We cannot say we are sending xml, either... |
250 | 250 | if (!headers_sent()) { |
251 | - header('Content-Type: ' . $r->content_type); |
|
251 | + header('Content-Type: '.$r->content_type); |
|
252 | 252 | // we do not know if client actually told us an accepted charset, but if he did |
253 | 253 | // we have to tell him what we did |
254 | 254 | header("Vary: Accept-Charset"); |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for |
277 | 277 | // responses up to 8000 bytes |
278 | 278 | if ($phpNoSelfCompress) { |
279 | - header('Content-Length: ' . (int)strlen($payload)); |
|
279 | + header('Content-Length: '.(int) strlen($payload)); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages'); |
|
282 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | print $payload; |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | $numParams = count($in); |
329 | 329 | } |
330 | 330 | foreach ($sigs as $curSig) { |
331 | - if (count($curSig) == $numParams + 1) { |
|
331 | + if (count($curSig) == $numParams+1) { |
|
332 | 332 | $itsOK = 1; |
333 | - for ($n = 0; $n < $numParams; $n++) { |
|
333 | + for ($n = 0; $n<$numParams; $n++) { |
|
334 | 334 | if (is_object($in)) { |
335 | 335 | $p = $in->getParam($n); |
336 | 336 | if ($p->kindOf() == 'scalar') { |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | // param index is $n+1, as first member of sig is return type |
346 | - if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) { |
|
346 | + if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) { |
|
347 | 347 | $itsOK = 0; |
348 | - $pno = $n + 1; |
|
349 | - $wanted = $curSig[$n + 1]; |
|
348 | + $pno = $n+1; |
|
349 | + $wanted = $curSig[$n+1]; |
|
350 | 350 | $got = $pt; |
351 | 351 | break; |
352 | 352 | } |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | // check if $_SERVER is populated: it might have been disabled via ini file |
374 | 374 | // (this is true even when in CLI mode) |
375 | 375 | if (count($_SERVER) == 0) { |
376 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated'); |
|
376 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated'); |
|
377 | 377 | } |
378 | 378 | |
379 | - if ($this->debug > 1) { |
|
379 | + if ($this->debug>1) { |
|
380 | 380 | if (function_exists('getallheaders')) { |
381 | 381 | $this->debugmsg(''); // empty line |
382 | 382 | foreach (getallheaders() as $name => $val) { |
@@ -398,13 +398,13 @@ discard block |
||
398 | 398 | if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) { |
399 | 399 | if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) { |
400 | 400 | $data = $degzdata; |
401 | - if ($this->debug > 1) { |
|
402 | - $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++"); |
|
401 | + if ($this->debug>1) { |
|
402 | + $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
403 | 403 | } |
404 | 404 | } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
405 | 405 | $data = $degzdata; |
406 | - if ($this->debug > 1) { |
|
407 | - $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++"); |
|
406 | + if ($this->debug>1) { |
|
407 | + $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
408 | 408 | } |
409 | 409 | } else { |
410 | 410 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'], PhpXmlRpc::$xmlrpcstr['server_decompress_fail']); |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | if (extension_loaded('mbstring')) { |
492 | 492 | $data = mb_convert_encoding($data, 'UTF-8', $reqEncoding); |
493 | 493 | } else { |
494 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding); |
|
494 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$reqEncoding); |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
@@ -509,16 +509,16 @@ discard block |
||
509 | 509 | |
510 | 510 | $xmlRpcParser = new XMLParser($options); |
511 | 511 | $xmlRpcParser->parse($data, $this->functions_parameters_type, XMLParser::ACCEPT_REQUEST); |
512 | - if ($xmlRpcParser->_xh['isf'] > 2) { |
|
512 | + if ($xmlRpcParser->_xh['isf']>2) { |
|
513 | 513 | // (BC) we return XML error as a faultCode |
514 | 514 | preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches); |
515 | 515 | $r = new Response(0, |
516 | - PhpXmlRpc::$xmlrpcerrxml + $matches[1], |
|
516 | + PhpXmlRpc::$xmlrpcerrxml+$matches[1], |
|
517 | 517 | $xmlRpcParser->_xh['isf_reason']); |
518 | 518 | } elseif ($xmlRpcParser->_xh['isf']) { |
519 | 519 | $r = new Response(0, |
520 | 520 | PhpXmlRpc::$xmlrpcerr['invalid_request'], |
521 | - PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']); |
|
521 | + PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']); |
|
522 | 522 | } else { |
523 | 523 | // small layering violation in favor of speed and memory usage: |
524 | 524 | // we should allow the 'execute' method handle this, but in the |
@@ -529,20 +529,20 @@ discard block |
||
529 | 529 | ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] == 'phpvals') |
530 | 530 | ) |
531 | 531 | ) { |
532 | - if ($this->debug > 1) { |
|
533 | - $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++"); |
|
532 | + if ($this->debug>1) { |
|
533 | + $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++"); |
|
534 | 534 | } |
535 | 535 | $r = $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']); |
536 | 536 | } else { |
537 | 537 | // build a Request object with data parsed from xml |
538 | 538 | $req = new Request($xmlRpcParser->_xh['method']); |
539 | 539 | // now add parameters in |
540 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
540 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
541 | 541 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
542 | 542 | } |
543 | 543 | |
544 | - if ($this->debug > 1) { |
|
545 | - $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++"); |
|
544 | + if ($this->debug>1) { |
|
545 | + $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++"); |
|
546 | 546 | } |
547 | 547 | $r = $this->execute($req); |
548 | 548 | } |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | return new Response( |
596 | 596 | 0, |
597 | 597 | PhpXmlRpc::$xmlrpcerr['incorrect_params'], |
598 | - PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": ${errStr}" |
|
598 | + PhpXmlRpc::$xmlrpcstr['incorrect_params'].": ${errStr}" |
|
599 | 599 | ); |
600 | 600 | } |
601 | 601 | } |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | |
609 | 609 | if (is_array($func)) { |
610 | 610 | if (is_object($func[0])) { |
611 | - $funcName = get_class($func[0]) . '->' . $func[1]; |
|
611 | + $funcName = get_class($func[0]).'->'.$func[1]; |
|
612 | 612 | } else { |
613 | 613 | $funcName = implode('::', $func); |
614 | 614 | } |
@@ -620,17 +620,17 @@ discard block |
||
620 | 620 | |
621 | 621 | // verify that function to be invoked is in fact callable |
622 | 622 | if (!is_callable($func)) { |
623 | - Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable"); |
|
623 | + Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable"); |
|
624 | 624 | return new Response( |
625 | 625 | 0, |
626 | 626 | PhpXmlRpc::$xmlrpcerr['server_error'], |
627 | - PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method" |
|
627 | + PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method" |
|
628 | 628 | ); |
629 | 629 | } |
630 | 630 | |
631 | 631 | // If debug level is 3, we should catch all errors generated during |
632 | 632 | // processing of user function, and log them as part of response |
633 | - if ($this->debug > 2) { |
|
633 | + if ($this->debug>2) { |
|
634 | 634 | self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler')); |
635 | 635 | } |
636 | 636 | |
@@ -643,14 +643,14 @@ discard block |
||
643 | 643 | $r = call_user_func($func, $req); |
644 | 644 | } |
645 | 645 | if (!is_a($r, 'PhpXmlRpc\Response')) { |
646 | - Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r)); |
|
646 | + Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r)); |
|
647 | 647 | if (is_a($r, 'PhpXmlRpc\Value')) { |
648 | 648 | $r = new Response($r); |
649 | 649 | } else { |
650 | 650 | $r = new Response( |
651 | 651 | 0, |
652 | 652 | PhpXmlRpc::$xmlrpcerr['server_error'], |
653 | - PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object" |
|
653 | + PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object" |
|
654 | 654 | ); |
655 | 655 | } |
656 | 656 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | // mimic EPI behaviour: if we get an array that looks like an error, make it |
667 | 667 | // an error response |
668 | 668 | if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) { |
669 | - $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']); |
|
669 | + $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']); |
|
670 | 670 | } else { |
671 | 671 | // functions using EPI api should NOT return resp objects, |
672 | 672 | // so make sure we encode the return type correctly |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | // in the called function, we wrap it in a proper error-response |
691 | 691 | switch ($this->exception_handling) { |
692 | 692 | case 2: |
693 | - if ($this->debug > 2) { |
|
693 | + if ($this->debug>2) { |
|
694 | 694 | if (self::$_xmlrpcs_prev_ehandler) { |
695 | 695 | set_error_handler(self::$_xmlrpcs_prev_ehandler); |
696 | 696 | } else { |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_error'], PhpXmlRpc::$xmlrpcstr['server_error']); |
706 | 706 | } |
707 | 707 | } |
708 | - if ($this->debug > 2) { |
|
708 | + if ($this->debug>2) { |
|
709 | 709 | // note: restore the error handler we found before calling the |
710 | 710 | // user func, even if it has been changed inside the func itself |
711 | 711 | if (self::$_xmlrpcs_prev_ehandler) { |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | */ |
726 | 726 | protected function debugmsg($string) |
727 | 727 | { |
728 | - $this->debug_info .= $string . "\n"; |
|
728 | + $this->debug_info .= $string."\n"; |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
@@ -735,9 +735,9 @@ discard block |
||
735 | 735 | protected function xml_header($charsetEncoding = '') |
736 | 736 | { |
737 | 737 | if ($charsetEncoding != '') { |
738 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n"; |
|
738 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n"; |
|
739 | 739 | } else { |
740 | - return "<?xml version=\"1.0\"?" . ">\n"; |
|
740 | + return "<?xml version=\"1.0\"?".">\n"; |
|
741 | 741 | } |
742 | 742 | } |
743 | 743 | |
@@ -970,12 +970,12 @@ discard block |
||
970 | 970 | } |
971 | 971 | |
972 | 972 | $req = new Request($methName->scalarval()); |
973 | - foreach($params as $i => $param) { |
|
973 | + foreach ($params as $i => $param) { |
|
974 | 974 | if (!$req->addParam($param)) { |
975 | 975 | $i++; // for error message, we count params from 1 |
976 | 976 | return static::_xmlrpcs_multicall_error(new Response(0, |
977 | 977 | PhpXmlRpc::$xmlrpcerr['incorrect_params'], |
978 | - PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i)); |
|
978 | + PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i)); |
|
979 | 979 | } |
980 | 980 | } |
981 | 981 | |
@@ -1042,12 +1042,12 @@ discard block |
||
1042 | 1042 | // let accept a plain list of php parameters, beside a single xmlrpc msg object |
1043 | 1043 | if (is_object($req)) { |
1044 | 1044 | $calls = $req->getParam(0); |
1045 | - foreach($calls as $call) { |
|
1045 | + foreach ($calls as $call) { |
|
1046 | 1046 | $result[] = static::_xmlrpcs_multicall_do_call($server, $call); |
1047 | 1047 | } |
1048 | 1048 | } else { |
1049 | 1049 | $numCalls = count($req); |
1050 | - for ($i = 0; $i < $numCalls; $i++) { |
|
1050 | + for ($i = 0; $i<$numCalls; $i++) { |
|
1051 | 1051 | $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]); |
1052 | 1052 | } |
1053 | 1053 | } |