Passed
Push — master ( 3181bf...b34e4f )
by Gaetano
15:19
created
src/Encoder.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
                                 'scalar' => $val,
48 48
                                 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($val)
49 49
                             );
50
-                            return (object)$xmlrpcVal;
50
+                            return (object) $xmlrpcVal;
51 51
                         case 'base64':
52 52
                             $xmlrpcVal = array(
53 53
                                 'xmlrpc_type' => 'base64',
54 54
                                 'scalar' => $val
55 55
                             );
56
-                            return (object)$xmlrpcVal;
56
+                            return (object) $xmlrpcVal;
57 57
                         default:
58 58
                             return $xmlrpcVal->scalarval();
59 59
                     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
             case 'array':
80 80
                 $arr = array();
81
-                foreach($xmlrpcVal as $value) {
81
+                foreach ($xmlrpcVal as $value) {
82 82
                     $arr[] = $this->decode($value, $options);
83 83
                 }
84 84
                 return $arr;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             case 'msg':
108 108
                 $paramCount = $xmlrpcVal->getNumParams();
109 109
                 $arr = array();
110
-                for ($i = 0; $i < $paramCount; $i++) {
110
+                for ($i = 0; $i<$paramCount; $i++) {
111 111
                     $arr[] = $this->decode($xmlrpcVal->getParam($i), $options);
112 112
                 }
113 113
                 return $arr;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
                 } else {
203 203
                     $arr = array();
204
-                    foreach($phpVal as $k => $v) {
204
+                    foreach ($phpVal as $k => $v) {
205 205
                         $arr[$k] = $this->encode($v, $options);
206 206
                     }
207 207
                     $xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                 break;
224 224
             case 'resource':
225 225
                 if (in_array('extension_api', $options)) {
226
-                    $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt);
226
+                    $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt);
227 227
                 } else {
228 228
                     $xmlrpcVal = new Value();
229 229
                 }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                     if (extension_loaded('mbstring')) {
272 272
                         $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding);
273 273
                     } else {
274
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding);
274
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding);
275 275
                     }
276 276
                 }
277 277
             }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         $xmlRpcParser = new XMLParser($parserOptions);
288 288
         $xmlRpcParser->parse($xmlVal, XMLParser::RETURN_XMLRPCVALS, XMLParser::ACCEPT_REQUEST | XMLParser::ACCEPT_RESPONSE | XMLParser::ACCEPT_VALUE | XMLParser::ACCEPT_FAULT);
289 289
 
