@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | } |
9 | 9 | |
10 | 10 | // Use the custom class autoloader. These two lines are not needed when the phpxmlrpc library is installed using Composer |
11 | -include_once __DIR__ . '/../../src/Autoloader.php'; |
|
11 | +include_once __DIR__.'/../../src/Autoloader.php'; |
|
12 | 12 | PhpXmlRpc\Autoloader::register(); |
13 | 13 | |
14 | 14 | // Let unit tests run against localhost, 'plain' demos against a known public server |
@@ -22,5 +22,5 @@ discard block |
||
22 | 22 | function output($text) |
23 | 23 | { |
24 | 24 | /// @todo we should only strip html tags, and let through all xml tags |
25 | - echo PHP_SAPI == 'cli' ? strip_tags(str_replace(array('<br/>','<br>'), "\n", $text)) : $text; |
|
25 | + echo PHP_SAPI == 'cli' ? strip_tags(str_replace(array('<br/>', '<br>'), "\n", $text)) : $text; |
|
26 | 26 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once __DIR__ . "/_prepend.php"; |
|
2 | +require_once __DIR__."/_prepend.php"; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Demoing how to inject a custom logger for use by the library |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | // logger API |
23 | 23 | public function debug($message, $context = array()) |
24 | 24 | { |
25 | - $this->debugBuffer .= $message . "\n"; |
|
25 | + $this->debugBuffer .= $message."\n"; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | // logger API |
29 | 29 | public function error($message, $context = array()) |
30 | 30 | { |
31 | - $this->errorBuffer .= $message . "\n"; |
|
31 | + $this->errorBuffer .= $message."\n"; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function getDebug() |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | $input = array( |
61 | 61 | array('name' => 'Dave', 'age' => 24), |
62 | - array('name' => 'Edd', 'age' => 45), |
|
63 | - array('name' => 'Joe', 'age' => 37), |
|
62 | + array('name' => 'Edd', 'age' => 45), |
|
63 | + array('name' => 'Joe', 'age' => 37), |
|
64 | 64 | array('name' => 'Fred', 'age' => 27), |
65 | 65 | ); |
66 | 66 | |
@@ -79,5 +79,5 @@ discard block |
||
79 | 79 | $response = $client->send($request); |
80 | 80 | output("Response received.<br>"); |
81 | 81 | |
82 | -output("The client error info is:<pre>\n" . $logger->getError() . "\n</pre>"); |
|
83 | -output("The client debug info is:<pre>\n" . $logger->getDebug() . "\n</pre>"); |
|
82 | +output("The client error info is:<pre>\n".$logger->getError()."\n</pre>"); |
|
83 | +output("The client debug info is:<pre>\n".$logger->getDebug()."\n</pre>"); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | 'scalar' => $val, |
58 | 58 | 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($val) |
59 | 59 | ); |
60 | - return (object)$xmlrpcVal; |
|
60 | + return (object) $xmlrpcVal; |
|
61 | 61 | case 'base64': |
62 | 62 | $xmlrpcVal = array( |
63 | 63 | 'xmlrpc_type' => 'base64', |
64 | 64 | 'scalar' => $val |
65 | 65 | ); |
66 | - return (object)$xmlrpcVal; |
|
66 | + return (object) $xmlrpcVal; |
|
67 | 67 | case 'string': |
68 | 68 | if (isset($options['extension_api_encoding'])) { |
69 | 69 | // if iconv is not available, we use mb_convert_encoding |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | case 'msg': |
137 | 137 | $paramCount = $xmlrpcVal->getNumParams(); |
138 | 138 | $arr = array(); |
139 | - for ($i = 0; $i < $paramCount; $i++) { |
|
139 | + for ($i = 0; $i<$paramCount; $i++) { |
|
140 | 140 | $arr[] = $this->decode($xmlrpcVal->getParam($i), $options); |
141 | 141 | } |
142 | 142 | return $arr; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | break; |
262 | 262 | case 'resource': |
263 | 263 | if (in_array('extension_api', $options)) { |
264 | - $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt); |
|
264 | + $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt); |
|
265 | 265 | } else { |
266 | 266 | $xmlrpcVal = new Value(); |
267 | 267 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | if ($valEncoding == 'ISO-8859-1') { |
311 | 311 | $xmlVal = utf8_encode($xmlVal); |
312 | 312 | } else { |
313 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding); |
|
313 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $parserOptions |
333 | 333 | ); |
334 | 334 | |
335 | - if ($xmlRpcParser->_xh['isf'] > 1) { |
|
335 | + if ($xmlRpcParser->_xh['isf']>1) { |
|
336 | 336 | // test that $xmlrpc->_xh['value'] is an obj, too??? |
337 | 337 | |
338 | 338 | $this->getLogger()->error($xmlRpcParser->_xh['isf_reason']); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | case 'methodcall': |
358 | 358 | $req = new Request($xmlRpcParser->_xh['method']); |
359 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
359 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
360 | 360 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
361 | 361 | } |
362 | 362 | return $req; |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | |
27 | 27 | // read chunk-size, chunk-extension (if any) and crlf |
28 | 28 | // get the position of the linebreak |
29 | - $chunkEnd = strpos($buffer, "\r\n") + 2; |
|
29 | + $chunkEnd = strpos($buffer, "\r\n")+2; |
|
30 | 30 | $temp = substr($buffer, 0, $chunkEnd); |
31 | 31 | $chunkSize = hexdec(trim($temp)); |
32 | 32 | $chunkStart = $chunkEnd; |
33 | - while ($chunkSize > 0) { |
|
34 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); |
|
33 | + while ($chunkSize>0) { |
|
34 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize); |
|
35 | 35 | |
36 | 36 | // just in case we got a broken connection |
37 | 37 | if ($chunkEnd == false) { |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | // read chunk-data and crlf |
46 | - $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
46 | + $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
47 | 47 | // append chunk-data to entity-body |
48 | 48 | $new .= $chunk; |
49 | 49 | // length := length + chunk-size |
50 | 50 | $length += strlen($chunk); |
51 | 51 | // read chunk-size and crlf |
52 | - $chunkStart = $chunkEnd + 2; |
|
52 | + $chunkStart = $chunkEnd+2; |
|
53 | 53 | |
54 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; |
|
54 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2; |
|
55 | 55 | if ($chunkEnd == false) { |
56 | 56 | break; // just in case we got a broken connection |
57 | 57 | } |
58 | - $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
58 | + $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
59 | 59 | $chunkSize = hexdec(trim($temp)); |
60 | 60 | $chunkStart = $chunkEnd; |
61 | 61 | } |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | // Look for CR/LF or simple LF as line separator (even though it is not valid http) |
85 | 85 | $pos = strpos($data, "\r\n\r\n"); |
86 | 86 | if ($pos || is_int($pos)) { |
87 | - $bd = $pos + 4; |
|
87 | + $bd = $pos+4; |
|
88 | 88 | } else { |
89 | 89 | $pos = strpos($data, "\n\n"); |
90 | 90 | if ($pos || is_int($pos)) { |
91 | - $bd = $pos + 2; |
|
91 | + $bd = $pos+2; |
|
92 | 92 | } else { |
93 | 93 | // No separation between response headers and body: fault? |
94 | 94 | $bd = 0; |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | // this filters out all http headers from proxy. maybe we could take them into account, too? |
99 | 99 | $data = substr($data, $bd); |
100 | 100 | } else { |
101 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed'); |
|
102 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
101 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
|
102 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -132,19 +132,19 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | if ($httpResponse['status_code'] !== '200') { |
135 | - $errstr = substr($data, 0, strpos($data, "\n") - 1); |
|
136 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr); |
|
137 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
135 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
136 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
137 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // be tolerant to usage of \n instead of \r\n to separate headers and data (even though it is not valid http) |
141 | 141 | $pos = strpos($data, "\r\n\r\n"); |
142 | 142 | if ($pos || is_int($pos)) { |
143 | - $bd = $pos + 4; |
|
143 | + $bd = $pos+4; |
|
144 | 144 | } else { |
145 | 145 | $pos = strpos($data, "\n\n"); |
146 | 146 | if ($pos || is_int($pos)) { |
147 | - $bd = $pos + 2; |
|
147 | + $bd = $pos+2; |
|
148 | 148 | } else { |
149 | 149 | // No separation between response headers and body: fault? |
150 | 150 | // we could take some action here instead of going on... |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | foreach ($ar as $line) { |
159 | 159 | // take care of multi-line headers and cookies |
160 | 160 | $arr = explode(':', $line, 2); |
161 | - if (count($arr) > 1) { |
|
161 | + if (count($arr)>1) { |
|
162 | 162 | $headerName = strtolower(trim($arr[0])); |
163 | 163 | /// @todo some other headers (the ones that allow a CSV list of values) do allow many values to be |
164 | 164 | /// passed using multiple header lines. |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | foreach ($cookies as $cookie) { |
176 | 176 | // glue together all received cookies, using a comma to separate them (same as php does with getallheaders()) |
177 | 177 | if (isset($httpResponse['headers'][$headerName])) { |
178 | - $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); |
|
178 | + $httpResponse['headers'][$headerName] .= ', '.trim($cookie); |
|
179 | 179 | } else { |
180 | 180 | $httpResponse['headers'][$headerName] = trim($cookie); |
181 | 181 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | } elseif (isset($headerName)) { |
206 | 206 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
207 | - $httpResponse['headers'][$headerName] .= ' ' . trim($line); |
|
207 | + $httpResponse['headers'][$headerName] .= ' '.trim($line); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // Decode chunked encoding sent by http 1.1 servers |
228 | 228 | if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') { |
229 | 229 | if (!$data = static::decodeChunked($data)) { |
230 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server'); |
|
230 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
|
231 | 231 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']); |
232 | 232 | } |
233 | 233 | } |
@@ -242,19 +242,19 @@ discard block |
||
242 | 242 | if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { |
243 | 243 | $data = $degzdata; |
244 | 244 | if ($debug) { |
245 | - $this->getLogger()->debug("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
245 | + $this->getLogger()->debug("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
246 | 246 | } |
247 | 247 | } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
248 | 248 | $data = $degzdata; |
249 | 249 | if ($debug) { |
250 | - $this->getLogger()->debug("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
250 | + $this->getLogger()->debug("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
251 | 251 | } |
252 | 252 | } else { |
253 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server'); |
|
253 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server'); |
|
254 | 254 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']); |
255 | 255 | } |
256 | 256 | } else { |
257 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
257 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
258 | 258 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']); |
259 | 259 | } |
260 | 260 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | public function parseAcceptHeader($header) |
275 | 275 | { |
276 | 276 | $accepted = array(); |
277 | - foreach(explode(',', $header) as $c) { |
|
277 | + foreach (explode(',', $header) as $c) { |
|
278 | 278 | if (preg_match('/^([^;]+); *q=([0-9.]+)/', $c, $matches)) { |
279 | 279 | $c = $matches[1]; |
280 | 280 | $w = $matches[2]; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->me['struct'] = $val; |
94 | 94 | break; |
95 | 95 | default: |
96 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a known type ($type)"); |
|
96 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": not a known type ($type)"); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | if ($typeOf !== 1) { |
120 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)"); |
|
120 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": not a scalar type ($type)"); |
|
121 | 121 | return 0; |
122 | 122 | } |
123 | 123 | |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | |
135 | 135 | switch ($this->mytype) { |
136 | 136 | case 1: |
137 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value'); |
|
137 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': scalar xmlrpc value can have only one value'); |
|
138 | 138 | return 0; |
139 | 139 | case 3: |
140 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value'); |
|
140 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpc value'); |
|
141 | 141 | return 0; |
142 | 142 | case 2: |
143 | 143 | // we're adding a scalar value to an array here |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | return 1; |
181 | 181 | } else { |
182 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
182 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
183 | 183 | return 0; |
184 | 184 | } |
185 | 185 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | return 1; |
211 | 211 | } else { |
212 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
212 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
213 | 213 | return 0; |
214 | 214 | } |
215 | 215 | } |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | case 1: |
252 | 252 | switch ($typ) { |
253 | 253 | case static::$xmlrpcBase64: |
254 | - $rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>"; |
|
254 | + $rs .= "<{$typ}>".base64_encode($val)."</{$typ}>"; |
|
255 | 255 | break; |
256 | 256 | case static::$xmlrpcBoolean: |
257 | - $rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>"; |
|
257 | + $rs .= "<{$typ}>".($val ? '1' : '0')."</{$typ}>"; |
|
258 | 258 | break; |
259 | 259 | case static::$xmlrpcString: |
260 | 260 | // Do NOT use htmlentities, since it will produce named html entities, which are invalid xml |
261 | - $rs .= "<{$typ}>" . $this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</{$typ}>"; |
|
261 | + $rs .= "<{$typ}>".$this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</{$typ}>"; |
|
262 | 262 | break; |
263 | 263 | case static::$xmlrpcInt: |
264 | 264 | case static::$xmlrpcI4: |
265 | 265 | case static::$xmlrpcI8: |
266 | - $rs .= "<{$typ}>" . (int)$val . "</{$typ}>"; |
|
266 | + $rs .= "<{$typ}>".(int) $val."</{$typ}>"; |
|
267 | 267 | break; |
268 | 268 | case static::$xmlrpcDouble: |
269 | 269 | // avoid using standard conversion of float to string because it is locale-dependent, |
@@ -271,16 +271,16 @@ discard block |
||
271 | 271 | // sprintf('%F') could be most likely ok, but it fails e.g. on 2e-14. |
272 | 272 | // The code below tries its best at keeping max precision while avoiding exp notation, |
273 | 273 | // but there is of course no limit in the number of decimal places to be used... |
274 | - $rs .= "<{$typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, PhpXmlRpc::$xmlpc_double_precision, '.', '')) . "</{$typ}>"; |
|
274 | + $rs .= "<{$typ}>".preg_replace('/\\.?0+$/', '', number_format((double) $val, PhpXmlRpc::$xmlpc_double_precision, '.', ''))."</{$typ}>"; |
|
275 | 275 | break; |
276 | 276 | case static::$xmlrpcDateTime: |
277 | 277 | if (is_string($val)) { |
278 | 278 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
279 | 279 | // DateTimeInterface is not present in php 5.4... |
280 | 280 | } elseif (is_a($val, 'DateTimeInterface') || is_a($val, 'DateTime')) { |
281 | - $rs .= "<{$typ}>" . $val->format('Ymd\TH:i:s') . "</{$typ}>"; |
|
281 | + $rs .= "<{$typ}>".$val->format('Ymd\TH:i:s')."</{$typ}>"; |
|
282 | 282 | } elseif (is_int($val)) { |
283 | - $rs .= "<{$typ}>" . date('Ymd\TH:i:s', $val) . "</{$typ}>"; |
|
283 | + $rs .= "<{$typ}>".date('Ymd\TH:i:s', $val)."</{$typ}>"; |
|
284 | 284 | } else { |
285 | 285 | // not really a good idea here: but what should we output anyway? left for backward compat... |
286 | 286 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | case 3: |
303 | 303 | // struct |
304 | 304 | if ($this->_php_class) { |
305 | - $rs .= '<struct php_class="' . $this->_php_class . "\">\n"; |
|
305 | + $rs .= '<struct php_class="'.$this->_php_class."\">\n"; |
|
306 | 306 | } else { |
307 | 307 | $rs .= "<struct>\n"; |
308 | 308 | } |
309 | 309 | $charsetEncoder = $this->getCharsetEncoder(); |
310 | 310 | /** @var Value $val2 */ |
311 | 311 | foreach ($val as $key2 => $val2) { |
312 | - $rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n"; |
|
312 | + $rs .= '<member><name>'.$charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</name>\n"; |
|
313 | 313 | //$rs.=$this->serializeval($val2); |
314 | 314 | $rs .= $val2->serialize($charsetEncoding); |
315 | 315 | $rs .= "</member>\n"; |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $val = reset($this->me); |
345 | 345 | $typ = key($this->me); |
346 | 346 | |
347 | - return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n"; |
|
347 | + return '<value>'.$this->serializedata($typ, $val, $charsetEncoding)."</value>\n"; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public static function xmlrpc_debugmsg($msg) |
193 | 193 | { |
194 | - static::$_xmlrpc_debuginfo .= $msg . "\n"; |
|
194 | + static::$_xmlrpc_debuginfo .= $msg."\n"; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function error_occurred($msg) |
205 | 205 | { |
206 | - static::$_xmlrpcs_occurred_errors .= $msg . "\n"; |
|
206 | + static::$_xmlrpcs_occurred_errors .= $msg."\n"; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | // user debug info should be encoded by the end user using the INTERNAL_ENCODING |
225 | 225 | $out = ''; |
226 | 226 | if ($this->debug_info != '') { |
227 | - $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n"; |
|
227 | + $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; |
|
228 | 228 | } |
229 | 229 | if (static::$_xmlrpc_debuginfo != '') { |
230 | - $out .= "<!-- DEBUG INFO:\n" . $this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n"; |
|
230 | + $out .= "<!-- DEBUG INFO:\n".$this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n"; |
|
231 | 231 | // NB: a better solution MIGHT be to use CDATA, but we need to insert it |
232 | 232 | // into return payload AFTER the beginning tag |
233 | 233 | //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n"; |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $this->debug_info = ''; |
257 | 257 | |
258 | 258 | // Save what we received, before parsing it |
259 | - if ($this->debug > 1) { |
|
260 | - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); |
|
259 | + if ($this->debug>1) { |
|
260 | + $this->debugmsg("+++GOT+++\n".$data."\n+++END+++"); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | $resp = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding); |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | $resp->raw_data = $rawData; |
275 | 275 | } |
276 | 276 | |
277 | - if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors != '') { |
|
278 | - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . |
|
279 | - static::$_xmlrpcs_occurred_errors . "+++END+++"); |
|
277 | + if ($this->debug>2 && static::$_xmlrpcs_occurred_errors != '') { |
|
278 | + $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n". |
|
279 | + static::$_xmlrpcs_occurred_errors."+++END+++"); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $payload = $this->xml_header($respCharset); |
283 | - if ($this->debug > 0) { |
|
284 | - $payload = $payload . $this->serializeDebug($respCharset); |
|
283 | + if ($this->debug>0) { |
|
284 | + $payload = $payload.$this->serializeDebug($respCharset); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Do not create response serialization if it has already happened. Helps to build json magic |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | if (empty($resp->payload)) { |
290 | 290 | $resp->serialize($respCharset); |
291 | 291 | } |
292 | - $payload = $payload . $resp->payload; |
|
292 | + $payload = $payload.$resp->payload; |
|
293 | 293 | |
294 | 294 | if ($returnPayload) { |
295 | 295 | return $payload; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | // if we get a warning/error that has output some text before here, then we cannot |
299 | 299 | // add a new header. We cannot say we are sending xml, either... |
300 | 300 | if (!headers_sent()) { |
301 | - header('Content-Type: ' . $resp->content_type); |
|
301 | + header('Content-Type: '.$resp->content_type); |
|
302 | 302 | // we do not know if client actually told us an accepted charset, but if it did we have to tell it what we did |
303 | 303 | header("Vary: Accept-Charset"); |
304 | 304 | |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for |
322 | 322 | // responses up to 8000 bytes |
323 | 323 | if ($phpNoSelfCompress) { |
324 | - header('Content-Length: ' . (int)strlen($payload)); |
|
324 | + header('Content-Length: '.(int) strlen($payload)); |
|
325 | 325 | } |
326 | 326 | } else { |
327 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages'); |
|
327 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | print $payload; |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | $numParams = count($in); |
383 | 383 | } |
384 | 384 | foreach ($sigs as $curSig) { |
385 | - if (count($curSig) == $numParams + 1) { |
|
385 | + if (count($curSig) == $numParams+1) { |
|
386 | 386 | $itsOK = 1; |
387 | - for ($n = 0; $n < $numParams; $n++) { |
|
387 | + for ($n = 0; $n<$numParams; $n++) { |
|
388 | 388 | if (is_object($in)) { |
389 | 389 | $p = $in->getParam($n); |
390 | 390 | if ($p->kindOf() == 'scalar') { |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | } |
398 | 398 | |
399 | 399 | // param index is $n+1, as first member of sig is return type |
400 | - if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) { |
|
400 | + if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) { |
|
401 | 401 | $itsOK = 0; |
402 | - $pno = $n + 1; |
|
403 | - $wanted = $curSig[$n + 1]; |
|
402 | + $pno = $n+1; |
|
403 | + $wanted = $curSig[$n+1]; |
|
404 | 404 | $got = $pt; |
405 | 405 | break; |
406 | 406 | } |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | // check if $_SERVER is populated: it might have been disabled via ini file |
428 | 428 | // (this is true even when in CLI mode) |
429 | 429 | if (count($_SERVER) == 0) { |
430 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated'); |
|
430 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated'); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ($this->debug > 1) { |
|
433 | + if ($this->debug>1) { |
|
434 | 434 | if (function_exists('getallheaders')) { |
435 | 435 | $this->debugmsg(''); // empty line |
436 | 436 | foreach (getallheaders() as $name => $val) { |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) { |
456 | 456 | if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) { |
457 | 457 | $data = $degzdata; |
458 | - if ($this->debug > 1) { |
|
459 | - $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++"); |
|
458 | + if ($this->debug>1) { |
|
459 | + $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
460 | 460 | } |
461 | 461 | } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
462 | 462 | $data = $degzdata; |
463 | - if ($this->debug > 1) { |
|
464 | - $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++"); |
|
463 | + if ($this->debug>1) { |
|
464 | + $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
465 | 465 | } |
466 | 466 | } else { |
467 | 467 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'], |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | if ($reqEncoding == 'ISO-8859-1') { |
549 | 549 | $data = utf8_encode($data); |
550 | 550 | } else { |
551 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received request: ' . $reqEncoding); |
|
551 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': unsupported charset encoding of received request: '.$reqEncoding); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches); |
576 | 576 | return new Response( |
577 | 577 | 0, |
578 | - PhpXmlRpc::$xmlrpcerrxml + (int)$matches[1], |
|
578 | + PhpXmlRpc::$xmlrpcerrxml+(int) $matches[1], |
|
579 | 579 | $xmlRpcParser->_xh['isf_reason']); |
580 | 580 | } elseif ($xmlRpcParser->_xh['isf']) { |
581 | 581 | /// @todo separate better the various cases, as we have done in Request::parseResponse: invalid xml-rpc vs. |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | return new Response( |
584 | 584 | 0, |
585 | 585 | PhpXmlRpc::$xmlrpcerr['invalid_request'], |
586 | - PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']); |
|
586 | + PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']); |
|
587 | 587 | } else { |
588 | 588 | // small layering violation in favor of speed and memory usage: we should allow the 'execute' method handle |
589 | 589 | // this, but in the most common scenario (xml-rpc values type server with some methods registered as phpvals) |
@@ -593,20 +593,20 @@ discard block |
||
593 | 593 | ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] != 'xmlrpcvals') |
594 | 594 | ) |
595 | 595 | ) { |
596 | - if ($this->debug > 1) { |
|
597 | - $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++"); |
|
596 | + if ($this->debug>1) { |
|
597 | + $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++"); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']); |
601 | 601 | } else { |
602 | 602 | // build a Request object with data parsed from xml and add parameters in |
603 | 603 | $req = new Request($xmlRpcParser->_xh['method']); |
604 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
604 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
605 | 605 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
606 | 606 | } |
607 | 607 | |
608 | - if ($this->debug > 1) { |
|
609 | - $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++"); |
|
608 | + if ($this->debug>1) { |
|
609 | + $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++"); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | return $this->execute($req); |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | return new Response( |
659 | 659 | 0, |
660 | 660 | PhpXmlRpc::$xmlrpcerr['incorrect_params'], |
661 | - PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}" |
|
661 | + PhpXmlRpc::$xmlrpcstr['incorrect_params'].": {$errStr}" |
|
662 | 662 | ); |
663 | 663 | } |
664 | 664 | } |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | // build string representation of function 'name' |
674 | 674 | if (is_array($func)) { |
675 | 675 | if (is_object($func[0])) { |
676 | - $funcName = get_class($func[0]) . '->' . $func[1]; |
|
676 | + $funcName = get_class($func[0]).'->'.$func[1]; |
|
677 | 677 | } else { |
678 | 678 | $funcName = implode('::', $func); |
679 | 679 | } |
@@ -685,17 +685,17 @@ discard block |
||
685 | 685 | |
686 | 686 | // verify that function to be invoked is in fact callable |
687 | 687 | if (!is_callable($func)) { |
688 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable"); |
|
688 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable"); |
|
689 | 689 | return new Response( |
690 | 690 | 0, |
691 | 691 | PhpXmlRpc::$xmlrpcerr['server_error'], |
692 | - PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method" |
|
692 | + PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method" |
|
693 | 693 | ); |
694 | 694 | } |
695 | 695 | |
696 | 696 | // If debug level is 3, we should catch all errors generated during processing of user function, and log them |
697 | 697 | // as part of response |
698 | - if ($this->debug > 2) { |
|
698 | + if ($this->debug>2) { |
|
699 | 699 | self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler')); |
700 | 700 | } |
701 | 701 | |
@@ -709,14 +709,14 @@ discard block |
||
709 | 709 | $r = call_user_func($func, $req); |
710 | 710 | } |
711 | 711 | if (!is_a($r, 'PhpXmlRpc\Response')) { |
712 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r)); |
|
712 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r)); |
|
713 | 713 | if (is_a($r, 'PhpXmlRpc\Value')) { |
714 | 714 | $r = new Response($r); |
715 | 715 | } else { |
716 | 716 | $r = new Response( |
717 | 717 | 0, |
718 | 718 | PhpXmlRpc::$xmlrpcerr['server_error'], |
719 | - PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object" |
|
719 | + PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object" |
|
720 | 720 | ); |
721 | 721 | } |
722 | 722 | } |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $r = call_user_func_array($func, array($methodName, $params, $this->user_data)); |
732 | 732 | // mimic EPI behaviour: if we get an array that looks like an error, make it an error response |
733 | 733 | if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) { |
734 | - $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']); |
|
734 | + $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']); |
|
735 | 735 | } else { |
736 | 736 | // functions using EPI api should NOT return resp objects, so make sure we encode the |
737 | 737 | // return type correctly |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | // proper error-response |
756 | 756 | switch ($this->exception_handling) { |
757 | 757 | case 2: |
758 | - if ($this->debug > 2) { |
|
758 | + if ($this->debug>2) { |
|
759 | 759 | if (self::$_xmlrpcs_prev_ehandler) { |
760 | 760 | set_error_handler(self::$_xmlrpcs_prev_ehandler); |
761 | 761 | } else { |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | // proper error-response |
779 | 779 | switch ($this->exception_handling) { |
780 | 780 | case 2: |
781 | - if ($this->debug > 2) { |
|
781 | + if ($this->debug>2) { |
|
782 | 782 | if (self::$_xmlrpcs_prev_ehandler) { |
783 | 783 | set_error_handler(self::$_xmlrpcs_prev_ehandler); |
784 | 784 | } else { |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | } |
799 | 799 | } |
800 | 800 | |
801 | - if ($this->debug > 2) { |
|
801 | + if ($this->debug>2) { |
|
802 | 802 | // note: restore the error handler we found before calling the user func, even if it has been changed |
803 | 803 | // inside the func itself |
804 | 804 | if (self::$_xmlrpcs_prev_ehandler) { |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | */ |
865 | 865 | protected function debugmsg($string) |
866 | 866 | { |
867 | - $this->debug_info .= $string . "\n"; |
|
867 | + $this->debug_info .= $string."\n"; |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -874,9 +874,9 @@ discard block |
||
874 | 874 | protected function xml_header($charsetEncoding = '') |
875 | 875 | { |
876 | 876 | if ($charsetEncoding != '') { |
877 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n"; |
|
877 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n"; |
|
878 | 878 | } else { |
879 | - return "<?xml version=\"1.0\"?" . ">\n"; |
|
879 | + return "<?xml version=\"1.0\"?".">\n"; |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | $i++; // for error message, we count params from 1 |
1170 | 1170 | return static::_xmlrpcs_multicall_error(new Response(0, |
1171 | 1171 | PhpXmlRpc::$xmlrpcerr['incorrect_params'], |
1172 | - PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i)); |
|
1172 | + PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i)); |
|
1173 | 1173 | } |
1174 | 1174 | } |
1175 | 1175 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } |
1251 | 1251 | } else { |
1252 | 1252 | $numCalls = count($req); |
1253 | - for ($i = 0; $i < $numCalls; $i++) { |
|
1253 | + for ($i = 0; $i<$numCalls; $i++) { |
|
1254 | 1254 | $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]); |
1255 | 1255 | } |
1256 | 1256 | } |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | // q: can php be built without ctype? should we use a regexp? |
186 | 186 | if (is_string($key) && !ctype_digit($key)) { |
187 | 187 | /// @todo on invalid options, throw/error-out instead of logging an error message? |
188 | - switch($key) { |
|
188 | + switch ($key) { |
|
189 | 189 | case 'target_charset': |
190 | 190 | if (function_exists('mb_convert_encoding')) { |
191 | 191 | $this->current_parsing_options['target_charset'] = $val; |
192 | 192 | } else { |
193 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": 'target_charset' option is unsupported without mbstring"); |
|
193 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": 'target_charset' option is unsupported without mbstring"); |
|
194 | 194 | } |
195 | 195 | break; |
196 | 196 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | if (is_callable($val)) { |
199 | 199 | $this->current_parsing_options['methodname_callback'] = $val; |
200 | 200 | } else { |
201 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Callback passed as 'methodname_callback' is not callable"); |
|
201 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": Callback passed as 'methodname_callback' is not callable"); |
|
202 | 202 | } |
203 | 203 | break; |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | break; |
210 | 210 | |
211 | 211 | default: |
212 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": unsupported option: $key"); |
|
212 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": unsupported option: $key"); |
|
213 | 213 | } |
214 | 214 | unset($mergedOptions[$key]); |
215 | 215 | } |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | |
256 | 256 | try { |
257 | 257 | // @see ticket #70 - we have to parse big xml docs in chunks to avoid errors |
258 | - for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) { |
|
258 | + for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) { |
|
259 | 259 | $chunk = substr($data, $offset, $this->maxChunkLength); |
260 | 260 | // error handling: xml not well formed |
261 | - if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) { |
|
261 | + if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) { |
|
262 | 262 | $errCode = xml_get_error_code($parser); |
263 | 263 | $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode), |
264 | 264 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | break; |
269 | 269 | } |
270 | 270 | // no need to parse further if we already have a fatal error |
271 | - if ($this->_xh['isf'] >= 2) { |
|
271 | + if ($this->_xh['isf']>=2) { |
|
272 | 272 | break; |
273 | 273 | } |
274 | 274 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) |
302 | 302 | { |
303 | 303 | // if invalid xml-rpc already detected, skip all processing |
304 | - if ($this->_xh['isf'] >= 2) { |
|
304 | + if ($this->_xh['isf']>=2) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $this->_xh['rt'] = strtolower($name); |
326 | 326 | } else { |
327 | 327 | $this->_xh['isf'] = 2; |
328 | - $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name; |
|
328 | + $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name; |
|
329 | 329 | |
330 | 330 | return; |
331 | 331 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | |
428 | 428 | case 'MEMBER': |
429 | 429 | // set member name to null, in case we do not find in the xml later on |
430 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = null; |
|
430 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = null; |
|
431 | 431 | //$this->_xh['ac']=''; |
432 | 432 | // Drop trough intentionally |
433 | 433 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1) |
509 | 509 | { |
510 | - if ($this->_xh['isf'] >= 2) { |
|
510 | + if ($this->_xh['isf']>=2) { |
|
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $this->_xh['value'] = mb_convert_encoding($this->_xh['value'], $this->current_parsing_options['target_charset'], 'UTF-8'); |
530 | 530 | } |
531 | 531 | |
532 | - if ($rebuildXmlrpcvals > 0) { |
|
532 | + if ($rebuildXmlrpcvals>0) { |
|
533 | 533 | // build the xml-rpc val out of the data received, and substitute it |
534 | 534 | $temp = new Value($this->_xh['value'], $this->_xh['vt']); |
535 | 535 | // in case we got info about underlying php class, save it in the object we're rebuilding |
@@ -537,15 +537,15 @@ discard block |
||
537 | 537 | $temp->_php_class = $this->_xh['php_class']; |
538 | 538 | } |
539 | 539 | $this->_xh['value'] = $temp; |
540 | - } elseif ($rebuildXmlrpcvals < 0) { |
|
540 | + } elseif ($rebuildXmlrpcvals<0) { |
|
541 | 541 | if ($this->_xh['vt'] == Value::$xmlrpcDateTime) { |
542 | - $this->_xh['value'] = (object)array( |
|
542 | + $this->_xh['value'] = (object) array( |
|
543 | 543 | 'xmlrpc_type' => 'datetime', |
544 | 544 | 'scalar' => $this->_xh['value'], |
545 | 545 | 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($this->_xh['value']) |
546 | 546 | ); |
547 | 547 | } elseif ($this->_xh['vt'] == Value::$xmlrpcBase64) { |
548 | - $this->_xh['value'] = (object)array( |
|
548 | + $this->_xh['value'] = (object) array( |
|
549 | 549 | 'xmlrpc_type' => 'base64', |
550 | 550 | 'scalar' => $this->_xh['value'] |
551 | 551 | ); |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | // check if we are inside an array or struct: |
561 | 561 | // if value just built is inside an array, let's move it into array on the stack |
562 | 562 | $vscount = count($this->_xh['valuestack']); |
563 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
564 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value']; |
|
563 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
564 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value']; |
|
565 | 565 | } |
566 | 566 | break; |
567 | 567 | |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') !== 0) { |
591 | 591 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) { |
592 | 592 | $this->_xh['isf'] = 2; |
593 | - $this->_xh['isf_reason'] = 'Invalid data received in BOOLEAN value: ' . $this->truncateValueForLog($this->_xh['ac']); |
|
593 | + $this->_xh['isf_reason'] = 'Invalid data received in BOOLEAN value: '.$this->truncateValueForLog($this->_xh['ac']); |
|
594 | 594 | return; |
595 | 595 | } else { |
596 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in BOOLEAN value: ' . |
|
596 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': invalid data received in BOOLEAN value: '. |
|
597 | 597 | $this->truncateValueForLog($this->_xh['ac'])); |
598 | 598 | } |
599 | 599 | } |
@@ -615,17 +615,17 @@ discard block |
||
615 | 615 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) |
616 | 616 | { |
617 | 617 | $this->_xh['isf'] = 2; |
618 | - $this->_xh['isf_reason'] = 'Non numeric data received in INT value: ' . $this->truncateValueForLog($this->_xh['ac']); |
|
618 | + $this->_xh['isf_reason'] = 'Non numeric data received in INT value: '.$this->truncateValueForLog($this->_xh['ac']); |
|
619 | 619 | return; |
620 | 620 | } else { |
621 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': non numeric data received in INT: ' . |
|
621 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': non numeric data received in INT: '. |
|
622 | 622 | $this->truncateValueForLog($this->_xh['ac'])); |
623 | 623 | } |
624 | 624 | /// @todo: find a better way of reporting an error value than this! Use NaN? |
625 | 625 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
626 | 626 | } else { |
627 | 627 | // it's ok, add it on |
628 | - $this->_xh['value'] = (int)$this->_xh['ac']; |
|
628 | + $this->_xh['value'] = (int) $this->_xh['ac']; |
|
629 | 629 | } |
630 | 630 | break; |
631 | 631 | |
@@ -635,18 +635,18 @@ discard block |
||
635 | 635 | if (!preg_match(PhpXmlRpc::$xmlrpc_double_format, $this->_xh['ac'])) { |
636 | 636 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) { |
637 | 637 | $this->_xh['isf'] = 2; |
638 | - $this->_xh['isf_reason'] = 'Non numeric data received in DOUBLE value: ' . |
|
638 | + $this->_xh['isf_reason'] = 'Non numeric data received in DOUBLE value: '. |
|
639 | 639 | $this->truncateValueForLog($this->_xh['ac']); |
640 | 640 | return; |
641 | 641 | } else { |
642 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': non numeric data received in DOUBLE value: ' . |
|
642 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': non numeric data received in DOUBLE value: '. |
|
643 | 643 | $this->truncateValueForLog($this->_xh['ac'])); |
644 | 644 | } |
645 | 645 | |
646 | 646 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
647 | 647 | } else { |
648 | 648 | // it's ok, add it on |
649 | - $this->_xh['value'] = (double)$this->_xh['ac']; |
|
649 | + $this->_xh['value'] = (double) $this->_xh['ac']; |
|
650 | 650 | } |
651 | 651 | break; |
652 | 652 | |
@@ -656,19 +656,19 @@ discard block |
||
656 | 656 | if (!preg_match(PhpXmlRpc::$xmlrpc_datetime_format, $this->_xh['ac'])) { |
657 | 657 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) { |
658 | 658 | $this->_xh['isf'] = 2; |
659 | - $this->_xh['isf_reason'] = 'Invalid data received in DATETIME value: ' . $this->truncateValueForLog($this->_xh['ac']); |
|
659 | + $this->_xh['isf_reason'] = 'Invalid data received in DATETIME value: '.$this->truncateValueForLog($this->_xh['ac']); |
|
660 | 660 | return; |
661 | 661 | } else { |
662 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in DATETIME value: ' . |
|
662 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': invalid data received in DATETIME value: '. |
|
663 | 663 | $this->truncateValueForLog($this->_xh['ac'])); |
664 | 664 | } |
665 | 665 | } |
666 | 666 | if ($this->current_parsing_options['xmlrpc_return_datetimes']) { |
667 | 667 | try { |
668 | 668 | $this->_xh['value'] = new \DateTime($this->_xh['ac']); |
669 | - } catch(\Exception $e) { |
|
669 | + } catch (\Exception $e) { |
|
670 | 670 | // q: what to do? we can not guarantee that a valid date can be created. Return null or throw? |
671 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': ' . $e->getMessage()); |
|
671 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': '.$e->getMessage()); |
|
672 | 672 | $this->_xh['value'] = null; |
673 | 673 | } |
674 | 674 | } else { |
@@ -683,14 +683,14 @@ discard block |
||
683 | 683 | $v = base64_decode($this->_xh['ac'], true); |
684 | 684 | if ($v === false) { |
685 | 685 | $this->_xh['isf'] = 2; |
686 | - $this->_xh['isf_reason'] = 'Invalid data received in BASE64 value: '. $this->truncateValueForLog($this->_xh['ac']); |
|
686 | + $this->_xh['isf_reason'] = 'Invalid data received in BASE64 value: '.$this->truncateValueForLog($this->_xh['ac']); |
|
687 | 687 | return; |
688 | 688 | } |
689 | 689 | } else { |
690 | 690 | $v = base64_decode($this->_xh['ac']); |
691 | 691 | if ($v === '' && $this->_xh['ac'] !== '') { |
692 | 692 | // only the empty string should decode to the empty string |
693 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in BASE64 value: ' . |
|
693 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': invalid data received in BASE64 value: '. |
|
694 | 694 | $this->truncateValueForLog($this->_xh['ac'])); |
695 | 695 | } |
696 | 696 | } |
@@ -698,31 +698,31 @@ discard block |
||
698 | 698 | break; |
699 | 699 | |
700 | 700 | case 'NAME': |
701 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac']; |
|
701 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac']; |
|
702 | 702 | break; |
703 | 703 | |
704 | 704 | case 'MEMBER': |
705 | 705 | // add to array in the stack the last element built, unless no VALUE or no NAME were found |
706 | 706 | if ($this->_xh['vt']) { |
707 | 707 | $vscount = count($this->_xh['valuestack']); |
708 | - if ($this->_xh['valuestack'][$vscount - 1]['name'] === null) { |
|
708 | + if ($this->_xh['valuestack'][$vscount-1]['name'] === null) { |
|
709 | 709 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) { |
710 | 710 | $this->_xh['isf'] = 2; |
711 | 711 | $this->_xh['isf_reason'] = 'Missing NAME inside STRUCT in received xml'; |
712 | 712 | return; |
713 | 713 | } else { |
714 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': missing NAME inside STRUCT in received xml'); |
|
714 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': missing NAME inside STRUCT in received xml'); |
|
715 | 715 | } |
716 | - $this->_xh['valuestack'][$vscount - 1]['name'] = ''; |
|
716 | + $this->_xh['valuestack'][$vscount-1]['name'] = ''; |
|
717 | 717 | } |
718 | - $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value']; |
|
718 | + $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value']; |
|
719 | 719 | } else { |
720 | 720 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) { |
721 | 721 | $this->_xh['isf'] = 2; |
722 | 722 | $this->_xh['isf_reason'] = 'Missing VALUE inside STRUCT in received xml'; |
723 | 723 | return; |
724 | 724 | } else { |
725 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml'); |
|
725 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml'); |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | break; |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | $this->_xh['isf_reason'] = 'Missing VALUE inside PARAM in received xml'; |
755 | 755 | return; |
756 | 756 | } else { |
757 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml'); |
|
757 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml'); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | break; |
@@ -763,10 +763,10 @@ discard block |
||
763 | 763 | if (!preg_match(PhpXmlRpc::$xmlrpc_methodname_format, $this->_xh['ac'])) { |
764 | 764 | if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) { |
765 | 765 | $this->_xh['isf'] = 2; |
766 | - $this->_xh['isf_reason'] = 'Invalid data received in METHODNAME: '. $this->truncateValueForLog($this->_xh['ac']); |
|
766 | + $this->_xh['isf_reason'] = 'Invalid data received in METHODNAME: '.$this->truncateValueForLog($this->_xh['ac']); |
|
767 | 767 | return; |
768 | 768 | } else { |
769 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in METHODNAME: '. |
|
769 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': invalid data received in METHODNAME: '. |
|
770 | 770 | $this->truncateValueForLog($this->_xh['ac'])); |
771 | 771 | } |
772 | 772 | } |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | public function xmlrpc_cd($parser, $data) |
844 | 844 | { |
845 | 845 | // skip processing if xml fault already detected |
846 | - if ($this->_xh['isf'] >= 2) { |
|
846 | + if ($this->_xh['isf']>=2) { |
|
847 | 847 | return; |
848 | 848 | } |
849 | 849 | |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | public function xmlrpc_dh($parser, $data) |
866 | 866 | { |
867 | 867 | // skip processing if xml fault already detected |
868 | - if ($this->_xh['isf'] >= 2) { |
|
868 | + if ($this->_xh['isf']>=2) { |
|
869 | 869 | return; |
870 | 870 | } |
871 | 871 | |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | // Details: |
940 | 940 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
941 | 941 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
942 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
943 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
942 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
943 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
944 | 944 | $xmlChunk, $matches)) { |
945 | 945 | return strtoupper(substr($matches[2], 1, -1)); |
946 | 946 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
959 | 959 | // IANA also likes better US-ASCII, so go with it |
960 | 960 | if ($enc == 'ASCII') { |
961 | - $enc = 'US-' . $enc; |
|
961 | + $enc = 'US-'.$enc; |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | return $enc; |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | // Details: |
996 | 996 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
997 | 997 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
998 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
999 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
998 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
999 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
1000 | 1000 | $xmlChunk)) { |
1001 | 1001 | return true; |
1002 | 1002 | } |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | */ |
1012 | 1012 | protected function truncateValueForLog($data) |
1013 | 1013 | { |
1014 | - if (strlen($data) > $this->maxLogValueLength) { |
|
1015 | - return substr($data, 0, $this->maxLogValueLength - 3) . '...'; |
|
1014 | + if (strlen($data)>$this->maxLogValueLength) { |
|
1015 | + return substr($data, 0, $this->maxLogValueLength-3).'...'; |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | return $data; |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | break; |
1032 | 1032 | default: |
1033 | 1033 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
1034 | - trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
1034 | + trigger_error('Undefined property via __set(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
1035 | 1035 | } |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | break; |
1057 | 1057 | default: |
1058 | 1058 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
1059 | - trigger_error('Undefined property via __unset(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
1059 | + trigger_error('Undefined property via __unset(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | public function xml_header($charsetEncoding = '') |
58 | 58 | { |
59 | 59 | if ($charsetEncoding != '') { |
60 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n"; |
|
60 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n"; |
|
61 | 61 | } else { |
62 | - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
|
62 | + return "<?xml version=\"1.0\"?".">\n<methodCall>\n"; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | public function createPayload($charsetEncoding = '') |
83 | 83 | { |
84 | 84 | if ($charsetEncoding != '') { |
85 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
85 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
86 | 86 | } else { |
87 | 87 | $this->content_type = 'text/xml'; |
88 | 88 | } |
89 | 89 | $this->payload = $this->xml_header($charsetEncoding); |
90 | - $this->payload .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities( |
|
91 | - $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n"; |
|
90 | + $this->payload .= '<methodName>'.$this->getCharsetEncoder()->encodeEntities( |
|
91 | + $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n"; |
|
92 | 92 | $this->payload .= "<params>\n"; |
93 | 93 | foreach ($this->params as $p) { |
94 | - $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) . |
|
94 | + $this->payload .= "<param>\n".$p->serialize($charsetEncoding). |
|
95 | 95 | "</param>\n"; |
96 | 96 | } |
97 | 97 | $this->payload .= "</params>\n"; |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS) |
214 | 214 | { |
215 | - if ($this->debug > 0) { |
|
215 | + if ($this->debug>0) { |
|
216 | 216 | $this->getLogger()->debug("---GOT---\n$data\n---END---"); |
217 | 217 | } |
218 | 218 | |
219 | 219 | $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array()); |
220 | 220 | |
221 | 221 | if ($data == '') { |
222 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': no response received from server.'); |
|
222 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': no response received from server.'); |
|
223 | 223 | return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']); |
224 | 224 | } |
225 | 225 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | if (substr($data, 0, 4) == 'HTTP') { |
228 | 228 | $httpParser = new Http(); |
229 | 229 | try { |
230 | - $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug > 0); |
|
230 | + $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug>0); |
|
231 | 231 | } catch (HttpException $e) { |
232 | 232 | // failed processing of HTTP response headers |
233 | 233 | // save into response obj the full payload received, for debugging |
234 | 234 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code', $e->statusCode())); |
235 | - } catch(\Exception $e) { |
|
235 | + } catch (\Exception $e) { |
|
236 | 236 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data)); |
237 | 237 | } |
238 | 238 | } else { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
249 | 249 | $pos = strrpos($data, '</methodResponse>'); |
250 | 250 | if ($pos !== false) { |
251 | - $data = substr($data, 0, $pos + 17); |
|
251 | + $data = substr($data, 0, $pos+17); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | // try to 'guestimate' the character encoding of the received response |
@@ -257,21 +257,21 @@ discard block |
||
257 | 257 | $data |
258 | 258 | ); |
259 | 259 | |
260 | - if ($this->debug >= 0) { |
|
260 | + if ($this->debug>=0) { |
|
261 | 261 | $this->httpResponse = $httpResponse; |
262 | 262 | } else { |
263 | 263 | $httpResponse = null; |
264 | 264 | } |
265 | 265 | |
266 | - if ($this->debug > 0) { |
|
266 | + if ($this->debug>0) { |
|
267 | 267 | $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
268 | 268 | if ($start) { |
269 | 269 | $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
270 | 270 | /// @todo what if there is no end tag? |
271 | 271 | $end = strpos($data, '-->', $start); |
272 | - $comments = substr($data, $start, $end - $start); |
|
273 | - $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t" . |
|
274 | - str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", array('encoding' => $respEncoding)); |
|
272 | + $comments = substr($data, $start, $end-$start); |
|
273 | + $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t". |
|
274 | + str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", array('encoding' => $respEncoding)); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | if ($respEncoding == 'ISO-8859-1') { |
294 | 294 | $data = utf8_encode($data); |
295 | 295 | } else { |
296 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding); |
|
296 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': unsupported charset encoding of received response: '.$respEncoding); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | } |
@@ -319,16 +319,16 @@ discard block |
||
319 | 319 | // there could be proxies meddling with the request, or network data corruption... |
320 | 320 | |
321 | 321 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_xml'], |
322 | - PhpXmlRpc::$xmlrpcstr['invalid_xml'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
322 | + PhpXmlRpc::$xmlrpcstr['invalid_xml'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
323 | 323 | |
324 | - if ($this->debug > 0) { |
|
324 | + if ($this->debug>0) { |
|
325 | 325 | $this->getLogger()->debug($xmlRpcParser->_xh['isf_reason']); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | // second error check: xml well-formed but not xml-rpc compliant |
329 | 329 | elseif ($xmlRpcParser->_xh['isf'] == 2) { |
330 | 330 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_not_compliant'], |
331 | - PhpXmlRpc::$xmlrpcstr['xml_not_compliant'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
331 | + PhpXmlRpc::$xmlrpcstr['xml_not_compliant'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
332 | 332 | |
333 | 333 | /// @todo echo something for the user? check if it was already done by the parser... |
334 | 334 | //if ($this->debug > 0) { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | } |
338 | 338 | // third error check: parsing of the response has somehow gone boink. |
339 | 339 | /// @todo shall we omit this check, since we trust the parsing code? |
340 | - elseif ($xmlRpcParser->_xh['isf'] > 3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
340 | + elseif ($xmlRpcParser->_xh['isf']>3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
341 | 341 | // something odd has happened and it's time to generate a client side error indicating something odd went on |
342 | 342 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_parsing_error'], PhpXmlRpc::$xmlrpcstr['xml_parsing_error'], |
343 | 343 | '', $httpResponse |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | /// @todo echo something for the user? |
347 | 347 | } else { |
348 | - if ($this->debug > 1) { |
|
348 | + if ($this->debug>1) { |
|
349 | 349 | $this->getLogger()->debug( |
350 | 350 | "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" |
351 | 351 | ); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | if ($errNo == 0) { |
370 | 370 | // FAULT returned, errno needs to reflect that |
371 | 371 | /// @todo feature creep - add this code to PhpXmlRpc::$xmlrpcerr |
372 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': fault response received with faultCode 0 or null. Converted it to -1'); |
|
372 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': fault response received with faultCode 0 or null. Converted it to -1'); |
|
373 | 373 | $errNo = -1; |
374 | 374 | } |
375 | 375 |