@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | if (count($this->xml_iso88591_Entities['in'])) { |
77 | 77 | return; |
78 | 78 | } |
79 | - for ($i = 0; $i < 32; $i++) { |
|
79 | + for ($i = 0; $i<32; $i++) { |
|
80 | 80 | $this->xml_iso88591_Entities["in"][] = chr($i); |
81 | 81 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
85 | 85 | |
86 | - for ($i = 160; $i < 256; $i++) { |
|
86 | + for ($i = 160; $i<256; $i++) { |
|
87 | 87 | $this->xml_iso88591_Entities["in"][] = chr($i); |
88 | 88 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
89 | 89 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | break;*/ |
112 | 112 | |
113 | 113 | default: |
114 | - throw new ValueErrorException('Unsupported table: ' . $tableName); |
|
114 | + throw new ValueErrorException('Unsupported table: '.$tableName); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $srcEncoding = 'UTF-8'; |
164 | 164 | } |
165 | 165 | |
166 | - $conversion = strtoupper($srcEncoding . '_' . $destEncoding); |
|
166 | + $conversion = strtoupper($srcEncoding.'_'.$destEncoding); |
|
167 | 167 | |
168 | 168 | // list ordered with (expected) most common scenarios first |
169 | 169 | switch ($conversion) { |
@@ -181,20 +181,20 @@ discard block |
||
181 | 181 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
182 | 182 | $escapedData = ''; |
183 | 183 | // be kind to users creating string xml-rpc values out of different php types |
184 | - $data = (string)$data; |
|
184 | + $data = (string) $data; |
|
185 | 185 | $ns = strlen($data); |
186 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
186 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
187 | 187 | $ch = $data[$nn]; |
188 | 188 | $ii = ord($ch); |
189 | 189 | // 7 bits in 1 byte: 0bbbbbbb (127) |
190 | - if ($ii < 32) { |
|
190 | + if ($ii<32) { |
|
191 | 191 | if ($conversion == 'UTF-8_US-ASCII') { |
192 | 192 | $escapedData .= sprintf('&#%d;', $ii); |
193 | 193 | } else { |
194 | 194 | $escapedData .= $ch; |
195 | 195 | } |
196 | 196 | } |
197 | - else if ($ii < 128) { |
|
197 | + else if ($ii<128) { |
|
198 | 198 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
199 | 199 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
200 | 200 | switch ($ii) { |
@@ -219,25 +219,25 @@ discard block |
||
219 | 219 | } // 11 bits in 2 bytes: 110bbbbb 10bbbbbb (2047) |
220 | 220 | elseif ($ii >> 5 == 6) { |
221 | 221 | $b1 = ($ii & 31); |
222 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
223 | - $ii = ($b1 * 64) + $b2; |
|
222 | + $b2 = (ord($data[$nn+1]) & 63); |
|
223 | + $ii = ($b1 * 64)+$b2; |
|
224 | 224 | $escapedData .= sprintf('&#%d;', $ii); |
225 | 225 | $nn += 1; |
226 | 226 | } // 16 bits in 3 bytes: 1110bbbb 10bbbbbb 10bbbbbb |
227 | 227 | elseif ($ii >> 4 == 14) { |
228 | 228 | $b1 = ($ii & 15); |
229 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
230 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
231 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
229 | + $b2 = (ord($data[$nn+1]) & 63); |
|
230 | + $b3 = (ord($data[$nn+2]) & 63); |
|
231 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
232 | 232 | $escapedData .= sprintf('&#%d;', $ii); |
233 | 233 | $nn += 2; |
234 | 234 | } // 21 bits in 4 bytes: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
235 | 235 | elseif ($ii >> 3 == 30) { |
236 | 236 | $b1 = ($ii & 7); |
237 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
238 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
239 | - $b4 = (ord($data[$nn + 3]) & 63); |
|
240 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
237 | + $b2 = (ord($data[$nn+1]) & 63); |
|
238 | + $b3 = (ord($data[$nn+2]) & 63); |
|
239 | + $b4 = (ord($data[$nn+3]) & 63); |
|
240 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
241 | 241 | $escapedData .= sprintf('&#%d;', $ii); |
242 | 242 | $nn += 3; |
243 | 243 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | // If src is UTF8, we run htmlspecialchars before converting to the target charset, as |
291 | 291 | // htmlspecialchars has limited charset support, but it groks utf8 |
292 | 292 | if ($srcEncoding === 'UTF-8') { |
293 | - $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8'); |
|
293 | + $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8'); |
|
294 | 294 | } |
295 | 295 | if ($srcEncoding !== $destEncoding) { |
296 | 296 | try { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | if ($data === false) { |
304 | 304 | $escapedData = ''; |
305 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding via mbstring: failed..."); |
|
305 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding via mbstring: failed..."); |
|
306 | 306 | } else { |
307 | 307 | if ($srcEncoding === 'UTF-8') { |
308 | 308 | $escapedData = $data; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | } |
313 | 313 | } else { |
314 | 314 | $escapedData = ''; |
315 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
315 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if (function_exists('mb_list_encodings')) { |
331 | 331 | $knownCharsets = array_unique(array_merge($knownCharsets, array_diff(mb_list_encodings(), array( |
332 | 332 | 'pass', 'auto', 'wchar', 'BASE64', 'UUENCODE', 'ASCII', 'HTML-ENTITIES', 'Quoted-Printable', |
333 | - '7bit','8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le' |
|
333 | + '7bit', '8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le' |
|
334 | 334 | )))); |
335 | 335 | } |
336 | 336 | return $knownCharsets; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function isValidCharset($encoding, $validList) |
349 | 349 | { |
350 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
350 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
351 | 351 | |
352 | 352 | if (is_string($validList)) { |
353 | 353 | $validList = explode(',', $validList); |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function getEntities($charset) |
379 | 379 | { |
380 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
380 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
381 | 381 | |
382 | 382 | switch ($charset) |
383 | 383 | { |
384 | 384 | case 'iso88591': |
385 | 385 | return $this->xml_iso88591_Entities; |
386 | 386 | default: |
387 | - throw new ValueErrorException('Unsupported charset: ' . $charset); |
|
387 | + throw new ValueErrorException('Unsupported charset: '.$charset); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->me['struct'] = $val; |
97 | 97 | break; |
98 | 98 | default: |
99 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a known type ($type)"); |
|
99 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": not a known type ($type)"); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | if ($typeOf !== 1) { |
129 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)"); |
|
129 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": not a scalar type ($type)"); |
|
130 | 130 | return 0; |
131 | 131 | } |
132 | 132 | |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | |
144 | 144 | switch ($this->mytype) { |
145 | 145 | case 1: |
146 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value'); |
|
146 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': scalar xmlrpc value can have only one value'); |
|
147 | 147 | return 0; |
148 | 148 | case 3: |
149 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value'); |
|
149 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpc value'); |
|
150 | 150 | return 0; |
151 | 151 | case 2: |
152 | 152 | // we're adding a scalar value to an array here |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | return 1; |
192 | 192 | } else { |
193 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
193 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
194 | 194 | return 0; |
195 | 195 | } |
196 | 196 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | return 1; |
223 | 223 | } else { |
224 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
224 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
225 | 225 | return 0; |
226 | 226 | } |
227 | 227 | } |
@@ -265,19 +265,19 @@ discard block |
||
265 | 265 | case 1: |
266 | 266 | switch ($typ) { |
267 | 267 | case static::$xmlrpcBase64: |
268 | - $rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>"; |
|
268 | + $rs .= "<{$typ}>".base64_encode($val)."</{$typ}>"; |
|
269 | 269 | break; |
270 | 270 | case static::$xmlrpcBoolean: |
271 | - $rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>"; |
|
271 | + $rs .= "<{$typ}>".($val ? '1' : '0')."</{$typ}>"; |
|
272 | 272 | break; |
273 | 273 | case static::$xmlrpcString: |
274 | 274 | // Do NOT use htmlentities, since it will produce named html entities, which are invalid xml |
275 | - $rs .= "<{$typ}>" . $this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</{$typ}>"; |
|
275 | + $rs .= "<{$typ}>".$this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</{$typ}>"; |
|
276 | 276 | break; |
277 | 277 | case static::$xmlrpcInt: |
278 | 278 | case static::$xmlrpcI4: |
279 | 279 | case static::$xmlrpcI8: |
280 | - $rs .= "<{$typ}>" . (int)$val . "</{$typ}>"; |
|
280 | + $rs .= "<{$typ}>".(int) $val."</{$typ}>"; |
|
281 | 281 | break; |
282 | 282 | case static::$xmlrpcDouble: |
283 | 283 | // avoid using standard conversion of float to string because it is locale-dependent, |
@@ -285,16 +285,16 @@ discard block |
||
285 | 285 | // sprintf('%F') could be most likely ok, but it fails e.g. on 2e-14. |
286 | 286 | // The code below tries its best at keeping max precision while avoiding exp notation, |
287 | 287 | // but there is of course no limit in the number of decimal places to be used... |
288 | - $rs .= "<{$typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, PhpXmlRpc::$xmlpc_double_precision, '.', '')) . "</{$typ}>"; |
|
288 | + $rs .= "<{$typ}>".preg_replace('/\\.?0+$/', '', number_format((double) $val, PhpXmlRpc::$xmlpc_double_precision, '.', ''))."</{$typ}>"; |
|
289 | 289 | break; |
290 | 290 | case static::$xmlrpcDateTime: |
291 | 291 | if (is_string($val)) { |
292 | 292 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
293 | 293 | // DateTimeInterface is not present in php 5.4... |
294 | 294 | } elseif (is_a($val, 'DateTimeInterface') || is_a($val, 'DateTime')) { |
295 | - $rs .= "<{$typ}>" . $val->format('Ymd\TH:i:s') . "</{$typ}>"; |
|
295 | + $rs .= "<{$typ}>".$val->format('Ymd\TH:i:s')."</{$typ}>"; |
|
296 | 296 | } elseif (is_int($val)) { |
297 | - $rs .= "<{$typ}>" . date('Ymd\TH:i:s', $val) . "</{$typ}>"; |
|
297 | + $rs .= "<{$typ}>".date('Ymd\TH:i:s', $val)."</{$typ}>"; |
|
298 | 298 | } else { |
299 | 299 | // not really a good idea here: but what should we output anyway? left for backward compat... |
300 | 300 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
@@ -316,14 +316,14 @@ discard block |
||
316 | 316 | case 3: |
317 | 317 | // struct |
318 | 318 | if ($this->_php_class) { |
319 | - $rs .= '<struct php_class="' . $this->_php_class . "\">\n"; |
|
319 | + $rs .= '<struct php_class="'.$this->_php_class."\">\n"; |
|
320 | 320 | } else { |
321 | 321 | $rs .= "<struct>\n"; |
322 | 322 | } |
323 | 323 | $charsetEncoder = $this->getCharsetEncoder(); |
324 | 324 | /** @var Value $val2 */ |
325 | 325 | foreach ($val as $key2 => $val2) { |
326 | - $rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n"; |
|
326 | + $rs .= '<member><name>'.$charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</name>\n"; |
|
327 | 327 | //$rs.=$this->serializeval($val2); |
328 | 328 | $rs .= $val2->serialize($charsetEncoding); |
329 | 329 | $rs .= "</member>\n"; |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $val = reset($this->me); |
359 | 359 | $typ = key($this->me); |
360 | 360 | |
361 | - return '<value>' . $this->serializeData($typ, $val, $charsetEncoding) . "</value>\n"; |
|
361 | + return '<value>'.$this->serializeData($typ, $val, $charsetEncoding)."</value>\n"; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function structMemExists($key) |
375 | 375 | { |
376 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
376 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
377 | 377 | |
378 | 378 | return array_key_exists($key, $this->me['struct']); |
379 | 379 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public function structMem($key) |
391 | 391 | { |
392 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
392 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
393 | 393 | |
394 | 394 | return $this->me['struct'][$key]; |
395 | 395 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function structReset() |
404 | 404 | { |
405 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
405 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
406 | 406 | |
407 | 407 | reset($this->me['struct']); |
408 | 408 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function structEach() |
419 | 419 | { |
420 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
420 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
421 | 421 | |
422 | 422 | return @each($this->me['struct']); |
423 | 423 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function arrayMem($key) |
464 | 464 | { |
465 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
465 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
466 | 466 | |
467 | 467 | return $this->me['array'][$key]; |
468 | 468 | } |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | */ |
477 | 477 | public function arraySize() |
478 | 478 | { |
479 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
479 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
480 | 480 | |
481 | 481 | return count($this->me['array']); |
482 | 482 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | public function structSize() |
492 | 492 | { |
493 | - $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); |
|
493 | + $this->logDeprecation('Method '.__METHOD__.' is deprecated'); |
|
494 | 494 | |
495 | 495 | return count($this->me['struct']); |
496 | 496 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | - $this->getLogger()->warning('XML-RPC Deprecated: ' . $message); |
|
17 | + $this->getLogger()->warning('XML-RPC Deprecated: '.$message); |
|
18 | 18 | } |
19 | 19 | } |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | // q: can php be built without ctype? should we use a regexp? |
184 | 184 | if (is_string($key) && !ctype_digit($key)) { |
185 | 185 | /// @todo on invalid options, throw/error-out instead of logging an error message? |
186 | - switch($key) { |
|
186 | + switch ($key) { |
|
187 | 187 | case 'target_charset': |
188 | 188 | if (function_exists('mb_convert_encoding')) { |
189 | 189 | $this->current_parsing_options['target_charset'] = $val; |
190 | 190 | } else { |
191 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": 'target_charset' option is unsupported without mbstring"); |
|
191 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": 'target_charset' option is unsupported without mbstring"); |
|
192 | 192 | } |
193 | 193 | break; |
194 | 194 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | if (is_callable($val)) { |
197 | 197 | $this->current_parsing_options['methodname_callback'] = $val; |
198 | 198 | } else { |
199 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Callback passed as 'methodname_callback' is not callable"); |
|
199 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": Callback passed as 'methodname_callback' is not callable"); |
|
200 | 200 | } |
201 | 201 | break; |
202 | 202 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | break; |
208 | 208 | |
209 | 209 | default: |
210 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": unsupported option: $key"); |
|
210 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": unsupported option: $key"); |
|
211 | 211 | } |
212 | 212 | unset($mergedOptions[$key]); |
213 | 213 | } |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | |
254 | 254 | try { |
255 | 255 | // @see ticket #70 - we have to parse big xml docs in chunks to avoid errors |
256 | - for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) { |
|
256 | + for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) { |
|
257 | 257 | $chunk = substr($data, $offset, $this->maxChunkLength); |
258 | 258 | // error handling: xml not well formed |
259 | - if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) { |
|
259 | + if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) { |
|
260 | 260 | $errCode = xml_get_error_code($parser); |
261 | 261 | $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode), |
262 | 262 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $this->_xh['isf_reason'] = $errStr; |
266 | 266 | } |
267 | 267 | // no need to parse further if we already have a fatal error |
268 | - if ($this->_xh['isf'] >= 2) { |
|
268 | + if ($this->_xh['isf']>=2) { |
|
269 | 269 | break; |
270 | 270 | } |
271 | 271 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) |
304 | 304 | { |
305 | 305 | // if invalid xml-rpc already detected, skip all processing |
306 | - if ($this->_xh['isf'] >= 2) { |
|
306 | + if ($this->_xh['isf']>=2) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | if ($acceptSingleVals === false) { |
318 | 318 | $accept = $this->current_parsing_options['accept']; |
319 | 319 | } else { |
320 | - $this->logDeprecation('Using argument $acceptSingleVals for method ' . __METHOD__ . ' is deprecated'); |
|
320 | + $this->logDeprecation('Using argument $acceptSingleVals for method '.__METHOD__.' is deprecated'); |
|
321 | 321 | $accept = self::ACCEPT_REQUEST | self::ACCEPT_RESPONSE | self::ACCEPT_VALUE; |
322 | 322 | } |
323 | 323 | if (($name == 'METHODCALL' && ($accept & self::ACCEPT_REQUEST)) || |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $this->_xh['rt'] = strtolower($name); |
328 | 328 | } else { |
329 | 329 | $this->_xh['isf'] = 2; |
330 | - $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name; |
|
330 | + $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name; |
|
331 | 331 | |
332 | 332 | return; |
333 | 333 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | case 'MEMBER': |
431 | 431 | // set member name to null, in case we do not find in the xml later on |
432 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = null; |
|
432 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = null; |
|
433 | 433 | //$this->_xh['ac']=''; |
434 | 434 | // Drop trough intentionally |
435 | 435 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | */ |
511 | 511 | public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1) |
512 | 512 | { |
513 | - if ($this->_xh['isf'] >= 2) { |
|
513 | + if ($this->_xh['isf']>=2) { |
|
514 | 514 | return; |
515 | 515 | } |
516 | 516 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | $this->_xh['value'] = mb_convert_encoding($this->_xh['value'], $this->current_parsing_options['target_charset'], 'UTF-8'); |
533 | 533 | } |
534 | 534 | |
535 | - if ($rebuildXmlrpcvals > 0) { |
|
535 | + if ($rebuildXmlrpcvals>0) { |
|
536 | 536 | // build the xml-rpc val out of the data received, and substitute it |
537 | 537 | $temp = new Value($this->_xh['value'], $this->_xh['vt']); |
538 | 538 | // in case we got info about underlying php class, save it in the object we're rebuilding |
@@ -540,15 +540,15 @@ discard block |
||
540 | 540 | $temp->_php_class = $this->_xh['php_class']; |
541 | 541 | } |
542 | 542 | $this->_xh['value'] = $temp; |
543 | - } elseif ($rebuildXmlrpcvals < 0) { |
|
543 | + } elseif ($rebuildXmlrpcvals<0) { |
|
544 | 544 | if ($this->_xh['vt'] == Value::$xmlrpcDateTime) { |
545 | - $this->_xh['value'] = (object)array( |
|
545 | + $this->_xh['value'] = (object) array( |
|
546 | 546 | 'xmlrpc_type' => 'datetime', |
547 | 547 | 'scalar' => $this->_xh['value'], |
548 | 548 | 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($this->_xh['value']) |
549 | 549 | ); |
550 | 550 | } elseif ($this->_xh['vt'] == Value::$xmlrpcBase64) { |
551 | - $this->_xh['value'] = (object)array( |
|
551 | + $this->_xh['value'] = (object) array( |
|
552 | 552 | 'xmlrpc_type' => 'base64', |
553 | 553 | 'scalar' => $this->_xh['value'] |
554 | 554 | ); |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | // check if we are inside an array or struct: |
564 | 564 | // if value just built is inside an array, let's move it into array on the stack |
565 | 565 | $vscount = count($this->_xh['valuestack']); |
566 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
567 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value']; |
|
566 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
567 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value']; |
|
568 | 568 | } |
569 | 569 | break; |
570 | 570 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | // log if receiving something strange, even though we set the value to false anyway |
592 | 592 | /// @todo to be consistent with the other types, we should return a value outside the good-value domain, e.g. NULL |
593 | 593 | if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') !== 0) { |
594 | - if (!$this->handleParsingError('invalid data received in BOOLEAN value: ' . |
|
594 | + if (!$this->handleParsingError('invalid data received in BOOLEAN value: '. |
|
595 | 595 | $this->truncateValueForLog($this->_xh['ac']), __METHOD__)) { |
596 | 596 | return; |
597 | 597 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $this->_xh['vt'] = strtolower($name); |
612 | 612 | $this->_xh['lv'] = 3; // indicate we've found a value |
613 | 613 | if (!preg_match(PhpXmlRpc::$xmlrpc_int_format, $this->_xh['ac'])) { |
614 | - if (!$this->handleParsingError('non numeric data received in INT value: ' . |
|
614 | + if (!$this->handleParsingError('non numeric data received in INT value: '. |
|
615 | 615 | $this->truncateValueForLog($this->_xh['ac']), __METHOD__)) { |
616 | 616 | return; |
617 | 617 | } |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
620 | 620 | } else { |
621 | 621 | // it's ok, add it on |
622 | - $this->_xh['value'] = (int)$this->_xh['ac']; |
|
622 | + $this->_xh['value'] = (int) $this->_xh['ac']; |
|
623 | 623 | } |
624 | 624 | break; |
625 | 625 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | $this->_xh['vt'] = Value::$xmlrpcDouble; |
628 | 628 | $this->_xh['lv'] = 3; // indicate we've found a value |
629 | 629 | if (!preg_match(PhpXmlRpc::$xmlrpc_double_format, $this->_xh['ac'])) { |
630 | - if (!$this->handleParsingError('non numeric data received in DOUBLE value: ' . |
|
630 | + if (!$this->handleParsingError('non numeric data received in DOUBLE value: '. |
|
631 | 631 | $this->truncateValueForLog($this->_xh['ac']), __METHOD__)) { |
632 | 632 | return; |
633 | 633 | } |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
636 | 636 | } else { |
637 | 637 | // it's ok, add it on |
638 | - $this->_xh['value'] = (double)$this->_xh['ac']; |
|
638 | + $this->_xh['value'] = (double) $this->_xh['ac']; |
|
639 | 639 | } |
640 | 640 | break; |
641 | 641 | |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | $this->_xh['vt'] = Value::$xmlrpcDateTime; |
644 | 644 | $this->_xh['lv'] = 3; // indicate we've found a value |
645 | 645 | if (!preg_match(PhpXmlRpc::$xmlrpc_datetime_format, $this->_xh['ac'])) { |
646 | - if (!$this->handleParsingError('invalid data received in DATETIME value: ' . |
|
646 | + if (!$this->handleParsingError('invalid data received in DATETIME value: '. |
|
647 | 647 | $this->truncateValueForLog($this->_xh['ac']), __METHOD__)) { |
648 | 648 | return; |
649 | 649 | } |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | |
655 | 655 | // the default regex used to validate the date string a few lines above should make this case impossible, |
656 | 656 | // but one never knows... |
657 | - } catch(\Exception $e) { |
|
657 | + } catch (\Exception $e) { |
|
658 | 658 | // what to do? We can not guarantee that a valid date can be created. We return null... |
659 | - if (!$this->handleParsingError('invalid data received in DATETIME value. Error ' . |
|
659 | + if (!$this->handleParsingError('invalid data received in DATETIME value. Error '. |
|
660 | 660 | $e->getMessage(), __METHOD__)) { |
661 | 661 | return; |
662 | 662 | } |
@@ -673,14 +673,14 @@ discard block |
||
673 | 673 | $v = base64_decode($this->_xh['ac'], true); |
674 | 674 | if ($v === false) { |
675 | 675 | $this->_xh['isf'] = 2; |
676 | - $this->_xh['isf_reason'] = 'Invalid data received in BASE64 value: '. $this->truncateValueForLog($this->_xh['ac']); |
|
676 | + $this->_xh['isf_reason'] = 'Invalid data received in BASE64 value: '.$this->truncateValueForLog($this->_xh['ac']); |
|
677 | 677 | return; |
678 | 678 | } |
679 | 679 | } else { |
680 | 680 | $v = base64_decode($this->_xh['ac']); |
681 | 681 | if ($v === '' && $this->_xh['ac'] !== '') { |
682 | 682 | // only the empty string should decode to the empty string |
683 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in BASE64 value: ' . |
|
683 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': invalid data received in BASE64 value: '. |
|
684 | 684 | $this->truncateValueForLog($this->_xh['ac'])); |
685 | 685 | } |
686 | 686 | } |
@@ -688,20 +688,20 @@ discard block |
||
688 | 688 | break; |
689 | 689 | |
690 | 690 | case 'NAME': |
691 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac']; |
|
691 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac']; |
|
692 | 692 | break; |
693 | 693 | |
694 | 694 | case 'MEMBER': |
695 | 695 | // add to array in the stack the last element built, unless no VALUE or no NAME were found |
696 | 696 | if ($this->_xh['vt']) { |
697 | 697 | $vscount = count($this->_xh['valuestack']); |
698 | - if ($this->_xh['valuestack'][$vscount - 1]['name'] === null) { |
|
698 | + if ($this->_xh['valuestack'][$vscount-1]['name'] === null) { |
|
699 | 699 | if (!$this->handleParsingError('missing NAME inside STRUCT in received xml', __METHOD__)) { |
700 | 700 | return; |
701 | 701 | } |
702 | - $this->_xh['valuestack'][$vscount - 1]['name'] = ''; |
|
702 | + $this->_xh['valuestack'][$vscount-1]['name'] = ''; |
|
703 | 703 | } |
704 | - $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value']; |
|
704 | + $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value']; |
|
705 | 705 | } else { |
706 | 706 | if (!$this->handleParsingError('missing VALUE inside STRUCT in received xml', __METHOD__)) { |
707 | 707 | return; |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | public function xmlrpc_cd($parser, $data) |
818 | 818 | { |
819 | 819 | // skip processing if xml fault already detected |
820 | - if ($this->_xh['isf'] >= 2) { |
|
820 | + if ($this->_xh['isf']>=2) { |
|
821 | 821 | return; |
822 | 822 | } |
823 | 823 | |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | public function xmlrpc_dh($parser, $data) |
840 | 840 | { |
841 | 841 | // skip processing if xml fault already detected |
842 | - if ($this->_xh['isf'] >= 2) { |
|
842 | + if ($this->_xh['isf']>=2) { |
|
843 | 843 | return; |
844 | 844 | } |
845 | 845 | |
@@ -913,8 +913,8 @@ discard block |
||
913 | 913 | // Details: |
914 | 914 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
915 | 915 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
916 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
917 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
916 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
917 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
918 | 918 | $xmlChunk, $matches)) { |
919 | 919 | return strtoupper(substr($matches[2], 1, -1)); |
920 | 920 | } |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
933 | 933 | // IANA also likes better US-ASCII, so go with it |
934 | 934 | if ($enc == 'ASCII') { |
935 | - $enc = 'US-' . $enc; |
|
935 | + $enc = 'US-'.$enc; |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | return $enc; |
@@ -969,8 +969,8 @@ discard block |
||
969 | 969 | // Details: |
970 | 970 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
971 | 971 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
972 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
973 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
972 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
973 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
974 | 974 | $xmlChunk)) { |
975 | 975 | return true; |
976 | 976 | } |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | $this->_xh['isf_reason'] = ucfirst($message); |
991 | 991 | return false; |
992 | 992 | } else { |
993 | - $this->getLogger()->error('XML-RPC: ' . ($method != '' ? $method . ': ' : '') . $message); |
|
993 | + $this->getLogger()->error('XML-RPC: '.($method != '' ? $method.': ' : '').$message); |
|
994 | 994 | return true; |
995 | 995 | } |
996 | 996 | } |
@@ -1002,8 +1002,8 @@ discard block |
||
1002 | 1002 | */ |
1003 | 1003 | protected function truncateValueForLog($data) |
1004 | 1004 | { |
1005 | - if (strlen($data) > $this->maxLogValueLength) { |
|
1006 | - return substr($data, 0, $this->maxLogValueLength - 3) . '...'; |
|
1005 | + if (strlen($data)>$this->maxLogValueLength) { |
|
1006 | + return substr($data, 0, $this->maxLogValueLength-3).'...'; |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | return $data; |
@@ -1016,13 +1016,13 @@ discard block |
||
1016 | 1016 | switch ($name) { |
1017 | 1017 | // this should only ever be called by subclasses which overtook `parse()` |
1018 | 1018 | case 'accept': |
1019 | - $this->logDeprecation('Setting property XMLParser::' . $name . ' is deprecated'); |
|
1019 | + $this->logDeprecation('Setting property XMLParser::'.$name.' is deprecated'); |
|
1020 | 1020 | $this->current_parsing_options['accept'] = $value; |
1021 | 1021 | break; |
1022 | 1022 | default: |
1023 | 1023 | /// @todo throw instead? There are very few other places where the lib trigger errors which can potentially reach stdout... |
1024 | 1024 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
1025 | - trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
1025 | + trigger_error('Undefined property via __set(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | { |
1031 | 1031 | switch ($name) { |
1032 | 1032 | case 'accept': |
1033 | - $this->logDeprecation('Checking property XMLParser::' . $name . ' is deprecated'); |
|
1033 | + $this->logDeprecation('Checking property XMLParser::'.$name.' is deprecated'); |
|
1034 | 1034 | return isset($this->current_parsing_options['accept']); |
1035 | 1035 | default: |
1036 | 1036 | return false; |
@@ -1042,13 +1042,13 @@ discard block |
||
1042 | 1042 | switch ($name) { |
1043 | 1043 | // q: does this make sense at all? |
1044 | 1044 | case 'accept': |
1045 | - $this->logDeprecation('Unsetting property XMLParser::' . $name . ' is deprecated'); |
|
1045 | + $this->logDeprecation('Unsetting property XMLParser::'.$name.' is deprecated'); |
|
1046 | 1046 | unset($this->current_parsing_options['accept']); |
1047 | 1047 | break; |
1048 | 1048 | default: |
1049 | 1049 | /// @todo throw instead? There are very few other places where the lib trigger errors which can potentially reach stdout... |
1050 | 1050 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
1051 | - trigger_error('Undefined property via __unset(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
1051 | + trigger_error('Undefined property via __unset(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | } |
@@ -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 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function tear_down() |
34 | 34 | { |
35 | - if ($this->args['DEBUG'] > 0) { |
|
35 | + if ($this->args['DEBUG']>0) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | |
51 | 51 | public function debug($message, $context = array()) |
52 | 52 | { |
53 | - $this->buffer .= $message . "\n"; |
|
53 | + $this->buffer .= $message."\n"; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function error($message, $context = array()) |
57 | 57 | { |
58 | - $this->buffer .= $message . "\n"; |
|
58 | + $this->buffer .= $message."\n"; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function warning($message, $context = array()) |
62 | 62 | { |
63 | - $this->buffer .= $message . "\n"; |
|
63 | + $this->buffer .= $message."\n"; |
|
64 | 64 | } |
65 | 65 | } |
@@ -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 |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | // logger API |
22 | 22 | public function debug($message, $context = array()) |
23 | 23 | { |
24 | - $this->debugBuffer .= $message . "\n"; |
|
24 | + $this->debugBuffer .= $message."\n"; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function error($message, $context = array()) |
28 | 28 | { |
29 | - $this->errorBuffer .= $message . "\n"; |
|
29 | + $this->errorBuffer .= $message."\n"; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function warning($message, $context = array()) |
33 | 33 | { |
34 | - $this->warningBuffer .= $message . "\n"; |
|
34 | + $this->warningBuffer .= $message."\n"; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function getDebug() |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | |
63 | 63 | $input = array( |
64 | 64 | array('name' => 'Dave', 'age' => 24), |
65 | - array('name' => 'Edd', 'age' => 45), |
|
66 | - array('name' => 'Joe', 'age' => 37), |
|
65 | + array('name' => 'Edd', 'age' => 45), |
|
66 | + array('name' => 'Joe', 'age' => 37), |
|
67 | 67 | array('name' => 'Fred', 'age' => 27), |
68 | 68 | ); |
69 | 69 | |
@@ -85,6 +85,6 @@ discard block |
||
85 | 85 | $response = $client->send($request); |
86 | 86 | output("Response received.<br>"); |
87 | 87 | |
88 | -output("The client error info is:<pre>\n" . $logger->getError() . "\n</pre>"); |
|
89 | -output("The client warning info is:<pre>\n" . $logger->getWarning() . "\n</pre>"); |
|
90 | -output("The client debug info is:<pre>\n" . $logger->getDebug() . "\n</pre>"); |
|
88 | +output("The client error info is:<pre>\n".$logger->getError()."\n</pre>"); |
|
89 | +output("The client warning info is:<pre>\n".$logger->getWarning()."\n</pre>"); |
|
90 | +output("The client debug info is:<pre>\n".$logger->getDebug()."\n</pre>"); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | if ($response->faultCode()) { |
29 | 29 | throw new HttpException(502, $response->faultString()); |
30 | 30 | } else { |
31 | - return new Response("<html><body>State number $stateNo is: " . $response->value()->scalarVal() . '</body></html>'); |
|
31 | + return new Response("<html><body>State number $stateNo is: ".$response->value()->scalarVal().'</body></html>'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -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 the code-generation capabilities of the library: create all that is required to expose as xml-rpc methods |
@@ -38,33 +38,33 @@ discard block |
||
38 | 38 | // generate a file with a class definition |
39 | 39 | |
40 | 40 | // the generated code does not have an autoloader included - we need to add in one |
41 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
41 | +$autoloader = __DIR__."/_prepend.php"; |
|
42 | 42 | |
43 | 43 | file_put_contents($targetClassFile, |
44 | - "<?php\n\n" . |
|
45 | - "require_once '$autoloader';\n\n" . |
|
44 | + "<?php\n\n". |
|
45 | + "require_once '$autoloader';\n\n". |
|
46 | 46 | "class MyServerClass\n{\n\n" |
47 | 47 | ) || die('uh oh'); |
48 | 48 | |
49 | 49 | // we mangle a bit the code we get from wrapPhpClass to turn it into a php class definition instead of a bunch of functions |
50 | 50 | |
51 | -foreach($code as $methodName => $methodDef) { |
|
52 | - file_put_contents($targetClassFile, ' ' . str_replace(array('function ', "\n"), array('public static function ', "\n "), $methodDef['source']) . "\n\n", FILE_APPEND) || die('uh oh'); |
|
53 | - $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function']; |
|
51 | +foreach ($code as $methodName => $methodDef) { |
|
52 | + file_put_contents($targetClassFile, ' '.str_replace(array('function ', "\n"), array('public static function ', "\n "), $methodDef['source'])."\n\n", FILE_APPEND) || die('uh oh'); |
|
53 | + $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function']; |
|
54 | 54 | unset($code[$methodName]['source']); |
55 | 55 | } |
56 | 56 | file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh'); |
57 | 57 | |
58 | 58 | // generate separate files with the xml-rpc server instantiation and its dispatch map |
59 | 59 | |
60 | -file_put_contents($targetDispatchMapFile, "<?php\n\nreturn " . var_export($code, true) . ";\n"); |
|
60 | +file_put_contents($targetDispatchMapFile, "<?php\n\nreturn ".var_export($code, true).";\n"); |
|
61 | 61 | |
62 | 62 | file_put_contents($targetControllerFile, |
63 | - "<?php\n\n" . |
|
63 | + "<?php\n\n". |
|
64 | 64 | |
65 | - "require_once '$autoloader';\n\n" . |
|
65 | + "require_once '$autoloader';\n\n". |
|
66 | 66 | |
67 | - "require_once '$targetClassFile';\n\n" . |
|
67 | + "require_once '$targetClassFile';\n\n". |
|
68 | 68 | |
69 | 69 | // NB: since we are running the generated code within the same script, the existing CommentManager instance will be |
70 | 70 | // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | // Wrapper::holdObject('xmlrpc_CommentManager_addComment', $cm); |
75 | 75 | // Wrapper::holdObject('xmlrpc_CommentManager_getComments', $cm); |
76 | 76 | |
77 | - "\$dm = require_once '$targetDispatchMapFile';\n" . |
|
78 | - '$s = new \PhpXmlRpc\Server($dm, false);' . "\n\n" . |
|
79 | - '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!' . "\n" . |
|
80 | - '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);' . "\n" . |
|
81 | - '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);' . "\n\n" . |
|
82 | - '$s->service();' . "\n" |
|
77 | + "\$dm = require_once '$targetDispatchMapFile';\n". |
|
78 | + '$s = new \PhpXmlRpc\Server($dm, false);'."\n\n". |
|
79 | + '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!'."\n". |
|
80 | + '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);'."\n". |
|
81 | + '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);'."\n\n". |
|
82 | + '$s->service();'."\n" |
|
83 | 83 | ) || die('uh oh'); |
84 | 84 | |
85 | 85 | // test that everything worked by running it in realtime (note that this script will return an xml-rpc error message if |
@@ -173,20 +173,20 @@ discard block |
||
173 | 173 | $callable = explode('::', $callable); |
174 | 174 | } |
175 | 175 | if (is_array($callable)) { |
176 | - if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
177 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong'); |
|
176 | + if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
177 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong'); |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | if (is_string($callable[0])) { |
181 | 181 | $plainFuncName = implode('::', $callable); |
182 | 182 | } elseif (is_object($callable[0])) { |
183 | - $plainFuncName = get_class($callable[0]) . '->' . $callable[1]; |
|
183 | + $plainFuncName = get_class($callable[0]).'->'.$callable[1]; |
|
184 | 184 | } |
185 | 185 | $exists = method_exists($callable[0], $callable[1]); |
186 | 186 | } else if ($callable instanceof \Closure) { |
187 | 187 | // we do not support creating code which wraps closures, as php does not allow to serialize them |
188 | 188 | if (!$buildIt) { |
189 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code'); |
|
189 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code'); |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | if (!$exists) { |
201 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName); |
|
201 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName); |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
@@ -242,23 +242,23 @@ discard block |
||
242 | 242 | if (is_array($callable)) { |
243 | 243 | $func = new \ReflectionMethod($callable[0], $callable[1]); |
244 | 244 | if ($func->isPrivate()) { |
245 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName); |
|
245 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName); |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | if ($func->isProtected()) { |
249 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName); |
|
249 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName); |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | if ($func->isConstructor()) { |
253 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName); |
|
253 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName); |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | if ($func->isDestructor()) { |
257 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName); |
|
257 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName); |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | if ($func->isAbstract()) { |
261 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName); |
|
261 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName); |
|
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | /// @todo add more checks for static vs. nonstatic? |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | if ($func->isInternal()) { |
269 | 269 | /// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully |
270 | 270 | /// reflect internal php functions |
271 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName); |
|
271 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName); |
|
272 | 272 | return false; |
273 | 273 | } |
274 | 274 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $i = 0; |
321 | 321 | foreach ($func->getParameters() as $paramObj) { |
322 | 322 | $params[$i] = array(); |
323 | - $params[$i]['name'] = '$' . $paramObj->getName(); |
|
323 | + $params[$i]['name'] = '$'.$paramObj->getName(); |
|
324 | 324 | $params[$i]['isoptional'] = $paramObj->isOptional(); |
325 | 325 | $i++; |
326 | 326 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | // build a signature |
385 | 385 | $sig = array($this->php2XmlrpcType($funcDesc['returns'])); |
386 | 386 | $pSig = array($funcDesc['returnsDocs']); |
387 | - for ($i = 0; $i < count($pars); $i++) { |
|
387 | + for ($i = 0; $i<count($pars); $i++) { |
|
388 | 388 | $name = strtolower($funcDesc['params'][$i]['name']); |
389 | 389 | if (isset($funcDesc['paramDocs'][$name]['type'])) { |
390 | 390 | $sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | } |
441 | 441 | } |
442 | 442 | $numPars = $req->getNumParams(); |
443 | - if ($numPars < $minPars || $numPars > $maxPars) { |
|
443 | + if ($numPars<$minPars || $numPars>$maxPars) { |
|
444 | 444 | return new $responseClass(0, 3, 'Incorrect parameters passed to method'); |
445 | 445 | } |
446 | 446 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | $result = call_user_func_array($callable, $params); |
455 | 455 | |
456 | - if (! is_a($result, $responseClass)) { |
|
456 | + if (!is_a($result, $responseClass)) { |
|
457 | 457 | // q: why not do the same for int, float, bool, string? |
458 | 458 | if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
459 | 459 | $result = new $valueClass($result, $funcDesc['returns']); |
@@ -492,9 +492,9 @@ discard block |
||
492 | 492 | if ($newFuncName == '') { |
493 | 493 | if (is_array($callable)) { |
494 | 494 | if (is_string($callable[0])) { |
495 | - $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable); |
|
495 | + $xmlrpcFuncName = "{$prefix}_".implode('_', $callable); |
|
496 | 496 | } else { |
497 | - $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1]; |
|
497 | + $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1]; |
|
498 | 498 | } |
499 | 499 | } else { |
500 | 500 | if ($callable instanceof \Closure) { |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | */ |
527 | 527 | protected function buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc) |
528 | 528 | { |
529 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
530 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
531 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
529 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
530 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
531 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
532 | 532 | $catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : ''; |
533 | 533 | |
534 | 534 | $i = 0; |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | // build body of new function |
564 | 564 | |
565 | 565 | $innerCode = " \$paramCount = \$req->getNumParams();\n"; |
566 | - $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new " . static::$namespace . "Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n"; |
|
566 | + $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new ".static::$namespace."Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n"; |
|
567 | 567 | |
568 | - $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
568 | + $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
569 | 569 | if ($decodePhpObjects) { |
570 | 570 | $innerCode .= " \$params = \$encoder->decode(\$req, array('decode_php_objs'));\n"; |
571 | 571 | } else { |
@@ -578,23 +578,23 @@ discard block |
||
578 | 578 | static::holdObject($newFuncName, $callable[0]); |
579 | 579 | $class = get_class($callable[0]); |
580 | 580 | if ($class[0] !== '\\') { |
581 | - $class = '\\' . $class; |
|
581 | + $class = '\\'.$class; |
|
582 | 582 | } |
583 | 583 | $innerCode .= " /// @var $class \$obj\n"; |
584 | 584 | $innerCode .= " \$obj = PhpXmlRpc\\Wrapper::getHeldObject('$newFuncName');\n"; |
585 | - $realFuncName = '$obj->' . $callable[1]; |
|
585 | + $realFuncName = '$obj->'.$callable[1]; |
|
586 | 586 | } else { |
587 | 587 | $realFuncName = $plainFuncName; |
588 | 588 | } |
589 | 589 | foreach ($parsVariations as $i => $pars) { |
590 | - $innerCode .= " if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n"; |
|
591 | - if ($i < (count($parsVariations) - 1)) |
|
590 | + $innerCode .= " if (\$paramCount == ".count($pars).") \$retVal = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n"; |
|
591 | + if ($i<(count($parsVariations)-1)) |
|
592 | 592 | $innerCode .= " else\n"; |
593 | 593 | } |
594 | - $innerCode .= " if (is_a(\$retVal, '" . static::$namespace . "Response'))\n return \$retVal;\n else\n"; |
|
594 | + $innerCode .= " if (is_a(\$retVal, '".static::$namespace."Response'))\n return \$retVal;\n else\n"; |
|
595 | 595 | /// q: why not do the same for int, float, bool, string? |
596 | 596 | if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
597 | - $innerCode .= " return new " . static::$namespace . "Response(new " . static::$namespace . "Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
597 | + $innerCode .= " return new ".static::$namespace."Response(new ".static::$namespace."Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
598 | 598 | } else { |
599 | 599 | $encodeOptions = array(); |
600 | 600 | if ($encodeNulls) { |
@@ -605,18 +605,18 @@ discard block |
||
605 | 605 | } |
606 | 606 | |
607 | 607 | if ($encodeOptions) { |
608 | - $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal, array('" . |
|
609 | - implode("', '", $encodeOptions) . "')));"; |
|
608 | + $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal, array('". |
|
609 | + implode("', '", $encodeOptions)."')));"; |
|
610 | 610 | } else { |
611 | - $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal));"; |
|
611 | + $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal));"; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | // shall we exclude functions returning by ref? |
615 | 615 | // if ($func->returnsReference()) |
616 | 616 | // return false; |
617 | 617 | |
618 | - $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n" . |
|
619 | - "function $newFuncName(\$req)\n{\n" . $innerCode . "\n}"; |
|
618 | + $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n". |
|
619 | + "function $newFuncName(\$req)\n{\n".$innerCode."\n}"; |
|
620 | 620 | |
621 | 621 | return $code; |
622 | 622 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array()) |
677 | 677 | { |
678 | 678 | if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) { |
679 | - return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . $classMethod; |
|
679 | + return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | if (is_object($className)) { |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | } else { |
685 | 685 | $realClassName = $className; |
686 | 686 | } |
687 | - return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . "$realClassName.$classMethod"; |
|
687 | + return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod"; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -780,14 +780,14 @@ discard block |
||
780 | 780 | */ |
781 | 781 | protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array()) |
782 | 782 | { |
783 | - $reqClass = static::$namespace . 'Request'; |
|
784 | - $valClass = static::$namespace . 'Value'; |
|
785 | - $decoderClass = static::$namespace . 'Encoder'; |
|
783 | + $reqClass = static::$namespace.'Request'; |
|
784 | + $valClass = static::$namespace.'Value'; |
|
785 | + $decoderClass = static::$namespace.'Encoder'; |
|
786 | 786 | |
787 | 787 | $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
788 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
788 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
789 | 789 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
790 | - $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0; |
|
790 | + $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0; |
|
791 | 791 | |
792 | 792 | $req = new $reqClass('system.methodSignature'); |
793 | 793 | $req->addParam(new $valClass($methodName)); |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | $response = $client->send($req, $timeout, $protocol); |
798 | 798 | $client->setDebug($origDebug); |
799 | 799 | if ($response->faultCode()) { |
800 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName); |
|
800 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName); |
|
801 | 801 | return false; |
802 | 802 | } |
803 | 803 | |
@@ -808,8 +808,8 @@ discard block |
||
808 | 808 | $mSig = $decoder->decode($mSig); |
809 | 809 | } |
810 | 810 | |
811 | - if (!is_array($mSig) || count($mSig) <= $sigNum) { |
|
812 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName); |
|
811 | + if (!is_array($mSig) || count($mSig)<=$sigNum) { |
|
812 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName); |
|
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | */ |
825 | 825 | protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array()) |
826 | 826 | { |
827 | - $reqClass = static::$namespace . 'Request'; |
|
828 | - $valClass = static::$namespace . 'Value'; |
|
827 | + $reqClass = static::$namespace.'Request'; |
|
828 | + $valClass = static::$namespace.'Value'; |
|
829 | 829 | |
830 | 830 | $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
831 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
831 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
832 | 832 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
833 | 833 | |
834 | 834 | $mDesc = ''; |
@@ -865,11 +865,11 @@ discard block |
||
865 | 865 | $clientClone = clone $client; |
866 | 866 | $function = function() use($clientClone, $methodName, $extraOptions, $mSig) |
867 | 867 | { |
868 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
868 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
869 | 869 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
870 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
871 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
872 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
870 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
871 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
872 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
873 | 873 | $throwFault = false; |
874 | 874 | $decodeFault = false; |
875 | 875 | $faultResponse = null; |
@@ -880,9 +880,9 @@ discard block |
||
880 | 880 | $faultResponse = $extraOptions['return_on_fault']; |
881 | 881 | } |
882 | 882 | |
883 | - $reqClass = static::$namespace . 'Request'; |
|
884 | - $encoderClass = static::$namespace . 'Encoder'; |
|
885 | - $valueClass = static::$namespace . 'Value'; |
|
883 | + $reqClass = static::$namespace.'Request'; |
|
884 | + $encoderClass = static::$namespace.'Encoder'; |
|
885 | + $valueClass = static::$namespace.'Value'; |
|
886 | 886 | |
887 | 887 | $encoder = new $encoderClass(); |
888 | 888 | $encodeOptions = array(); |
@@ -964,14 +964,14 @@ discard block |
||
964 | 964 | * @param string $mDesc |
965 | 965 | * @return string[] keys: source, docstring |
966 | 966 | */ |
967 | - public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') |
|
967 | + public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '') |
|
968 | 968 | { |
969 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
969 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
970 | 970 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
971 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
972 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
973 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
974 | - $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0; |
|
971 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
972 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
973 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
974 | + $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0; |
|
975 | 975 | $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
976 | 976 | $throwFault = false; |
977 | 977 | $decodeFault = false; |
@@ -984,10 +984,10 @@ discard block |
||
984 | 984 | } |
985 | 985 | |
986 | 986 | $code = "function $newFuncName("; |
987 | - if ($clientCopyMode < 2) { |
|
987 | + if ($clientCopyMode<2) { |
|
988 | 988 | // client copy mode 0 or 1 == full / partial client copy in emitted code |
989 | 989 | $verbatimClientCopy = !$clientCopyMode; |
990 | - $innerCode = ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
990 | + $innerCode = ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
991 | 991 | $innerCode .= "\$client->setDebug(\$debug);\n"; |
992 | 992 | $this_ = ''; |
993 | 993 | } else { |
@@ -995,28 +995,28 @@ discard block |
||
995 | 995 | $innerCode = ''; |
996 | 996 | $this_ = 'this->'; |
997 | 997 | } |
998 | - $innerCode .= " \$req = new " . static::$namespace . "Request('$methodName');\n"; |
|
998 | + $innerCode .= " \$req = new ".static::$namespace."Request('$methodName');\n"; |
|
999 | 999 | |
1000 | 1000 | if ($mDesc != '') { |
1001 | 1001 | // take care that PHP comment is not terminated unwillingly by method description |
1002 | 1002 | /// @todo according to the spec, method desc can have html in it. We should run it through strip_tags... |
1003 | - $mDesc = "/**\n * " . str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc) . "\n"; |
|
1003 | + $mDesc = "/**\n * ".str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc)."\n"; |
|
1004 | 1004 | } else { |
1005 | 1005 | $mDesc = "/**\n * Function $newFuncName.\n"; |
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | // param parsing |
1009 | - $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
1009 | + $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
1010 | 1010 | $plist = array(); |
1011 | 1011 | $pCount = count($mSig); |
1012 | - for ($i = 1; $i < $pCount; $i++) { |
|
1012 | + for ($i = 1; $i<$pCount; $i++) { |
|
1013 | 1013 | $plist[] = "\$p$i"; |
1014 | 1014 | $pType = $mSig[$i]; |
1015 | 1015 | if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || |
1016 | 1016 | $pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null' |
1017 | 1017 | ) { |
1018 | 1018 | // only build directly xml-rpc values when type is known and scalar |
1019 | - $innerCode .= " \$p$i = new " . static::$namespace . "Value(\$p$i, '$pType');\n"; |
|
1019 | + $innerCode .= " \$p$i = new ".static::$namespace."Value(\$p$i, '$pType');\n"; |
|
1020 | 1020 | } else { |
1021 | 1021 | if ($encodePhpObjects || $encodeNulls) { |
1022 | 1022 | $encOpts = array(); |
@@ -1027,26 +1027,26 @@ discard block |
||
1027 | 1027 | $encOpts[] = 'null_extension'; |
1028 | 1028 | } |
1029 | 1029 | |
1030 | - $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '" . implode("', '", $encOpts) . "'));\n"; |
|
1030 | + $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '".implode("', '", $encOpts)."'));\n"; |
|
1031 | 1031 | } else { |
1032 | 1032 | $innerCode .= " \$p$i = \$encoder->encode(\$p$i);\n"; |
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | $innerCode .= " \$req->addParam(\$p$i);\n"; |
1036 | - $mDesc .= " * @param " . $this->xmlrpc2PhpType($pType) . " \$p$i\n"; |
|
1036 | + $mDesc .= " * @param ".$this->xmlrpc2PhpType($pType)." \$p$i\n"; |
|
1037 | 1037 | } |
1038 | - if ($clientCopyMode < 2) { |
|
1038 | + if ($clientCopyMode<2) { |
|
1039 | 1039 | $plist[] = '$debug = 0'; |
1040 | 1040 | $mDesc .= " * @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
1041 | 1041 | } |
1042 | 1042 | $plist = implode(', ', $plist); |
1043 | - $mDesc .= ' * @return ' . $this->xmlrpc2PhpType($mSig[0]); |
|
1043 | + $mDesc .= ' * @return '.$this->xmlrpc2PhpType($mSig[0]); |
|
1044 | 1044 | if ($throwFault) { |
1045 | - $mDesc .= "\n * @throws " . (is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
1045 | + $mDesc .= "\n * @throws ".(is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
1046 | 1046 | } else if ($decodeFault) { |
1047 | - $mDesc .= '|' . gettype($faultResponse) . " (a " . gettype($faultResponse) . " if call fails)"; |
|
1047 | + $mDesc .= '|'.gettype($faultResponse)." (a ".gettype($faultResponse)." if call fails)"; |
|
1048 | 1048 | } else { |
1049 | - $mDesc .= '|' . static::$namespace . "Response (a " . static::$namespace . "Response obj instance if call fails)"; |
|
1049 | + $mDesc .= '|'.static::$namespace."Response (a ".static::$namespace."Response obj instance if call fails)"; |
|
1050 | 1050 | } |
1051 | 1051 | $mDesc .= "\n */\n"; |
1052 | 1052 | |
@@ -1059,9 +1059,9 @@ discard block |
||
1059 | 1059 | $respCode = "throw new $throwFault(\$res->faultString(), \$res->faultCode())"; |
1060 | 1060 | } else if ($decodeFault) { |
1061 | 1061 | if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) { |
1062 | - $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')"; |
|
1062 | + $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')"; |
|
1063 | 1063 | } else { |
1064 | - $respCode = 'return ' . var_export($faultResponse, true); |
|
1064 | + $respCode = 'return '.var_export($faultResponse, true); |
|
1065 | 1065 | } |
1066 | 1066 | } else { |
1067 | 1067 | $respCode = 'return $res'; |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | $innerCode .= " if (\$res->faultCode()) $respCode; else return \$encoder->decode(\$res->value());"; |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - $code = $code . $plist . ")\n{\n" . $innerCode . "\n}\n"; |
|
1075 | + $code = $code.$plist.")\n{\n".$innerCode."\n}\n"; |
|
1076 | 1076 | |
1077 | 1077 | return array('source' => $code, 'docstring' => $mDesc); |
1078 | 1078 | } |
@@ -1102,26 +1102,26 @@ discard block |
||
1102 | 1102 | public function wrapXmlrpcServer($client, $extraOptions = array()) |
1103 | 1103 | { |
1104 | 1104 | $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : ''; |
1105 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
1105 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
1106 | 1106 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
1107 | 1107 | $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : ''; |
1108 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
1109 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
1110 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
1108 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
1109 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
1110 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
1111 | 1111 | $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true; |
1112 | - $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool)$extraOptions['throw_on_fault'] : false; |
|
1112 | + $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool) $extraOptions['throw_on_fault'] : false; |
|
1113 | 1113 | $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true; |
1114 | 1114 | $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
1115 | 1115 | |
1116 | - $reqClass = static::$namespace . 'Request'; |
|
1117 | - $decoderClass = static::$namespace . 'Encoder'; |
|
1116 | + $reqClass = static::$namespace.'Request'; |
|
1117 | + $decoderClass = static::$namespace.'Encoder'; |
|
1118 | 1118 | |
1119 | 1119 | // retrieve the list of methods |
1120 | 1120 | $req = new $reqClass('system.listMethods'); |
1121 | 1121 | /// @todo move setting of timeout, protocol to outside the send() call |
1122 | 1122 | $response = $client->send($req, $timeout, $protocol); |
1123 | 1123 | if ($response->faultCode()) { |
1124 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server'); |
|
1124 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server'); |
|
1125 | 1125 | |
1126 | 1126 | return false; |
1127 | 1127 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | $mList = $decoder->decode($mList); |
1133 | 1133 | } |
1134 | 1134 | if (!is_array($mList) || !count($mList)) { |
1135 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server'); |
|
1135 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server'); |
|
1136 | 1136 | |
1137 | 1137 | return false; |
1138 | 1138 | } |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | $xmlrpcClassName = $newClassName; |
1143 | 1143 | } else { |
1144 | 1144 | /// @todo direct access to $client->server is now deprecated |
1145 | - $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''), |
|
1146 | - $client->server) . '_client'; |
|
1145 | + $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''), |
|
1146 | + $client->server).'_client'; |
|
1147 | 1147 | } |
1148 | 1148 | while ($buildIt && class_exists($xmlrpcClassName)) { |
1149 | 1149 | $xmlrpcClassName .= 'x'; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | $source = "class $xmlrpcClassName\n{\n public \$client;\n\n"; |
1153 | 1153 | $source .= " function __construct()\n {\n"; |
1154 | - $source .= ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
1154 | + $source .= ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
1155 | 1155 | $source .= "\$this->client = \$client;\n }\n\n"; |
1156 | 1156 | $opts = array( |
1157 | 1157 | 'return_source' => true, |
@@ -1174,28 +1174,28 @@ discard block |
||
1174 | 1174 | $methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts); |
1175 | 1175 | if ($methodWrap) { |
1176 | 1176 | if ($buildIt) { |
1177 | - $source .= $methodWrap['source'] . "\n"; |
|
1177 | + $source .= $methodWrap['source']."\n"; |
|
1178 | 1178 | |
1179 | 1179 | } else { |
1180 | - $source .= ' ' . str_replace("\n", "\n ", $methodWrap['docstring']); |
|
1181 | - $source .= str_replace("\n", "\n ", $methodWrap['source']). "\n"; |
|
1180 | + $source .= ' '.str_replace("\n", "\n ", $methodWrap['docstring']); |
|
1181 | + $source .= str_replace("\n", "\n ", $methodWrap['source'])."\n"; |
|
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | } else { |
1185 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName); |
|
1185 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName); |
|
1186 | 1186 | } |
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | $source .= "}\n"; |
1190 | 1190 | if ($buildIt) { |
1191 | 1191 | $allOK = 0; |
1192 | - eval($source . '$allOK=1;'); |
|
1192 | + eval($source.'$allOK=1;'); |
|
1193 | 1193 | if ($allOK) { |
1194 | 1194 | return $xmlrpcClassName; |
1195 | 1195 | } else { |
1196 | 1196 | /// @todo direct access to $client->server is now deprecated |
1197 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . |
|
1198 | - ' to wrap remote server ' . $client->server); |
|
1197 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName. |
|
1198 | + ' to wrap remote server '.$client->server); |
|
1199 | 1199 | return false; |
1200 | 1200 | } |
1201 | 1201 | } else { |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | */ |
1215 | 1215 | protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\') |
1216 | 1216 | { |
1217 | - $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()) . |
|
1217 | + $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()). |
|
1218 | 1218 | "');\n"; |
1219 | 1219 | |
1220 | 1220 | // copy all client fields to the client that will be generated runtime |