290
-        if ($xmlRpcParser->_xh['isf'] > 1) {
290
+        if ($xmlRpcParser->_xh['isf']>1) {
291 291
             // test that $xmlrpc->_xh['value'] is an obj, too???
292 292
 
293 293
             Logger::instance()->errorLog($xmlRpcParser->_xh['isf_reason']);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
             case 'methodcall':
313 313
                 $req = new Request($xmlRpcParser->_xh['method']);
314
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
314
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
315 315
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
316 316
                 }
317 317
                 return $req;
Please login to merge, or discard this patch.
src/Helper/Charset.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
      */
62 62
     protected function buildConversionTable($tableName)
63 63
     {
64
-        switch($tableName) {
64
+        switch ($tableName) {
65 65
             case 'xml_iso88591_Entities':
66 66
                 if (count($this->xml_iso88591_Entities['in'])) {
67 67
                     return;
68 68
                 }
69
-                for ($i = 0; $i < 32; $i++) {
69
+                for ($i = 0; $i<32; $i++) {
70 70
                     $this->xml_iso88591_Entities["in"][] = chr($i);
71 71
                     $this->xml_iso88591_Entities["out"][] = "&#{$i};";
72 72
                 }
73 73
 
74
-                for ($i = 160; $i < 256; $i++) {
74
+                for ($i = 160; $i<256; $i++) {
75 75
                     $this->xml_iso88591_Entities["in"][] = chr($i);
76 76
                     $this->xml_iso88591_Entities["out"][] = "&#{$i};";
77 77
                 }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 $this->buildConversionTable('xml_iso88591_Entities');
98 98
                 break;*/
99 99
             default:
100
-                throw new \Exception('Unsupported table: ' . $tableName);
100
+                throw new \Exception('Unsupported table: '.$tableName);
101 101
         }
102 102
     }
103 103
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding;
128 128
         }
129 129
 
130
-        $conversion = strtoupper($srcEncoding . '_' . $destEncoding);
130
+        $conversion = strtoupper($srcEncoding.'_'.$destEncoding);
131 131
         switch ($conversion) {
132 132
             case 'ISO-8859-1_':
133 133
             case 'ISO-8859-1_US-ASCII':
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
                 // NB: this will choke on invalid UTF-8, going most likely beyond EOF
158 158
                 $escapedData = '';
159 159
                 // be kind to users creating string xmlrpc values out of different php types
160
-                $data = (string)$data;
160
+                $data = (string) $data;
161 161
                 $ns = strlen($data);
162
-                for ($nn = 0; $nn < $ns; $nn++) {
162
+                for ($nn = 0; $nn<$ns; $nn++) {
163 163
                     $ch = $data[$nn];
164 164
                     $ii = ord($ch);
165 165
                     // 7 bits: 0bbbbbbb (127)
166
-                    if ($ii < 128) {
166
+                    if ($ii<128) {
167 167
                         /// @todo shall we replace this with a (supposedly) faster str_replace?
168 168
                         switch ($ii) {
169 169
                             case 34:
@@ -187,33 +187,33 @@  discard block
 block discarded – undo
187 187
                     } // 11 bits: 110bbbbb 10bbbbbb (2047)
188 188
                     elseif ($ii >> 5 == 6) {
189 189
                         $b1 = ($ii & 31);
190
-                        $ii = ord($data[$nn + 1]);
190
+                        $ii = ord($data[$nn+1]);
191 191
                         $b2 = ($ii & 63);
192
-                        $ii = ($b1 * 64) + $b2;
192
+                        $ii = ($b1 * 64)+$b2;
193 193
                         $ent = sprintf('&#%d;', $ii);
194 194
                         $escapedData .= $ent;
195 195
                         $nn += 1;
196 196
                     } // 16 bits: 1110bbbb 10bbbbbb 10bbbbbb
197 197
                     elseif ($ii >> 4 == 14) {
198 198
                         $b1 = ($ii & 15);
199
-                        $ii = ord($data[$nn + 1]);
199
+                        $ii = ord($data[$nn+1]);
200 200
                         $b2 = ($ii & 63);
201
-                        $ii = ord($data[$nn + 2]);
201
+                        $ii = ord($data[$nn+2]);
202 202
                         $b3 = ($ii & 63);
203
-                        $ii = ((($b1 * 64) + $b2) * 64) + $b3;
203
+                        $ii = ((($b1 * 64)+$b2) * 64)+$b3;
204 204
                         $ent = sprintf('&#%d;', $ii);
205 205
                         $escapedData .= $ent;
206 206
                         $nn += 2;
207 207
                     } // 21 bits: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
208 208
                     elseif ($ii >> 3 == 30) {
209 209
                         $b1 = ($ii & 7);
210
-                        $ii = ord($data[$nn + 1]);
210
+                        $ii = ord($data[$nn+1]);
211 211
                         $b2 = ($ii & 63);
212
-                        $ii = ord($data[$nn + 2]);
212
+                        $ii = ord($data[$nn+2]);
213 213
                         $b3 = ($ii & 63);
214
-                        $ii = ord($data[$nn + 3]);
214
+                        $ii = ord($data[$nn+3]);
215 215
                         $b4 = ($ii & 63);
216
-                        $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
216
+                        $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4;
217 217
                         $ent = sprintf('&#%d;', $ii);
218 218
                         $escapedData .= $ent;
219 219
                         $nn += 3;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
             default:
254 254
                 $escapedData = '';
255
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported...");
255
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported...");
256 256
         }
257 257
 
258 258
         return $escapedData;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             case 'iso88591':
307 307
                 return $this->xml_iso88591_Entities;
308 308
             default:
309
-                throw new \Exception('Unsupported charset: ' . $charset);
309
+                throw new \Exception('Unsupported charset: '.$charset);
310 310
         }
311 311
     }
312 312
 }
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
     public function xml_header($charsetEncoding = '')
46 46
     {
47 47
         if ($charsetEncoding != '') {
48
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n";
48
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n";
49 49
         } else {
50
-            return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
50
+            return "<?xml version=\"1.0\"?".">\n<methodCall>\n";
51 51
         }
52 52
     }
53 53
 
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
     public function createPayload($charsetEncoding = '')
68 68
     {
69 69
         if ($charsetEncoding != '') {
70
-            $this->content_type = 'text/xml; charset=' . $charsetEncoding;
70
+            $this->content_type = 'text/xml; charset='.$charsetEncoding;
71 71
         } else {
72 72
             $this->content_type = 'text/xml';
73 73
         }
74 74
         $this->payload = $this->xml_header($charsetEncoding);
75
-        $this->payload .= '<methodName>' . Charset::instance()->encodeEntities(
76
-            $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n";
75
+        $this->payload .= '<methodName>'.Charset::instance()->encodeEntities(
76
+            $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n";
77 77
         $this->payload .= "<params>\n";
78 78
         foreach ($this->params as $p) {
79
-            $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) .
79
+            $this->payload .= "<param>\n".$p->serialize($charsetEncoding).
80 80
                 "</param>\n";
81 81
         }
82 82
         $this->payload .= "</params>\n";
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array());
204 204
 
205 205
         if ($data == '') {
206
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': no response received from server.');
206
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': no response received from server.');
207 207
             return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']);
208 208
         }
209 209
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             $httpParser = new Http();
213 213
             try {
214 214
                 $this->httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug);
215
-            } catch(\Exception $e) {
215
+            } catch (\Exception $e) {
216 216
                 $r = new Response(0, $e->getCode(), $e->getMessage());
217 217
                 // failed processing of HTTP response headers
218 218
                 // save into response obj the full payload received, for debugging
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib
232 232
         $pos = strrpos($data, '</methodResponse>');
233 233
         if ($pos !== false) {
234
-            $data = substr($data, 0, $pos + 17);
234
+            $data = substr($data, 0, $pos+17);
235 235
         }
236 236
 
237 237
         // try to 'guestimate' the character encoding of the received response
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
             if ($start) {
243 243
                 $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
244 244
                 $end = strpos($data, '-->', $start);
245
-                $comments = substr($data, $start, $end - $start);
246
-                Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t" .
247
-                    str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", $respEncoding);
245
+                $comments = substr($data, $start, $end-$start);
246
+                Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t".
247
+                    str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", $respEncoding);
248 248
             }
249 249
         }
250 250
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                     if (extension_loaded('mbstring')) {
273 273
                         $data = mb_convert_encoding($data, 'UTF-8', $respEncoding);
274 274
                     } else {
275
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received response: ' . $respEncoding);
275
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received response: '.$respEncoding);
276 276
                     }
277 277
                 }
278 278
             }
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
         $xmlRpcParser->parse($data, $returnType, XMLParser::ACCEPT_RESPONSE);
293 293
 
294 294
         // first error check: xml not well formed
295
-        if ($xmlRpcParser->_xh['isf'] > 2) {
295
+        if ($xmlRpcParser->_xh['isf']>2) {
296 296
 
297 297
             // BC break: in the past for some cases we used the error message: 'XML error at line 1, check URL'
298 298
 
299 299
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
300
-                PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
300
+                PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']);
301 301
 
302 302
             if ($this->debug) {
303 303
                 print $xmlRpcParser->_xh['isf_reason'];
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         // second error check: xml well formed but not xml-rpc compliant
307 307
         elseif ($xmlRpcParser->_xh['isf'] == 2) {
308 308
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
309
-                PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
309
+                PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']);
310 310
 
311 311
             if ($this->debug) {
312 312
                 /// @todo echo something for user?
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
322 322
                 PhpXmlRpc::$xmlrpcstr['invalid_return']);
323 323
         } else {
324
-            if ($this->debug > 1) {
324
+            if ($this->debug>1) {
325 325
                 Logger::instance()->debugMessage(
326 326
                     "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---"
327 327
                 );
Please login to merge, or discard this patch.
src/Wrapper.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
             $callable = explode('::', $callable);
168 168
         }
169 169
         if (is_array($callable)) {
170
-            if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
171
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong');
170
+            if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
171
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong');
172 172
                 return false;
173 173
             }
174 174
             if (is_string($callable[0])) {
175 175
                 $plainFuncName = implode('::', $callable);
176 176
             } elseif (is_object($callable[0])) {
177
-                $plainFuncName = get_class($callable[0]) . '->' . $callable[1];
177
+                $plainFuncName = get_class($callable[0]).'->'.$callable[1];
178 178
             }
179 179
             $exists = method_exists($callable[0], $callable[1]);
180 180
         } else if ($callable instanceof \Closure) {
181 181
             // we do not support creating code which wraps closures, as php does not allow to serialize them
182 182
             if (!$buildIt) {
183
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code');
183
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code');
184 184
                 return false;
185 185
             }
186 186
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         }
193 193
 
194 194
         if (!$exists) {
195
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName);
195
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName);
196 196
             return false;
197 197
         }
198 198
 
@@ -236,23 +236,23 @@  discard block
 block discarded – undo
236 236
         if (is_array($callable)) {
237 237
             $func = new \ReflectionMethod($callable[0], $callable[1]);
238 238
             if ($func->isPrivate()) {
239
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName);
239
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName);
240 240
                 return false;
241 241
             }
242 242
             if ($func->isProtected()) {
243
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName);
243
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName);
244 244
                 return false;
245 245
             }
246 246
             if ($func->isConstructor()) {
247
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName);
247
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName);
248 248
                 return false;
249 249
             }
250 250
             if ($func->isDestructor()) {
251
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName);
251
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName);
252 252
                 return false;
253 253
             }
254 254
             if ($func->isAbstract()) {
255
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName);
255
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName);
256 256
                 return false;
257 257
             }
258 258
             /// @todo add more checks for static vs. nonstatic?
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         if ($func->isInternal()) {
263 263
             // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs
264 264
             // instead of getparameters to fully reflect internal php functions ?
265
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName);
265
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName);
266 266
             return false;
267 267
         }
268 268
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         $i = 0;
315 315
         foreach ($func->getParameters() as $paramObj) {
316 316
             $params[$i] = array();
317
-            $params[$i]['name'] = '$' . $paramObj->getName();
317
+            $params[$i]['name'] = '$'.$paramObj->getName();
318 318
             $params[$i]['isoptional'] = $paramObj->isOptional();
319 319
             $i++;
320 320
         }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
             // build a signature
380 380
             $sig = array($this->php2XmlrpcType($funcDesc['returns']));
381 381
             $pSig = array($funcDesc['returnsDocs']);
382
-            for ($i = 0; $i < count($pars); $i++) {
382
+            for ($i = 0; $i<count($pars); $i++) {
383 383
                 $name = strtolower($funcDesc['params'][$i]['name']);
384 384
                 if (isset($funcDesc['paramDocs'][$name]['type'])) {
385 385
                     $sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']);
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
                 }
435 435
             }
436 436
             $numPars = $req->getNumParams();
437
-            if ($numPars < $minPars || $numPars > $maxPars) {
437
+            if ($numPars<$minPars || $numPars>$maxPars) {
438 438
                 return new $responseClass(0, 3, 'Incorrect parameters passed to method');
439 439
             }
440 440
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 
448 448
             $result = call_user_func_array($callable, $params);
449 449
 
450
-            if (! is_a($result, $responseClass)) {
450
+            if (!is_a($result, $responseClass)) {
451 451
                 if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) {
452 452
                     $result = new $valueClass($result, $funcDesc['returns']);
453 453
                 } else {
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
         if ($newFuncName == '') {
483 483
             if (is_array($callable)) {
484 484
                 if (is_string($callable[0])) {
485
-                    $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable);
485
+                    $xmlrpcFuncName = "{$prefix}_".implode('_', $callable);
486 486
                 } else {
487
-                    $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1];
487
+                    $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1];
488 488
                 }
489 489
             } else {
490 490
                 if ($callable instanceof \Closure) {
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
     {
521 521
         $namespace = '\\PhpXmlRpc\\';
522 522
 
523
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
524
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
523
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
524
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
525 525
         $catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : '';
526 526
 
527 527
         $i = 0;
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         // build body of new function
557 557
 
558 558
         $innerCode = "\$paramCount = \$req->getNumParams();\n";
559
-        $innerCode .= "if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n";
559
+        $innerCode .= "if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n";
560 560
 
561 561
         $innerCode .= "\$encoder = new {$namespace}Encoder();\n";
562 562
         if ($decodePhpObjects) {
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
         if (is_array($callable) && is_object($callable[0])) {
571 571
             self::$objHolder[$newFuncName] = $callable[0];
572 572
             $innerCode .= "\$obj = PhpXmlRpc\\Wrapper::\$objHolder['$newFuncName'];\n";
573
-            $realFuncName = '$obj->' . $callable[1];
573
+            $realFuncName = '$obj->'.$callable[1];
574 574
         } else {
575 575
             $realFuncName = $plainFuncName;
576 576
         }
577 577
         foreach ($parsVariations as $i => $pars) {
578
-            $innerCode .= "if (\$paramCount == " . count($pars) . ") \$retval = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n";
579
-            if ($i < (count($parsVariations) - 1))
578
+            $innerCode .= "if (\$paramCount == ".count($pars).") \$retval = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n";
579
+            if ($i<(count($parsVariations)-1))
580 580
                 $innerCode .= "else\n";
581 581
         }
582 582
         $innerCode .= "if (is_a(\$retval, '{$namespace}Response')) return \$retval; else\n";
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         // if($func->returnsReference())
594 594
         //     return false;
595 595
 
596
-        $code = "function $newFuncName(\$req) {\n" . $innerCode . "\n}";
596
+        $code = "function $newFuncName(\$req) {\n".$innerCode."\n}";
597 597
 
598 598
         return $code;
599 599
     }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
                         if ($methodWrap) {
631 631
                             if (is_object($className)) {
632 632
                                 $realClassName = get_class($className);
633
-                            }else {
633
+                            } else {
634 634
                                 $realClassName = $className;
635 635
                             }
636 636
                             $results[$prefix."$realClassName.$mName"] = $methodWrap;
@@ -731,21 +731,21 @@  discard block
 block discarded – undo
731 731
     protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array())
732 732
     {
733 733
         $namespace = '\\PhpXmlRpc\\';
734
-        $reqClass = $namespace . 'Request';
735
-        $valClass = $namespace . 'Value';
736
-        $decoderClass = $namespace . 'Encoder';
734
+        $reqClass = $namespace.'Request';
735
+        $valClass = $namespace.'Value';
736
+        $decoderClass = $namespace.'Encoder';
737 737
 
738 738
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
739
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
739
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
740 740
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
741
-        $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0;
741
+        $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0;
742 742
 
743 743
         $req = new $reqClass('system.methodSignature');
744 744
         $req->addparam(new $valClass($methodName));
745 745
         $client->setDebug($debug);
746 746
         $response = $client->send($req, $timeout, $protocol);
747 747
         if ($response->faultCode()) {
748
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName);
748
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName);
749 749
             return false;
750 750
         }
751 751
 
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
             $mSig = $decoder->decode($mSig);
756 756
         }
757 757
 
758
-        if (!is_array($mSig) || count($mSig) <= $sigNum) {
759
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName);
758
+        if (!is_array($mSig) || count($mSig)<=$sigNum) {
759
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName);
760 760
             return false;
761 761
         }
762 762
 
@@ -772,11 +772,11 @@  discard block
 block discarded – undo
772 772
     protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array())
773 773
     {
774 774
         $namespace = '\\PhpXmlRpc\\';
775
-        $reqClass = $namespace . 'Request';
776
-        $valClass = $namespace . 'Value';
775
+        $reqClass = $namespace.'Request';
776
+        $valClass = $namespace.'Value';
777 777
 
778 778
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
779
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
779
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
780 780
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
781 781
 
782 782
         $mDesc = '';
@@ -810,10 +810,10 @@  discard block
 block discarded – undo
810 810
         $clientClone = clone $client;
811 811
         $function = function() use($clientClone, $methodName, $extraOptions, $mSig)
812 812
         {
813
-            $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
813
+            $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
814 814
             $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
815
-            $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
816
-            $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
815
+            $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
816
+            $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
817 817
             if (isset($extraOptions['return_on_fault'])) {
818 818
                 $decodeFault = true;
819 819
                 $faultResponse = $extraOptions['return_on_fault'];
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
             }
823 823
 
824 824
             $namespace = '\\PhpXmlRpc\\';
825
-            $reqClass = $namespace . 'Request';
826
-            $encoderClass = $namespace . 'Encoder';
827
-            $valueClass = $namespace . 'Value';
825
+            $reqClass = $namespace.'Request';
826
+            $encoderClass = $namespace.'Encoder';
827
+            $valueClass = $namespace.'Value';
828 828
 
829 829
             $encoder = new $encoderClass();
830 830
             $encodeOptions = array();
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
             }
848 848
 
849 849
             $xmlrpcArgs = array();
850
-            foreach($currentArgs as $i => $arg) {
850
+            foreach ($currentArgs as $i => $arg) {
851 851
                 if ($i == $maxArgs) {
852 852
                     break;
853 853
                 }
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
      * @param string $mDesc
896 896
      * @return string[] keys: source, docstring
897 897
      */
898
-    public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='')
898
+    public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '')
899 899
     {
900
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
900
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
901 901
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
902
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
903
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
904
-        $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0;
902
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
903
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
904
+        $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0;
905 905
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
906 906
         if (isset($extraOptions['return_on_fault'])) {
907 907
             $decodeFault = true;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
         $namespace = '\\PhpXmlRpc\\';
915 915
 
916 916
         $code = "function $newFuncName (";
917
-        if ($clientCopyMode < 2) {
917
+        if ($clientCopyMode<2) {
918 918
             // client copy mode 0 or 1 == full / partial client copy in emitted code
919 919
             $verbatimClientCopy = !$clientCopyMode;
920 920
             $innerCode = $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, $namespace);
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 
930 930
         if ($mDesc != '') {
931 931
             // take care that PHP comment is not terminated unwillingly by method description
932
-            $mDesc = "/**\n* " . str_replace('*/', '* /', $mDesc) . "\n";
932
+            $mDesc = "/**\n* ".str_replace('*/', '* /', $mDesc)."\n";
933 933
         } else {
934 934
             $mDesc = "/**\nFunction $newFuncName\n";
935 935
         }
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
         $innerCode .= "\$encoder = new {$namespace}Encoder();\n";
939 939
         $plist = array();
940 940
         $pCount = count($mSig);
941
-        for ($i = 1; $i < $pCount; $i++) {
941
+        for ($i = 1; $i<$pCount; $i++) {
942 942
             $plist[] = "\$p$i";
943 943
             $pType = $mSig[$i];
944 944
             if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
@@ -954,19 +954,19 @@  discard block
 block discarded – undo
954 954
                 }
955 955
             }
956 956
             $innerCode .= "\$req->addparam(\$p$i);\n";
957
-            $mDesc .= '* @param ' . $this->xmlrpc2PhpType($pType) . " \$p$i\n";
957
+            $mDesc .= '* @param '.$this->xmlrpc2PhpType($pType)." \$p$i\n";
958 958
         }
959
-        if ($clientCopyMode < 2) {
959
+        if ($clientCopyMode<2) {
960 960
             $plist[] = '$debug=0';
961 961
             $mDesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
962 962
         }
963 963
         $plist = implode(', ', $plist);
964
-        $mDesc .= '* @return {$namespace}Response|' . $this->xmlrpc2PhpType($mSig[0]) . " (an {$namespace}Response obj instance if call fails)\n*/\n";
964
+        $mDesc .= '* @return {$namespace}Response|'.$this->xmlrpc2PhpType($mSig[0])." (an {$namespace}Response obj instance if call fails)\n*/\n";
965 965
 
966 966
         $innerCode .= "\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n";
967 967
         if ($decodeFault) {
968 968
             if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) {
969
-                $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')";
969
+                $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')";
970 970
             } else {
971 971
                 $respCode = var_export($faultResponse, true);
972 972
             }
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
             $innerCode .= "if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value());";
980 980
         }
981 981
 
982
-        $code = $code . $plist . ") {\n" . $innerCode . "\n}\n";
982
+        $code = $code.$plist.") {\n".$innerCode."\n}\n";
983 983
 
984 984
         return array('source' => $code, 'docstring' => $mDesc);
985 985
     }
@@ -1005,23 +1005,23 @@  discard block
 block discarded – undo
1005 1005
     public function wrapXmlrpcServer($client, $extraOptions = array())
1006 1006
     {
1007 1007
         $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : '';
1008
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
1008
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
1009 1009
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
1010 1010
         $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : '';
1011
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
1012
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
1011
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
1012
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
1013 1013
         $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true;
1014 1014
         $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true;
1015 1015
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
1016 1016
         $namespace = '\\PhpXmlRpc\\';
1017 1017
 
1018
-        $reqClass = $namespace . 'Request';
1019
-        $decoderClass = $namespace . 'Encoder';
1018
+        $reqClass = $namespace.'Request';
1019
+        $decoderClass = $namespace.'Encoder';
1020 1020
 
1021 1021
         $req = new $reqClass('system.listMethods');
1022 1022
         $response = $client->send($req, $timeout, $protocol);
1023 1023
         if ($response->faultCode()) {
1024
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
1024
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server');
1025 1025
 
1026 1026
             return false;
1027 1027
         } else {
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
                 $mList = $decoder->decode($mList);
1032 1032
             }
1033 1033
             if (!is_array($mList) || !count($mList)) {
1034
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');
1034
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server');
1035 1035
 
1036 1036
                 return false;
1037 1037
             } else {
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
                 if ($newClassName != '') {
1040 1040
                     $xmlrpcClassName = $newClassName;
1041 1041
                 } else {
1042
-                    $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
1043
-                            array('_', ''), $client->server) . '_client';
1042
+                    $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
1043
+                            array('_', ''), $client->server).'_client';
1044 1044
                 }
1045 1045
                 while ($buildIt && class_exists($xmlrpcClassName)) {
1046 1046
                     $xmlrpcClassName .= 'x';
@@ -1071,20 +1071,20 @@  discard block
 block discarded – undo
1071 1071
                             if (!$buildIt) {
1072 1072
                                 $source .= $methodWrap['docstring'];
1073 1073
                             }
1074
-                            $source .= $methodWrap['source'] . "\n";
1074
+                            $source .= $methodWrap['source']."\n";
1075 1075
                         } else {
1076
-                            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName);
1076
+                            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName);
1077 1077
                         }
1078 1078
                     }
