@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | // read chunk-size, chunk-extension (if any) and crlf |
48 | 48 | // get the position of the linebreak |
49 | - $chunkEnd = strpos($buffer, "\r\n") + 2; |
|
49 | + $chunkEnd = strpos($buffer, "\r\n")+2; |
|
50 | 50 | $temp = substr($buffer, 0, $chunkEnd); |
51 | 51 | $chunkSize = hexdec(trim($temp)); |
52 | 52 | $chunkStart = $chunkEnd; |
53 | - while ($chunkSize > 0) { |
|
54 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); |
|
53 | + while ($chunkSize>0) { |
|
54 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize); |
|
55 | 55 | |
56 | 56 | // just in case we got a broken connection |
57 | 57 | if ($chunkEnd == false) { |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // read chunk-data and crlf |
66 | - $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
66 | + $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
67 | 67 | // append chunk-data to entity-body |
68 | 68 | $new .= $chunk; |
69 | 69 | // length := length + chunk-size |
70 | 70 | $length += strlen($chunk); |
71 | 71 | // read chunk-size and crlf |
72 | - $chunkStart = $chunkEnd + 2; |
|
72 | + $chunkStart = $chunkEnd+2; |
|
73 | 73 | |
74 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; |
|
74 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2; |
|
75 | 75 | if ($chunkEnd == false) { |
76 | 76 | break; // just in case we got a broken connection |
77 | 77 | } |
78 | - $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
78 | + $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
79 | 79 | $chunkSize = hexdec(trim($temp)); |
80 | 80 | $chunkStart = $chunkEnd; |
81 | 81 | } |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | // Look for CR/LF or simple LF as line separator (even though it is not valid http) |
105 | 105 | $pos = strpos($data, "\r\n\r\n"); |
106 | 106 | if ($pos || is_int($pos)) { |
107 | - $bd = $pos + 4; |
|
107 | + $bd = $pos+4; |
|
108 | 108 | } else { |
109 | 109 | $pos = strpos($data, "\n\n"); |
110 | 110 | if ($pos || is_int($pos)) { |
111 | - $bd = $pos + 2; |
|
111 | + $bd = $pos+2; |
|
112 | 112 | } else { |
113 | 113 | // No separation between response headers and body: fault? |
114 | 114 | $bd = 0; |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | // this filters out all http headers from proxy. maybe we could take them into account, too? |
119 | 119 | $data = substr($data, $bd); |
120 | 120 | } else { |
121 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed'); |
|
122 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
121 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
|
122 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | if ($httpResponse['status_code'] !== '200') { |
155 | - $errstr = substr($data, 0, strpos($data, "\n") - 1); |
|
156 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr); |
|
157 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
155 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
156 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
157 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // be tolerant to usage of \n instead of \r\n to separate headers and data (even though it is not valid http) |
161 | 161 | $pos = strpos($data, "\r\n\r\n"); |
162 | 162 | if ($pos || is_int($pos)) { |
163 | - $bd = $pos + 4; |
|
163 | + $bd = $pos+4; |
|
164 | 164 | } else { |
165 | 165 | $pos = strpos($data, "\n\n"); |
166 | 166 | if ($pos || is_int($pos)) { |
167 | - $bd = $pos + 2; |
|
167 | + $bd = $pos+2; |
|
168 | 168 | } else { |
169 | 169 | // No separation between response headers and body: fault? |
170 | 170 | // we could take some action here instead of going on... |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | foreach ($ar as $line) { |
179 | 179 | // take care of multi-line headers and cookies |
180 | 180 | $arr = explode(':', $line, 2); |
181 | - if (count($arr) > 1) { |
|
181 | + if (count($arr)>1) { |
|
182 | 182 | $headerName = strtolower(trim($arr[0])); |
183 | 183 | /// @todo some other headers (the ones that allow a CSV list of values) do allow many values to be |
184 | 184 | /// passed using multiple header lines. |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | foreach ($cookies as $cookie) { |
196 | 196 | // glue together all received cookies, using a comma to separate them (same as php does with getallheaders()) |
197 | 197 | if (isset($httpResponse['headers'][$headerName])) { |
198 | - $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); |
|
198 | + $httpResponse['headers'][$headerName] .= ', '.trim($cookie); |
|
199 | 199 | } else { |
200 | 200 | $httpResponse['headers'][$headerName] = trim($cookie); |
201 | 201 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | } |
225 | 225 | } elseif (isset($headerName)) { |
226 | 226 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
227 | - $httpResponse['headers'][$headerName] .= ' ' . trim($line); |
|
227 | + $httpResponse['headers'][$headerName] .= ' '.trim($line); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | // Decode chunked encoding sent by http 1.1 servers |
248 | 248 | if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') { |
249 | 249 | if (!$data = static::decodeChunked($data)) { |
250 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server'); |
|
250 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
|
251 | 251 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']); |
252 | 252 | } |
253 | 253 | } |
@@ -262,19 +262,19 @@ discard block |
||
262 | 262 | if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { |
263 | 263 | $data = $degzdata; |
264 | 264 | if ($debug) { |
265 | - $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
265 | + $this->getLogger()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
266 | 266 | } |
267 | 267 | } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
268 | 268 | $data = $degzdata; |
269 | 269 | if ($debug) { |
270 | - $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
270 | + $this->getLogger()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
271 | 271 | } |
272 | 272 | } else { |
273 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server'); |
|
273 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server'); |
|
274 | 274 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']); |
275 | 275 | } |
276 | 276 | } else { |
277 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
277 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
278 | 278 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']); |
279 | 279 | } |
280 | 280 | } |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | $this->accept = $accept; |
176 | 176 | |
177 | 177 | // @see ticket #70 - we have to parse big xml docks in chunks to avoid errors |
178 | - for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) { |
|
178 | + for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) { |
|
179 | 179 | $chunk = substr($data, $offset, $this->maxChunkLength); |
180 | 180 | // error handling: xml not well formed |
181 | - if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) { |
|
181 | + if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) { |
|
182 | 182 | $errCode = xml_get_error_code($parser); |
183 | 183 | $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode), |
184 | 184 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) |
206 | 206 | { |
207 | 207 | // if invalid xmlrpc already detected, skip all processing |
208 | - if ($this->_xh['isf'] < 2) { |
|
208 | + if ($this->_xh['isf']<2) { |
|
209 | 209 | |
210 | 210 | // check for correct element nesting |
211 | 211 | if (count($this->_xh['stack']) == 0) { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $this->_xh['rt'] = strtolower($name); |
226 | 226 | } else { |
227 | 227 | $this->_xh['isf'] = 2; |
228 | - $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name; |
|
228 | + $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name; |
|
229 | 229 | |
230 | 230 | return; |
231 | 231 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | break; |
320 | 320 | case 'MEMBER': |
321 | 321 | // set member name to null, in case we do not find in the xml later on |
322 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = ''; |
|
322 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = ''; |
|
323 | 323 | //$this->_xh['ac']=''; |
324 | 324 | // Drop trough intentionally |
325 | 325 | case 'PARAM': |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1) |
385 | 385 | { |
386 | - if ($this->_xh['isf'] < 2) { |
|
386 | + if ($this->_xh['isf']<2) { |
|
387 | 387 | // push this element name from stack |
388 | 388 | // NB: if XML validates, correct opening/closing is guaranteed and |
389 | 389 | // we do not have to check for $name == $currElem. |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $this->_xh['vt'] = Value::$xmlrpcString; |
399 | 399 | } |
400 | 400 | |
401 | - if ($rebuildXmlrpcvals > 0) { |
|
401 | + if ($rebuildXmlrpcvals>0) { |
|
402 | 402 | // build the xmlrpc val out of the data received, and substitute it |
403 | 403 | $temp = new Value($this->_xh['value'], $this->_xh['vt']); |
404 | 404 | // in case we got info about underlying php class, save it |
@@ -407,15 +407,15 @@ discard block |
||
407 | 407 | $temp->_php_class = $this->_xh['php_class']; |
408 | 408 | } |
409 | 409 | $this->_xh['value'] = $temp; |
410 | - } elseif ($rebuildXmlrpcvals < 0) { |
|
410 | + } elseif ($rebuildXmlrpcvals<0) { |
|
411 | 411 | if ($this->_xh['vt'] == Value::$xmlrpcDateTime) { |
412 | - $this->_xh['value'] = (object)array( |
|
412 | + $this->_xh['value'] = (object) array( |
|
413 | 413 | 'xmlrpc_type' => 'datetime', |
414 | 414 | 'scalar' => $this->_xh['value'], |
415 | 415 | 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($this->_xh['value']) |
416 | 416 | ); |
417 | 417 | } elseif ($this->_xh['vt'] == Value::$xmlrpcBase64) { |
418 | - $this->_xh['value'] = (object)array( |
|
418 | + $this->_xh['value'] = (object) array( |
|
419 | 419 | 'xmlrpc_type' => 'base64', |
420 | 420 | 'scalar' => $this->_xh['value'] |
421 | 421 | ); |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | // check if we are inside an array or struct: |
432 | 432 | // if value just built is inside an array, let's move it into array on the stack |
433 | 433 | $vscount = count($this->_xh['valuestack']); |
434 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
435 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value']; |
|
434 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
435 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value']; |
|
436 | 436 | } |
437 | 437 | break; |
438 | 438 | case 'BOOLEAN': |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $this->_xh['value'] = $this->_xh['ac']; |
452 | 452 | } elseif ($name == 'DATETIME.ISO8601') { |
453 | 453 | if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) { |
454 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']); |
|
454 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']); |
|
455 | 455 | } |
456 | 456 | $this->_xh['vt'] = Value::$xmlrpcDateTime; |
457 | 457 | $this->_xh['value'] = $this->_xh['ac']; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | } else { |
471 | 471 | // log if receiving something strange, even though we set the value to false anyway |
472 | 472 | if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) { |
473 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']); |
|
473 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']); |
|
474 | 474 | } |
475 | 475 | $this->_xh['value'] = false; |
476 | 476 | } |
@@ -480,37 +480,37 @@ discard block |
||
480 | 480 | // NOTE: regexp could be much stricter than this... |
481 | 481 | if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) { |
482 | 482 | /// @todo: find a better way of throwing an error than this! |
483 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']); |
|
483 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']); |
|
484 | 484 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
485 | 485 | } else { |
486 | 486 | // it's ok, add it on |
487 | - $this->_xh['value'] = (double)$this->_xh['ac']; |
|
487 | + $this->_xh['value'] = (double) $this->_xh['ac']; |
|
488 | 488 | } |
489 | 489 | } else { |
490 | 490 | // we have an I4/I8/INT |
491 | 491 | // we must check that only 0123456789-<space> are characters here |
492 | 492 | if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) { |
493 | 493 | /// @todo find a better way of throwing an error than this! |
494 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']); |
|
494 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']); |
|
495 | 495 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
496 | 496 | } else { |
497 | 497 | // it's ok, add it on |
498 | - $this->_xh['value'] = (int)$this->_xh['ac']; |
|
498 | + $this->_xh['value'] = (int) $this->_xh['ac']; |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | $this->_xh['lv'] = 3; // indicate we've found a value |
502 | 502 | break; |
503 | 503 | case 'NAME': |
504 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac']; |
|
504 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac']; |
|
505 | 505 | break; |
506 | 506 | case 'MEMBER': |
507 | 507 | // add to array in the stack the last element built, |
508 | 508 | // unless no VALUE was found |
509 | 509 | if ($this->_xh['vt']) { |
510 | 510 | $vscount = count($this->_xh['valuestack']); |
511 | - $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value']; |
|
511 | + $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value']; |
|
512 | 512 | } else { |
513 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml'); |
|
513 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml'); |
|
514 | 514 | } |
515 | 515 | break; |
516 | 516 | case 'DATA': |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $this->_xh['params'][] = $this->_xh['value']; |
534 | 534 | $this->_xh['pt'][] = $this->_xh['vt']; |
535 | 535 | } else { |
536 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml'); |
|
536 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml'); |
|
537 | 537 | } |
538 | 538 | break; |
539 | 539 | case 'METHODNAME': |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | public function xmlrpc_cd($parser, $data) |
599 | 599 | { |
600 | 600 | // skip processing if xml fault already detected |
601 | - if ($this->_xh['isf'] < 2) { |
|
601 | + if ($this->_xh['isf']<2) { |
|
602 | 602 | // "lookforvalue==3" means that we've found an entire value |
603 | 603 | // and should discard any further character data |
604 | 604 | if ($this->_xh['lv'] != 3) { |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | public function xmlrpc_dh($parser, $data) |
620 | 620 | { |
621 | 621 | // skip processing if xml fault already detected |
622 | - if ($this->_xh['isf'] < 2) { |
|
622 | + if ($this->_xh['isf']<2) { |
|
623 | 623 | if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') { |
624 | 624 | $this->_xh['ac'] .= $data; |
625 | 625 | } |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | // Details: |
694 | 694 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
695 | 695 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
696 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
697 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
696 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
697 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
698 | 698 | $xmlChunk, $matches)) { |
699 | 699 | return strtoupper(substr($matches[2], 1, -1)); |
700 | 700 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
713 | 713 | // IANA also likes better US-ASCII, so go with it |
714 | 714 | if ($enc == 'ASCII') { |
715 | - $enc = 'US-' . $enc; |
|
715 | + $enc = 'US-'.$enc; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | return $enc; |
@@ -747,8 +747,8 @@ discard block |
||
747 | 747 | // Details: |
748 | 748 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
749 | 749 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
750 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
751 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
750 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
751 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
752 | 752 | $xmlChunk, $matches)) { |
753 | 753 | return true; |
754 | 754 | } |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | if (count($this->xml_iso88591_Entities['in'])) { |
92 | 92 | return; |
93 | 93 | } |
94 | - for ($i = 0; $i < 32; $i++) { |
|
94 | + for ($i = 0; $i<32; $i++) { |
|
95 | 95 | $this->xml_iso88591_Entities["in"][] = chr($i); |
96 | 96 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
97 | 97 | } |
98 | 98 | |
99 | 99 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
100 | 100 | |
101 | - for ($i = 160; $i < 256; $i++) { |
|
101 | + for ($i = 160; $i<256; $i++) { |
|
102 | 102 | $this->xml_iso88591_Entities["in"][] = chr($i); |
103 | 103 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
104 | 104 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | break;*/ |
127 | 127 | |
128 | 128 | default: |
129 | - throw new \Exception('Unsupported table: ' . $tableName); |
|
129 | + throw new \Exception('Unsupported table: '.$tableName); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $destEncoding = 'US-ASCII'; |
169 | 169 | } |
170 | 170 | |
171 | - $conversion = strtoupper($srcEncoding . '_' . $destEncoding); |
|
171 | + $conversion = strtoupper($srcEncoding.'_'.$destEncoding); |
|
172 | 172 | |
173 | 173 | // list ordered with (expected) most common scenarios first |
174 | 174 | switch ($conversion) { |
@@ -186,20 +186,20 @@ discard block |
||
186 | 186 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
187 | 187 | $escapedData = ''; |
188 | 188 | // be kind to users creating string xmlrpc values out of different php types |
189 | - $data = (string)$data; |
|
189 | + $data = (string) $data; |
|
190 | 190 | $ns = strlen($data); |
191 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
191 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
192 | 192 | $ch = $data[$nn]; |
193 | 193 | $ii = ord($ch); |
194 | 194 | // 7 bits in 1 byte: 0bbbbbbb (127) |
195 | - if ($ii < 32) { |
|
195 | + if ($ii<32) { |
|
196 | 196 | if ($conversion == 'UTF-8_US-ASCII') { |
197 | 197 | $escapedData .= sprintf('&#%d;', $ii); |
198 | 198 | } else { |
199 | 199 | $escapedData .= $ch; |
200 | 200 | } |
201 | 201 | } |
202 | - else if ($ii < 128) { |
|
202 | + else if ($ii<128) { |
|
203 | 203 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
204 | 204 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
205 | 205 | switch ($ii) { |
@@ -224,25 +224,25 @@ discard block |
||
224 | 224 | } // 11 bits in 2 bytes: 110bbbbb 10bbbbbb (2047) |
225 | 225 | elseif ($ii >> 5 == 6) { |
226 | 226 | $b1 = ($ii & 31); |
227 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
228 | - $ii = ($b1 * 64) + $b2; |
|
227 | + $b2 = (ord($data[$nn+1]) & 63); |
|
228 | + $ii = ($b1 * 64)+$b2; |
|
229 | 229 | $escapedData .= sprintf('&#%d;', $ii); |
230 | 230 | $nn += 1; |
231 | 231 | } // 16 bits in 3 bytes: 1110bbbb 10bbbbbb 10bbbbbb |
232 | 232 | elseif ($ii >> 4 == 14) { |
233 | 233 | $b1 = ($ii & 15); |
234 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
235 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
236 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
234 | + $b2 = (ord($data[$nn+1]) & 63); |
|
235 | + $b3 = (ord($data[$nn+2]) & 63); |
|
236 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
237 | 237 | $escapedData .= sprintf('&#%d;', $ii); |
238 | 238 | $nn += 2; |
239 | 239 | } // 21 bits in 4 bytes: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
240 | 240 | elseif ($ii >> 3 == 30) { |
241 | 241 | $b1 = ($ii & 7); |
242 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
243 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
244 | - $b4 = (ord($data[$nn + 3]) & 63); |
|
245 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
242 | + $b2 = (ord($data[$nn+1]) & 63); |
|
243 | + $b3 = (ord($data[$nn+2]) & 63); |
|
244 | + $b4 = (ord($data[$nn+3]) & 63); |
|
245 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
246 | 246 | $escapedData .= sprintf('&#%d;', $ii); |
247 | 247 | $nn += 3; |
248 | 248 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | default: |
293 | 293 | $escapedData = ''; |
294 | 294 | /// @todo allow usage of a custom Logger via the DIC(ish) pattern we use in other classes |
295 | - $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
295 | + $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | return $escapedData; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | case 'iso88591': |
344 | 344 | return $this->xml_iso88591_Entities; |
345 | 345 | default: |
346 | - throw new \Exception('Unsupported charset: ' . $charset); |
|
346 | + throw new \Exception('Unsupported charset: '.$charset); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |