@@ -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 | } |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
4 | -include_once __DIR__ . '/../lib/xmlrpcs.inc'; |
|
3 | +include_once __DIR__.'/../lib/xmlrpc.inc'; |
|
4 | +include_once __DIR__.'/../lib/xmlrpcs.inc'; |
|
5 | 5 | |
6 | -include_once __DIR__ . '/parse_args.php'; |
|
6 | +include_once __DIR__.'/parse_args.php'; |
|
7 | 7 | |
8 | -include_once __DIR__ . '/PolyfillTestCase.php'; |
|
8 | +include_once __DIR__.'/PolyfillTestCase.php'; |
|
9 | 9 | |
10 | 10 | use PHPUnit\Runner\BaseTestRunner; |
11 | 11 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | { |
23 | 23 | $this->args = argParser::getArgs(); |
24 | 24 | // hide parsing errors unless in debug mode |
25 | - if ($this->args['DEBUG'] < 1) |
|
25 | + if ($this->args['DEBUG']<1) |
|
26 | 26 | ob_start(); |
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function tear_down() |
30 | 30 | { |
31 | - if ($this->args['DEBUG'] >= 1) |
|
31 | + if ($this->args['DEBUG']>=1) |
|
32 | 32 | return; |
33 | 33 | $out = ob_get_clean(); |
34 | 34 | $status = $this->getStatus(); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | public function testI8() |
132 | 132 | { |
133 | - if (PHP_INT_SIZE == 4 ) { |
|
133 | + if (PHP_INT_SIZE == 4) { |
|
134 | 134 | $this->markTestSkipped('Can not test i8 as php is compiled in 32 bit mode'); |
135 | 135 | return; |
136 | 136 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | public function testUnicodeInMemberName() |
207 | 207 | { |
208 | - $str = "G" . chr(252) . "nter, El" . chr(232) . "ne"; |
|
208 | + $str = "G".chr(252)."nter, El".chr(232)."ne"; |
|
209 | 209 | $v = array($str => new xmlrpcval(1)); |
210 | 210 | $r = new xmlrpcresp(new xmlrpcval($v, 'struct')); |
211 | 211 | $r = $r->serialize(); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $response = @utf8_encode( |
222 | 222 | '<?xml version="1.0"?> |
223 | 223 | <!-- covers what happens when lib receives UTF8 chars in response text and comments --> |
224 | -<!-- ' . chr(224) . chr(252) . chr(232) . 'àüè --> |
|
224 | +<!-- ' . chr(224).chr(252).chr(232).'àüè --> |
|
225 | 225 | <methodResponse> |
226 | 226 | <fault> |
227 | 227 | <value> |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | </member> |
233 | 233 | <member> |
234 | 234 | <name>faultString</name> |
235 | -<value><string>' . chr(224) . chr(252) . chr(232) . 'àüè</string></value> |
|
235 | +<value><string>' . chr(224).chr(252).chr(232).'àüè</string></value> |
|
236 | 236 | </member> |
237 | 237 | </struct> |
238 | 238 | </value> |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $m = $this->newRequest('dummy'); |
242 | 242 | $r = $m->parseResponse($response); |
243 | 243 | $v = $r->faultString(); |
244 | - $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v); |
|
244 | + $this->assertEquals(chr(224).chr(252).chr(232).chr(224).chr(252).chr(232), $v); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | public function testBrokenRequests() |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | $i = \PhpXmlRpc\PhpXmlRpc::$xmlrpc_reject_invalid_values; |
449 | 449 | \PhpXmlRpc\PhpXmlRpc::$xmlrpc_reject_invalid_values = true; |
450 | 450 | |
451 | - foreach($values as $value) { |
|
452 | - $f = '<?xml version="1.0"?><methodResponse><params><param><value>' . $value . '</value></param></params></methodResponse> '; |
|
451 | + foreach ($values as $value) { |
|
452 | + $f = '<?xml version="1.0"?><methodResponse><params><param><value>'.$value.'</value></param></params></methodResponse> '; |
|
453 | 453 | $r = $s->parseResponse($f); |
454 | 454 | $v = $r->faultCode(); |
455 | 455 | $this->assertEquals(2, $v, "Testing $value"); |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | |
554 | 554 | public function testUTF8Response() |
555 | 555 | { |
556 | - $string = chr(224) . chr(252) . chr(232); |
|
556 | + $string = chr(224).chr(252).chr(232); |
|
557 | 557 | |
558 | 558 | $s = $this->newRequest('dummy'); |
559 | - $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
560 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
559 | + $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
560 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string).'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
561 | 561 | '; |
562 | 562 | $r = $s->parseResponse($f, false, 'phpvals'); |
563 | 563 | $v = $r->value(); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | $this->assertEquals($string, $v); |
566 | 566 | |
567 | 567 | $f = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
568 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
568 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string).'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
569 | 569 | '; |
570 | 570 | $r = $s->parseResponse($f, false, 'phpvals'); |
571 | 571 | $v = $r->value(); |
@@ -581,11 +581,11 @@ discard block |
||
581 | 581 | |
582 | 582 | public function testLatin1Response() |
583 | 583 | { |
584 | - $string = chr(224) . chr(252) . chr(232); |
|
584 | + $string = chr(224).chr(252).chr(232); |
|
585 | 585 | |
586 | 586 | $s = $this->newRequest('dummy'); |
587 | - $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
588 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
587 | + $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
|
588 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string.'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
589 | 589 | '; |
590 | 590 | $r = $s->parseResponse($f, false, 'phpvals'); |
591 | 591 | $v = $r->value(); |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $this->assertEquals($string, $v); |
594 | 594 | |
595 | 595 | $f = '<?xml version="1.0" encoding="ISO-8859-1"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member> |
596 | -<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
596 | +<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string.'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse> |
|
597 | 597 | '; |
598 | 598 | $r = $s->parseResponse($f, false, 'phpvals'); |
599 | 599 | $v = $r->value(); |
@@ -22,14 +22,16 @@ |
||
22 | 22 | { |
23 | 23 | $this->args = argParser::getArgs(); |
24 | 24 | // hide parsing errors unless in debug mode |
25 | - if ($this->args['DEBUG'] < 1) |
|
26 | - ob_start(); |
|
25 | + if ($this->args['DEBUG'] < 1) { |
|
26 | + ob_start(); |
|
27 | + } |
|
27 | 28 | } |
28 | 29 | |
29 | 30 | protected function tear_down() |
30 | 31 | { |
31 | - if ($this->args['DEBUG'] >= 1) |
|
32 | - return; |
|
32 | + if ($this->args['DEBUG'] >= 1) { |
|
33 | + return; |
|
34 | + } |
|
33 | 35 | $out = ob_get_clean(); |
34 | 36 | $status = $this->getStatus(); |
35 | 37 | if ($status == BaseTestRunner::STATUS_ERROR |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once __DIR__ . '/PolyfillTestCase.php'; |
|
3 | +include_once __DIR__.'/PolyfillTestCase.php'; |
|
4 | 4 | |
5 | 5 | use PhpXmlRpc\Helper\Charset; |
6 | 6 | use PhpXmlRpc\Helper\Http; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $l = $h->getLogger(); |
39 | 39 | Http::setLogger($this); |
40 | 40 | |
41 | - $s = "HTTP/1.0 200 OK\r\n" . |
|
42 | - "Content-Type: unknown\r\n" . |
|
43 | - "\r\n" . |
|
41 | + $s = "HTTP/1.0 200 OK\r\n". |
|
42 | + "Content-Type: unknown\r\n". |
|
43 | + "\r\n". |
|
44 | 44 | "body"; |
45 | 45 | ob_start(); |
46 | 46 | $h->parseResponseHeaders($s, false, 1); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
4 | -include_once __DIR__ . '/../lib/xmlrpcs.inc'; |
|
3 | +include_once __DIR__.'/../lib/xmlrpc.inc'; |
|
4 | +include_once __DIR__.'/../lib/xmlrpcs.inc'; |
|
5 | 5 | |
6 | -include_once __DIR__ . '/parse_args.php'; |
|
6 | +include_once __DIR__.'/parse_args.php'; |
|
7 | 7 | |
8 | -include_once __DIR__ . '/PolyfillTestCase.php'; |
|
8 | +include_once __DIR__.'/PolyfillTestCase.php'; |
|
9 | 9 | |
10 | 10 | use PHPUnit\Runner\BaseTestRunner; |
11 | 11 |
@@ -23,14 +23,16 @@ |
||
23 | 23 | { |
24 | 24 | $this->args = argParser::getArgs(); |
25 | 25 | // hide parsing errors unless in debug mode |
26 | - if ($this->args['DEBUG'] == 1) |
|
27 | - ob_start(); |
|
26 | + if ($this->args['DEBUG'] == 1) { |
|
27 | + ob_start(); |
|
28 | + } |
|
28 | 29 | } |
29 | 30 | |
30 | 31 | protected function tear_down() |
31 | 32 | { |
32 | - if ($this->args['DEBUG'] != 1) |
|
33 | - return; |
|
33 | + if ($this->args['DEBUG'] != 1) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | $out = ob_get_clean(); |
35 | 37 | $status = $this->getStatus(); |
36 | 38 | if ($status == BaseTestRunner::STATUS_ERROR |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // user declares the type of resp value: we "almost" trust it... but log errors just in case |
74 | 74 | if (($this->valtyp == 'xmlrpcvals' && (!is_a($this->val, 'PhpXmlRpc\Value'))) || |
75 | 75 | ($this->valtyp == 'xml' && (!is_string($this->val)))) { |
76 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in does not match type ' . $valType); |
|
76 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': value passed in does not match type '.$valType); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } |
@@ -152,33 +152,33 @@ discard block |
||
152 | 152 | public function serialize($charsetEncoding = '') |
153 | 153 | { |
154 | 154 | if ($charsetEncoding != '') { |
155 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
155 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
156 | 156 | } else { |
157 | 157 | $this->content_type = 'text/xml'; |
158 | 158 | } |
159 | 159 | if (PhpXmlRpc::$xmlrpc_null_apache_encoding) { |
160 | - $result = "<methodResponse xmlns:ex=\"" . PhpXmlRpc::$xmlrpc_null_apache_encoding_ns . "\">\n"; |
|
160 | + $result = "<methodResponse xmlns:ex=\"".PhpXmlRpc::$xmlrpc_null_apache_encoding_ns."\">\n"; |
|
161 | 161 | } else { |
162 | 162 | $result = "<methodResponse>\n"; |
163 | 163 | } |
164 | 164 | if ($this->errno) { |
165 | 165 | // Let non-ASCII response messages be tolerated by clients by xml-encoding non ascii chars |
166 | - $result .= "<fault>\n" . |
|
167 | - "<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno . |
|
168 | - "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . |
|
169 | - $this->getCharsetEncoder()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . |
|
166 | + $result .= "<fault>\n". |
|
167 | + "<value>\n<struct><member><name>faultCode</name>\n<value><int>".$this->errno. |
|
168 | + "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>". |
|
169 | + $this->getCharsetEncoder()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding). |
|
170 | 170 | "</string></value>\n</member>\n</struct>\n</value>\n</fault>"; |
171 | 171 | } else { |
172 | 172 | if (is_object($this->val) && is_a($this->val, 'PhpXmlRpc\Value')) { |
173 | - $result .= "<params>\n<param>\n" . $this->val->serialize($charsetEncoding) . "</param>\n</params>"; |
|
173 | + $result .= "<params>\n<param>\n".$this->val->serialize($charsetEncoding)."</param>\n</params>"; |
|
174 | 174 | } else if (is_string($this->val) && $this->valtyp == 'xml') { |
175 | - $result .= "<params>\n<param>\n" . |
|
176 | - $this->val . |
|
175 | + $result .= "<params>\n<param>\n". |
|
176 | + $this->val. |
|
177 | 177 | "</param>\n</params>"; |
178 | 178 | } else if ($this->valtyp == 'phpvals') { |
179 | 179 | $encoder = new Encoder(); |
180 | 180 | $val = $encoder->encode($this->val); |
181 | - $result .= "<params>\n<param>\n" . $val->serialize($charsetEncoding) . "</param>\n</params>"; |
|
181 | + $result .= "<params>\n<param>\n".$val->serialize($charsetEncoding)."</param>\n</params>"; |
|
182 | 182 | } else { |
183 | 183 | throw new StateErrorException('cannot serialize xmlrpc response objects whose content is native php values'); |
184 | 184 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | return $this->httpResponse['raw_data']; |
205 | 205 | default: |
206 | 206 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
207 | - trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
207 | + trigger_error('Undefined property via __get(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
208 | 208 | return null; |
209 | 209 | } |
210 | 210 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | break; |
226 | 226 | default: |
227 | 227 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
228 | - trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
228 | + trigger_error('Undefined property via __set(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | break; |
260 | 260 | default: |
261 | 261 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
262 | - trigger_error('Undefined property via __unset(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
262 | + trigger_error('Undefined property via __unset(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
@@ -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"; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | return true; |
143 | 143 | } else { |
144 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in must be a PhpXmlRpc\Value'); |
|
144 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': value passed in must be a PhpXmlRpc\Value'); |
|
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | } |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS) |
215 | 215 | { |
216 | - if ($this->debug > 0) { |
|
216 | + if ($this->debug>0) { |
|
217 | 217 | $this->getLogger()->debug("---GOT---\n$data\n---END---"); |
218 | 218 | } |
219 | 219 | |
220 | 220 | $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array()); |
221 | 221 | |
222 | 222 | if ($data == '') { |
223 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': no response received from server.'); |
|
223 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': no response received from server.'); |
|
224 | 224 | return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']); |
225 | 225 | } |
226 | 226 | |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | if (substr($data, 0, 4) == 'HTTP') { |
229 | 229 | $httpParser = new Http(); |
230 | 230 | try { |
231 | - $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug > 0); |
|
231 | + $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug>0); |
|
232 | 232 | } catch (HttpException $e) { |
233 | 233 | // failed processing of HTTP response headers |
234 | 234 | // save into response obj the full payload received, for debugging |
235 | 235 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code', $e->statusCode())); |
236 | - } catch(\Exception $e) { |
|
236 | + } catch (\Exception $e) { |
|
237 | 237 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data)); |
238 | 238 | } |
239 | 239 | } else { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
250 | 250 | $pos = strrpos($data, '</methodResponse>'); |
251 | 251 | if ($pos !== false) { |
252 | - $data = substr($data, 0, $pos + 17); |
|
252 | + $data = substr($data, 0, $pos+17); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | // try to 'guestimate' the character encoding of the received response |
@@ -258,21 +258,21 @@ discard block |
||
258 | 258 | $data |
259 | 259 | ); |
260 | 260 | |
261 | - if ($this->debug >= 0) { |
|
261 | + if ($this->debug>=0) { |
|
262 | 262 | $this->httpResponse = $httpResponse; |
263 | 263 | } else { |
264 | 264 | $httpResponse = null; |
265 | 265 | } |
266 | 266 | |
267 | - if ($this->debug > 0) { |
|
267 | + if ($this->debug>0) { |
|
268 | 268 | $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
269 | 269 | if ($start) { |
270 | 270 | $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
271 | 271 | /// @todo what if there is no end tag? |
272 | 272 | $end = strpos($data, '-->', $start); |
273 | - $comments = substr($data, $start, $end - $start); |
|
274 | - $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t" . |
|
275 | - str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", array('encoding' => $respEncoding)); |
|
273 | + $comments = substr($data, $start, $end-$start); |
|
274 | + $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t". |
|
275 | + str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", array('encoding' => $respEncoding)); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | if ($respEncoding == 'ISO-8859-1') { |
295 | 295 | $data = utf8_encode($data); |
296 | 296 | } else { |
297 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding); |
|
297 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': unsupported charset encoding of received response: '.$respEncoding); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | } |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | // there could be proxies meddling with the request, or network data corruption... |
321 | 321 | |
322 | 322 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_xml'], |
323 | - PhpXmlRpc::$xmlrpcstr['invalid_xml'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
323 | + PhpXmlRpc::$xmlrpcstr['invalid_xml'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
324 | 324 | |
325 | - if ($this->debug > 0) { |
|
325 | + if ($this->debug>0) { |
|
326 | 326 | $this->getLogger()->debug($xmlRpcParser->_xh['isf_reason']); |
327 | 327 | } |
328 | 328 | } |
329 | 329 | // second error check: xml well-formed but not xml-rpc compliant |
330 | 330 | elseif ($xmlRpcParser->_xh['isf'] == 2) { |
331 | 331 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_not_compliant'], |
332 | - PhpXmlRpc::$xmlrpcstr['xml_not_compliant'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
332 | + PhpXmlRpc::$xmlrpcstr['xml_not_compliant'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
333 | 333 | |
334 | 334 | /// @todo echo something for the user? check if it was already done by the parser... |
335 | 335 | //if ($this->debug > 0) { |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | // third error check: parsing of the response has somehow gone boink. |
340 | 340 | /// @todo shall we omit this check, since we trust the parsing code? |
341 | - elseif ($xmlRpcParser->_xh['isf'] > 3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
341 | + elseif ($xmlRpcParser->_xh['isf']>3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
342 | 342 | // something odd has happened and it's time to generate a client side error indicating something odd went on |
343 | 343 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_parsing_error'], PhpXmlRpc::$xmlrpcstr['xml_parsing_error'], |
344 | 344 | '', $httpResponse |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | /// @todo echo something for the user? |
348 | 348 | } else { |
349 | - if ($this->debug > 1) { |
|
349 | + if ($this->debug>1) { |
|
350 | 350 | $this->getLogger()->debug( |
351 | 351 | "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" |
352 | 352 | ); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | if ($errNo == 0) { |
371 | 371 | // FAULT returned, errno needs to reflect that |
372 | 372 | /// @todo feature creep - add this code to PhpXmlRpc::$xmlrpcerr |
373 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': fault response received with faultCode 0 or null. Converted it to -1'); |
|
373 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': fault response received with faultCode 0 or null. Converted it to -1'); |
|
374 | 374 | $errNo = -1; |
375 | 375 | } |
376 | 376 |