1079 1079
                 }
1080 1080
                 $source .= "}\n";
1081 1081
                 if ($buildIt) {
1082 1082
                     $allOK = 0;
1083
-                    eval($source . '$allOK=1;');
1083
+                    eval($source.'$allOK=1;');
1084 1084
                     if ($allOK) {
1085 1085
                         return $xmlrpcClassName;
1086 1086
                     } else {
1087
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server);
1087
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName.' to wrap remote server '.$client->server);
1088 1088
                         return false;
1089 1089
                     }
1090 1090
                 } else {
@@ -1105,10 +1105,10 @@  discard block
 block discarded – undo
1105 1105
      *
1106 1106
      * @return string
1107 1107
      */
1108
-    protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\' )
1108
+    protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\')
1109 1109
     {
1110
-        $code = "\$client = new {$namespace}Client('" . str_replace("'", "\'", $client->path) .
1111
-            "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n";
1110
+        $code = "\$client = new {$namespace}Client('".str_replace("'", "\'", $client->path).
1111
+            "', '".str_replace("'", "\'", $client->server)."', $client->port);\n";
1112 1112
 
1113 1113
         // copy all client fields to the client that will be generated runtime
1114 1114
         // (this provides for future expansion or subclassing of client obj)
Please login to merge, or discard this patch.
src/Server.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public static function xmlrpc_debugmsg($msg)
162 162
     {
163
-        static::$_xmlrpc_debuginfo .= $msg . "\n";
163
+        static::$_xmlrpc_debuginfo .= $msg."\n";
164 164
     }
165 165
 
166 166
     /**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public static function error_occurred($msg)
174 174
     {
175
-        static::$_xmlrpcs_occurred_errors .= $msg . "\n";
175
+        static::$_xmlrpcs_occurred_errors .= $msg."\n";
176 176
     }
177 177
 
178 178
     /**
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
         // user debug info should be encoded by the end user using the INTERNAL_ENCODING
192 192
         $out = '';
193 193
         if ($this->debug_info != '') {
194
-            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n";
194
+            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
195 195
         }
196 196
         if (static::$_xmlrpc_debuginfo != '') {
197
-            $out .= "<!-- DEBUG INFO:\n" . Charset::instance()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n";
197
+            $out .= "<!-- DEBUG INFO:\n".Charset::instance()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n";
198 198
             // NB: a better solution MIGHT be to use CDATA, but we need to insert it
199 199
             // into return payload AFTER the beginning tag
200 200
             //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n";
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
         $this->debug_info = '';
225 225
 
226 226
         // Save what we received, before parsing it
227
-        if ($this->debug > 1) {
228
-            $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
227
+        if ($this->debug>1) {
228
+            $this->debugmsg("+++GOT+++\n".$data."\n+++END+++");
229 229
         }
230 230
 
231 231
         $r = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding);
@@ -237,21 +237,21 @@  discard block
 block discarded – undo
237 237
         // save full body of request into response, for more debugging usages
238 238
         $r->raw_data = $rawData;
239 239
 
240
-        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors) {
241
-            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
242
-                static::$_xmlrpcs_occurred_errors . "+++END+++");
240
+        if ($this->debug>2 && static::$_xmlrpcs_occurred_errors) {
241
+            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n".
242
+                static::$_xmlrpcs_occurred_errors."+++END+++");
243 243
         }
244 244
 
245 245
         $payload = $this->xml_header($respCharset);
246
-        if ($this->debug > 0) {
247
-            $payload = $payload . $this->serializeDebug($respCharset);
246
+        if ($this->debug>0) {
247
+            $payload = $payload.$this->serializeDebug($respCharset);
248 248
         }
249 249
 
250 250
         // Do not create response serialization if it has already happened. Helps building json magic
251 251
         if (empty($r->payload)) {
252 252
             $r->serialize($respCharset);
253 253
         }
254
-        $payload = $payload . $r->payload;
254
+        $payload = $payload.$r->payload;
255 255
 
256 256
         if ($returnPayload) {
257 257
             return $payload;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         // if we get a warning/error that has output some text before here, then we cannot
261 261
         // add a new header. We cannot say we are sending xml, either...
262 262
         if (!headers_sent()) {
263
-            header('Content-Type: ' . $r->content_type);
263
+            header('Content-Type: '.$r->content_type);
264 264
             // we do not know if client actually told us an accepted charset, but if he did
265 265
             // we have to tell him what we did
266 266
             header("Vary: Accept-Charset");
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
             // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for
290 290
             // responses up to 8000 bytes
291 291
             if ($phpNoSelfCompress) {
292
-                header('Content-Length: ' . (int)strlen($payload));
292
+                header('Content-Length: '.(int) strlen($payload));
293 293
             }
294 294
         } else {
295
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
295
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
296 296
         }
297 297
 
298 298
         print $payload;
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
             $numParams = count($in);
348 348
         }
349 349
         foreach ($sigs as $curSig) {
350
-            if (count($curSig) == $numParams + 1) {
350
+            if (count($curSig) == $numParams+1) {
351 351
                 $itsOK = 1;
352
-                for ($n = 0; $n < $numParams; $n++) {
352
+                for ($n = 0; $n<$numParams; $n++) {
353 353
                     if (is_object($in)) {
354 354
                         $p = $in->getParam($n);
355 355
                         if ($p->kindOf() == 'scalar') {
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
                     }
363 363
 
364 364
                     // param index is $n+1, as first member of sig is return type
365
-                    if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
365
+                    if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) {
366 366
                         $itsOK = 0;
367
-                        $pno = $n + 1;
368
-                        $wanted = $curSig[$n + 1];
367
+                        $pno = $n+1;
368
+                        $wanted = $curSig[$n+1];
369 369
                         $got = $pt;
370 370
                         break;
371 371
                     }
@@ -392,10 +392,10 @@  discard block
 block discarded – undo
392 392
         // check if $_SERVER is populated: it might have been disabled via ini file
393 393
         // (this is true even when in CLI mode)
394 394
         if (count($_SERVER) == 0) {
395
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
395
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated');
396 396
         }
397 397
 
398
-        if ($this->debug > 1) {
398
+        if ($this->debug>1) {
399 399
             if (function_exists('getallheaders')) {
400 400
                 $this->debugmsg(''); // empty line
401 401
                 foreach (getallheaders() as $name => $val) {
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
                 if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) {
418 418
                     if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) {
419 419
                         $data = $degzdata;
420
-                        if ($this->debug > 1) {
421
-                            $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
420
+                        if ($this->debug>1) {
421
+                            $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
422 422
                         }
423 423
                     } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
424 424
                         $data = $degzdata;
425
-                        if ($this->debug > 1) {
426
-                            $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
425
+                        if ($this->debug>1) {
426
+                            $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
427 427
                         }
428 428
                     } else {
429 429
                         $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'], PhpXmlRpc::$xmlrpcstr['server_decompress_fail']);
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
                     if (extension_loaded('mbstring')) {
514 514
                         $data = mb_convert_encoding($data, 'UTF-8', $reqEncoding);
515 515
                     } else {
516
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding);
516
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$reqEncoding);
517 517
                     }
518 518
                 }
519 519
             }
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
 
532 532
         $xmlRpcParser = new XMLParser($options);
533 533
         $xmlRpcParser->parse($data, $this->functions_parameters_type, XMLParser::ACCEPT_REQUEST);
534
-        if ($xmlRpcParser->_xh['isf'] > 2) {
534
+        if ($xmlRpcParser->_xh['isf']>2) {
535 535
             // (BC) we return XML error as a faultCode
536 536
             preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches);
537 537
             $r = new Response(0,
538
-                PhpXmlRpc::$xmlrpcerrxml + $matches[1],
538
+                PhpXmlRpc::$xmlrpcerrxml+$matches[1],
539 539
                 $xmlRpcParser->_xh['isf_reason']);
540 540
         } elseif ($xmlRpcParser->_xh['isf']) {
541 541
             $r = new Response(0,
542 542
                 PhpXmlRpc::$xmlrpcerr['invalid_request'],
543
-                PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
543
+                PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']);
544 544
         } else {
545 545
             // small layering violation in favor of speed and memory usage:
546 546
             // we should allow the 'execute' method handle this, but in the
@@ -551,20 +551,20 @@  discard block
 block discarded – undo
551 551
                     ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] != 'xmlrpcvals')
552 552
                 )
553 553
             ) {
554
-                if ($this->debug > 1) {
555
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++");
554
+                if ($this->debug>1) {
555
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++");
556 556
                 }
557 557
                 $r = $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']);
558 558
             } else {
559 559
                 // build a Request object with data parsed from xml
560 560
                 $req = new Request($xmlRpcParser->_xh['method']);
561 561
                 // now add parameters in
562
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
562
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
563 563
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
564 564
                 }
565 565
 
566
-                if ($this->debug > 1) {
567
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++");
566
+                if ($this->debug>1) {
567
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++");
568 568
                 }
569 569
                 $r = $this->execute($req);
570 570
             }
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
                 return new Response(
618 618
                     0,
619 619
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
620
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": ${errStr}"
620
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": ${errStr}"
621 621
                 );
622 622
             }
623 623
         }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 
631 631
         if (is_array($func)) {
632 632
             if (is_object($func[0])) {
633
-                $funcName = get_class($func[0]) . '->' . $func[1];
633
+                $funcName = get_class($func[0]).'->'.$func[1];
634 634
             } else {
635 635
                 $funcName = implode('::', $func);
636 636
             }
@@ -642,17 +642,17 @@  discard block
 block discarded – undo
642 642
 
643 643
         // verify that function to be invoked is in fact callable
644 644
         if (!is_callable($func)) {
645
-            Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
645
+            Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable");
646 646
             return new Response(
647 647
                 0,
648 648
                 PhpXmlRpc::$xmlrpcerr['server_error'],
649
-                PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method"
649
+                PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method"
650 650
             );
651 651
         }
652 652
 
653 653
         // If debug level is 3, we should catch all errors generated during
654 654
         // processing of user function, and log them as part of response
655
-        if ($this->debug > 2) {
655
+        if ($this->debug>2) {
656 656
             self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
657 657
         }
658 658
 
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
                     $r = call_user_func($func, $req);
666 666
                 }
667 667
                 if (!is_a($r, 'PhpXmlRpc\Response')) {
668
-                    Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
668
+                    Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r));
669 669
                     if (is_a($r, 'PhpXmlRpc\Value')) {
670 670
                         $r = new Response($r);
671 671
                     } else {
672 672
                         $r = new Response(
673 673
                             0,
674 674
                             PhpXmlRpc::$xmlrpcerr['server_error'],
675
-                            PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object"
675
+                            PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object"
676 676
                         );
677 677
                     }
678 678
                 }
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                         // mimic EPI behaviour: if we get an array that looks like an error, make it
689 689
                         // an error response
690 690
                         if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
691
-                            $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']);
691
+                            $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']);
692 692
                         } else {
693 693
                             // functions using EPI api should NOT return resp objects,
694 694
                             // so make sure we encode the return type correctly
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
             // in the called function, we wrap it in a proper error-response
713 713
             switch ($this->exception_handling) {
714 714
                 case 2:
715
-                    if ($this->debug > 2) {
715
+                    if ($this->debug>2) {
716 716
                         if (self::$_xmlrpcs_prev_ehandler) {
717 717
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
718 718
                         } else {
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
                     $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_error'], PhpXmlRpc::$xmlrpcstr['server_error']);
728 728
             }
729 729
         }
730
-        if ($this->debug > 2) {
730
+        if ($this->debug>2) {
731 731
             // note: restore the error handler we found before calling the
732 732
             // user func, even if it has been changed inside the func itself
733 733
             if (self::$_xmlrpcs_prev_ehandler) {
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
      */
748 748
     protected function debugmsg($string)
749 749
     {
750
-        $this->debug_info .= $string . "\n";
750
+        $this->debug_info .= $string."\n";
751 751
     }
752 752
 
753 753
     /**
@@ -757,9 +757,9 @@  discard block
 block discarded – undo
757 757
     protected function xml_header($charsetEncoding = '')
758 758
     {
759 759
         if ($charsetEncoding != '') {
760
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
760
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n";
761 761
         } else {
762
-            return "<?xml version=\"1.0\"?" . ">\n";
762
+            return "<?xml version=\"1.0\"?".">\n";
763 763
         }
764 764
     }
765 765
 
@@ -1003,12 +1003,12 @@  discard block
 block discarded – undo
1003 1003
         }
1004 1004
 
1005 1005
         $req = new Request($methName->scalarval());
1006
-        foreach($params as $i => $param) {
1006
+        foreach ($params as $i => $param) {
1007 1007
             if (!$req->addParam($param)) {
1008 1008
                 $i++; // for error message, we count params from 1
1009 1009
                 return static::_xmlrpcs_multicall_error(new Response(0,
1010 1010
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
1011
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i));
1011
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i));
1012 1012
             }
1013 1013
         }
1014 1014
 
@@ -1080,12 +1080,12 @@  discard block
 block discarded – undo
1080 1080
         // let accept a plain list of php parameters, beside a single xmlrpc msg object
1081 1081
         if (is_object($req)) {
1082 1082
             $calls = $req->getParam(0);
1083
-            foreach($calls as $call) {
1083
+            foreach ($calls as $call) {
1084 1084
                 $result[] = static::_xmlrpcs_multicall_do_call($server, $call);
1085 1085
             }
1086 1086
         } else {
1087 1087
             $numCalls = count($req);
1088
-            for ($i = 0; $i < $numCalls; $i++) {
1088
+            for ($i = 0; $i<$numCalls; $i++) {
1089 1089
                 $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]);
1090 1090
             }
1091 1091
         }
Please login to merge, or discard this patch.
debugger/controller.php 1 patch
Braces   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,12 @@
 block discarded – undo
31 31
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32 32
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
33 33
 <head>
34
-    <title><?php if (defined('DEFAULT_WSTYPE') && DEFAULT_WSTYPE == 1) echo 'JSONRPC'; else echo 'XMLRPC'; ?> Debugger</title>
34
+    <title><?php if (defined('DEFAULT_WSTYPE') && DEFAULT_WSTYPE == 1) {
35
+    echo 'JSONRPC';
36
+} else {
37
+    echo 'XMLRPC';
38
+}
39
+?> Debugger</title>
35 40
     <meta name="robots" content="index,nofollow"/>
36 41
     <script type="text/javascript" language="Javascript">
37 42
         if (window.name != 'frmcontroller')
Please login to merge, or discard this patch.