Passed
Pull Request — master (#109)
by
unknown
12:15
created
lib/xmlrpc_wrappers.inc 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
  * @param array $extraOptions
42 42
  * @return array|false
43 43
  */
44
-function wrap_php_function($funcName, $newFuncName='', $extraOptions=array())
44
+function wrap_php_function($funcName, $newFuncName = '', $extraOptions = array())
45 45
 {
46 46
     $wrapper = new PhpXmlRpc\Wrapper();
47
-    if (!isset($extraOptions['return_source'])  || $extraOptions['return_source'] == false) {
47
+    if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) {
48 48
         // backwards compat: return string instead of callable
49 49
         $extraOptions['return_source'] = true;
50 50
         $wrapped = $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions);
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
  * @param array $extraOptions
65 65
  * @return array|false
66 66
  */
67
-function wrap_php_class($className, $extraOptions=array())
67
+function wrap_php_class($className, $extraOptions = array())
68 68
 {
69 69
     $wrapper = new PhpXmlRpc\Wrapper();
70 70
     $fix = false;
71
-    if (!isset($extraOptions['return_source'])  || $extraOptions['return_source'] == false) {
71
+    if (!isset($extraOptions['return_source']) || $extraOptions['return_source'] == false) {
72 72
         // backwards compat: return string instead of callable
73 73
         $extraOptions['return_source'] = true;
74 74
         $fix = true;
75 75
     }
76 76
     $wrapped = $wrapper->wrapPhpClass($className, $extraOptions);
77
-    foreach($wrapped as $name => $value) {
77
+    foreach ($wrapped as $name => $value) {
78 78
         if ($fix) {
79 79
             eval($value['source']);
80 80
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
  * @param string $newFuncName     deprecated, use an option in $extraOptions
94 94
  * @return array|callable|false
95 95
  */
96
-function wrap_xmlrpc_method($client, $methodName, $extraOptions=0, $timeout=0, $protocol='', $newFuncName='')
96
+function wrap_xmlrpc_method($client, $methodName, $extraOptions = 0, $timeout = 0, $protocol = '', $newFuncName = '')
97 97
 {
98 98
     if (!is_array($extraOptions))
99 99
     {
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
  * @param array $extraOptions
129 129
  * @return mixed
130 130
  */
131
-function wrap_xmlrpc_server($client, $extraOptions=array())
131
+function wrap_xmlrpc_server($client, $extraOptions = array())
132 132
 {
133 133
     $wrapper = new PhpXmlRpc\Wrapper();
134 134
     return $wrapper->wrapXmlrpcServer($client, $extraOptions);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      $faultResponse = '', $namespace = '\\PhpXmlRpc\\')
149 149
 {
150 150
     $code = "function $xmlrpcFuncName (";
151
-    if ($clientCopyMode < 2) {
151
+    if ($clientCopyMode<2) {
152 152
         // client copy mode 0 or 1 == partial / full client copy in emitted code
153 153
         $innerCode = build_client_wrapper_code($client, $clientCopyMode, $prefix);
154 154
         $innerCode .= "\$client->setDebug(\$debug);\n";
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
     if ($mDesc != '') {
164 164
         // take care that PHP comment is not terminated unwillingly by method description
165
-        $mDesc = "/**\n* " . str_replace('*/', '* /', $mDesc) . "\n";
165
+        $mDesc = "/**\n* ".str_replace('*/', '* /', $mDesc)."\n";
166 166
     } else {
167 167
         $mDesc = "/**\nFunction $xmlrpcFuncName\n";
168 168
     }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     $innerCode .= "\$encoder = new {$namespace}Encoder();\n";
172 172
     $plist = array();
173 173
     $pCount = count($mSig);
174
-    for ($i = 1; $i < $pCount; $i++) {
174
+    for ($i = 1; $i<$pCount; $i++) {
175 175
         $plist[] = "\$p$i";
176 176
         $pType = $mSig[$i];
177 177
         if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
             }
188 188
         }
189 189
         $innerCode .= "\$req->addparam(\$p$i);\n";
190
-        $mDesc .= '* @param ' . xmlrpc_2_php_type($pType) . " \$p$i\n";
190
+        $mDesc .= '* @param '.xmlrpc_2_php_type($pType)." \$p$i\n";
191 191
     }
192
-    if ($clientCopyMode < 2) {
192
+    if ($clientCopyMode<2) {
193 193
         $plist[] = '$debug=0';
194 194
         $mDesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
195 195
     }
196 196
     $plist = implode(', ', $plist);
197
-    $mDesc .= '* @return ' . xmlrpc_2_php_type($mSig[0]) . " (or an {$namespace}Response obj instance if call fails)\n*/\n";
197
+    $mDesc .= '* @return '.xmlrpc_2_php_type($mSig[0])." (or an {$namespace}Response obj instance if call fails)\n*/\n";
198 198
 
199 199
     $innerCode .= "\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n";
200 200
     if ($decodeFault) {
201 201
         if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) {
202
-            $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')";
202
+            $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')";
203 203
         } else {
204 204
             $respCode = var_export($faultResponse, true);
205 205
         }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $innerCode .= "if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value());";
213 213
     }
214 214
 
215
-    $code = $code . $plist . ") {\n" . $innerCode . "\n}\n";
215
+    $code = $code.$plist.") {\n".$innerCode."\n}\n";
216 216
 
217 217
     return array('source' => $code, 'docstring' => $mDesc);
218 218
 }
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 /**
221 221
  * @deprecated
222 222
  */
223
-function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc')
223
+function build_client_wrapper_code($client, $verbatim_client_copy, $prefix = 'xmlrpc')
224 224
 {
225 225
     $code = "\$client = new {$prefix}_client('".str_replace("'", "\'", $client->path).
226
-        "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n";
226
+        "', '".str_replace("'", "\'", $client->server)."', $client->port);\n";
227 227
 
228 228
     // copy all client fields to the client that will be generated runtime
229 229
     // (this provides for future expansion or subclassing of client obj)
Please login to merge, or discard this patch.
tests/03MessagesTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 /**
6 6
  * Tests involving Requests and Responses, except for the parsing part
Please login to merge, or discard this patch.
tests/06EncoderTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 /**
6 6
  * Tests involving automatic encoding/decoding of php values into xmlrpc values (the Encoder class).
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         /// @todo it seems that old php versions can not automatically transform latin to utf8 upon xml parsing.
76 76
         ///       We should fix that, then re-enable this test
77 77
         if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
78
-            $i = $e->decodeXml('<?xml version="1.0" encoding="ISO-8859-15" ?><value><string>' . $string . '</string></value>');
78
+            $i = $e->decodeXml('<?xml version="1.0" encoding="ISO-8859-15" ?><value><string>'.$string.'</string></value>');
79 79
             $this->assertEquals($string, $i->scalarVal());
80 80
         }
81 81
 
Please login to merge, or discard this patch.
tests/07ClientTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 /**
6 6
  * Tests involving the Client class (and no server).
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $this->client->server .= 'XXX';
36 36
         $dnsinfo = @dns_get_record($this->client->server);
37 37
         if ($dnsinfo) {
38
-            $this->markTestSkipped('Seems like there is a catchall DNS in effect: host ' . $this->client->server . ' found');
38
+            $this->markTestSkipped('Seems like there is a catchall DNS in effect: host '.$this->client->server.' found');
39 39
         } else {
40 40
             $r = $this->client->send($m, 5);
41 41
             // make sure there's no freaking catchall DNS in effect
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
         // now test a successful connection
64 64
         $server = explode(':', $this->args['HTTPSERVER']);
65
-        if (count($server) > 1) {
65
+        if (count($server)>1) {
66 66
             $this->client->port = $server[1];
67 67
         }
68 68
         $this->client->server = $server[0];
Please login to merge, or discard this patch.
tests/02ValueTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 /**
6 6
  * Tests involving the Value class.
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $this->assertequals(1, count($v1));
156 156
         $out = array('me' => array(), 'mytype' => 2, '_php_class' => null);
157 157
 
158
-        foreach($v1 as $key => $val)
158
+        foreach ($v1 as $key => $val)
159 159
         {
160 160
             $this->assertArrayHasKey($key, $out);
161 161
             $expected = $out[$key];
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $this->assertequals(2, count($v2));
171 171
         $out = array(array('key' => 0, 'value'  => 'object'), array('key' => 1, 'value'  => 'object'));
172 172
         $i = 0;
173
-        foreach($v2 as $key => $val)
173
+        foreach ($v2 as $key => $val)
174 174
         {
175 175
             $expected = $out[$i];
176 176
             $this->assertequals($expected['key'], $key);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     {
185 185
         // nb: make sure that  the serialized xml corresponding to this is > 10MB in size
186 186
         $data = array();
187
-        for ($i = 0; $i < 500000; $i++ ) {
187
+        for ($i = 0; $i<500000; $i++) {
188 188
             $data[] = 'hello world';
189 189
         }
190 190
 
Please login to merge, or discard this patch.
tests/04ParsingTest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 /**
6 6
  * Tests involving xml parsing.
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
     public function testI8()
103 103
     {
104
-        if (PHP_INT_SIZE == 4 ) {
104
+        if (PHP_INT_SIZE == 4) {
105 105
             $this->markTestSkipped('Can not test i8 as php is compiled in 32 bit mode');
106 106
             return;
107 107
         }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
     public function testUnicodeInMemberName()
178 178
     {
179
-        $str = "G" . chr(252) . "nter, El" . chr(232) . "ne";
179
+        $str = "G".chr(252)."nter, El".chr(232)."ne";
180 180
         $v = array($str => new xmlrpcval(1));
181 181
         $r = new xmlrpcresp(new xmlrpcval($v, 'struct'));
182 182
         $r = $r->serialize();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         $response = @utf8_encode(
193 193
             '<?xml version="1.0"?>
194 194
 <!-- covers what happens when lib receives UTF8 chars in response text and comments -->
195
-<!-- ' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232; -->
195
+<!-- ' . chr(224).chr(252).chr(232).'&#224;&#252;&#232; -->
196 196
 <methodResponse>
197 197
 <fault>
198 198
 <value>
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 </member>
204 204
 <member>
205 205
 <name>faultString</name>
206
-<value><string>' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232;</string></value>
206
+<value><string>' . chr(224).chr(252).chr(232).'&#224;&#252;&#232;</string></value>
207 207
 </member>
208 208
 </struct>
209 209
 </value>
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $m = $this->newRequest('dummy');
213 213
         $r = $m->parseResponse($response);
214 214
         $v = $r->faultString();
215
-        $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v);
215
+        $this->assertEquals(chr(224).chr(252).chr(232).chr(224).chr(252).chr(232), $v);
216 216
     }
217 217
 
218 218
     public function testBrokenRequests()
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
         $i = \PhpXmlRpc\PhpXmlRpc::$xmlrpc_reject_invalid_values;
420 420
         \PhpXmlRpc\PhpXmlRpc::$xmlrpc_reject_invalid_values = true;
421 421
 
422
-        foreach($values as $value) {
423
-            $f = '<?xml version="1.0"?><methodResponse><params><param><value>' . $value . '</value></param></params></methodResponse> ';
422
+        foreach ($values as $value) {
423
+            $f = '<?xml version="1.0"?><methodResponse><params><param><value>'.$value.'</value></param></params></methodResponse> ';
424 424
             $r = $s->parseResponse($f);
425 425
             $v = $r->faultCode();
426 426
             $this->assertEquals(2, $v, "Testing $value");
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
 
525 525
     public function testUTF8Response()
526 526
     {
527
-        $string = chr(224) . chr(252) . chr(232);
527
+        $string = chr(224).chr(252).chr(232);
528 528
 
529 529
         $s = $this->newRequest('dummy');
530
-        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
531
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
530
+        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
531
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string).'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
532 532
 ';
533 533
         $r = $s->parseResponse($f, false, 'phpvals');
534 534
         $v = $r->value();
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         $this->assertEquals($string, $v);
537 537
 
538 538
         $f = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
539
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
539
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . @utf8_encode($string).'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
540 540
 ';
541 541
         $r = $s->parseResponse($f, false, 'phpvals');
542 542
         $v = $r->value();
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
 
553 553
     public function testLatin1Response()
554 554
     {
555
-        $string = chr(224) . chr(252) . chr(232);
555
+        $string = chr(224).chr(252).chr(232);
556 556
 
557 557
         $s = $this->newRequest('dummy');
558
-        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
559
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
558
+        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
559
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string.'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
560 560
 ';
561 561
         $r = $s->parseResponse($f, false, 'phpvals');
562 562
         $v = $r->value();
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         $this->assertEquals($string, $v);
565 565
 
566 566
         $f = '<?xml version="1.0" encoding="ISO-8859-1"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
567
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
567
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string.'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
568 568
 ';
569 569
         $r = $s->parseResponse($f, false, 'phpvals');
570 570
         $v = $r->value();
Please login to merge, or discard this patch.
tests/ServerAwareTestCase.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage;
6 6
 use PHPUnit\Framework\TestResult;
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function _run($result = NULL)
30 30
     {
31
-        $this->testId = get_class($this) . '__' . $this->getName();
31
+        $this->testId = get_class($this).'__'.$this->getName();
32 32
 
33 33
         if ($result === NULL) {
34 34
             $result = $this->createResult();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         parent::set_up();
60 60
 
61 61
         // assumes HTTPURI to be in the form /tests/index.php?etc...
62
-        $this->baseUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']);
63
-        $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
62
+        $this->baseUrl = 'http://'.$this->args['HTTPSERVER'].preg_replace('|\?.+|', '', $this->args['HTTPURI']);
63
+        $this->coverageScriptUrl = 'http://'.$this->args['HTTPSERVER'].preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
64 64
     }
65 65
 }
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
     public function xml_header($charsetEncoding = '')
58 58
     {
59 59
         if ($charsetEncoding != '') {
60
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n";
60
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n";
61 61
         } else {
62
-            return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
62
+            return "<?xml version=\"1.0\"?".">\n<methodCall>\n";
63 63
         }
64 64
     }
65 65
 
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
     public function createPayload($charsetEncoding = '')
83 83
     {
84 84
         if ($charsetEncoding != '') {
85
-            $this->content_type = 'text/xml; charset=' . $charsetEncoding;
85
+            $this->content_type = 'text/xml; charset='.$charsetEncoding;
86 86
         } else {
87 87
             $this->content_type = 'text/xml';
88 88
         }
89 89
         $this->payload = $this->xml_header($charsetEncoding);
90
-        $this->payload .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities(
91
-            $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n";
90
+        $this->payload .= '<methodName>'.$this->getCharsetEncoder()->encodeEntities(
91
+            $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n";
92 92
         $this->payload .= "<params>\n";
93 93
         foreach ($this->params as $p) {
94
-            $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) .
94
+            $this->payload .= "<param>\n".$p->serialize($charsetEncoding).
95 95
                 "</param>\n";
96 96
         }
97 97
         $this->payload .= "</params>\n";
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
             return true;
143 143
         } else {
144
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in must be a PhpXmlRpc\Value');
144
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': value passed in must be a PhpXmlRpc\Value');
145 145
             return false;
146 146
         }
147 147
     }
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS)
215 215
     {
216
-        if ($this->debug > 0) {
216
+        if ($this->debug>0) {
217 217
             $this->getLogger()->debug("---GOT---\n$data\n---END---");
218 218
         }
219 219
 
220 220
         $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array());
221 221
 
222 222
         if ($data == '') {
223
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': no response received from server.');
223
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': no response received from server.');
224 224
             return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']);
225 225
         }
226 226
 
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
         if (substr($data, 0, 4) == 'HTTP') {
229 229
             $httpParser = new Http();
230 230
             try {
231
-                $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug > 0);
231
+                $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug>0);
232 232
             } catch (HttpException $e) {
233 233
                 // failed processing of HTTP response headers
234 234
                 // save into response obj the full payload received, for debugging
235 235
                 return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code', $e->statusCode()));
236
-            } catch(\Exception $e) {
236
+            } catch (\Exception $e) {
237 237
                 return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data));
238 238
             }
239 239
         } else {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib
250 250
         $pos = strrpos($data, '</methodResponse>');
251 251
         if ($pos !== false) {
252
-            $data = substr($data, 0, $pos + 17);
252
+            $data = substr($data, 0, $pos+17);
253 253
         }
254 254
 
255 255
         // try to 'guestimate' the character encoding of the received response
@@ -258,21 +258,21 @@  discard block
 block discarded – undo
258 258
             $data
259 259
         );
260 260
 
261
-        if ($this->debug >= 0) {
261
+        if ($this->debug>=0) {
262 262
             $this->httpResponse = $httpResponse;
263 263
         } else {
264 264
             $httpResponse = null;
265 265
         }
266 266
 
267
-        if ($this->debug > 0) {
267
+        if ($this->debug>0) {
268 268
             $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
269 269
             if ($start) {
270 270
                 $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
271 271
                 /// @todo what if there is no end tag?
272 272
                 $end = strpos($data, '-->', $start);
273
-                $comments = substr($data, $start, $end - $start);
274
-                $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t" .
275
-                    str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", array('encoding' => $respEncoding));
273
+                $comments = substr($data, $start, $end-$start);
274
+                $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t".
275
+                    str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", array('encoding' => $respEncoding));
276 276
             }
277 277
         }
278 278
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                 if (function_exists('mb_convert_encoding')) {
292 292
                     $data = mb_convert_encoding($data, 'UTF-8', $respEncoding);
293 293
                 } else {
294
-                    $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding);
294
+                    $this->getLogger()->error('XML-RPC: '.__METHOD__.': unsupported charset encoding of received response: '.$respEncoding);
295 295
                 }
296 296
             }
297 297
         }
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
             //    there could be proxies meddling with the request, or network data corruption...
317 317
 
318 318
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_xml'],
319
-                PhpXmlRpc::$xmlrpcstr['invalid_xml'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse);
319
+                PhpXmlRpc::$xmlrpcstr['invalid_xml'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse);
320 320
 
321
-            if ($this->debug > 0) {
321
+            if ($this->debug>0) {
322 322
                 $this->getLogger()->debug($xmlRpcParser->_xh['isf_reason']);
323 323
             }
324 324
         }
325 325
         // second error check: xml well-formed but not xml-rpc compliant
326 326
         elseif ($xmlRpcParser->_xh['isf'] == 2) {
327 327
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_not_compliant'],
328
-                PhpXmlRpc::$xmlrpcstr['xml_not_compliant'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse);
328
+                PhpXmlRpc::$xmlrpcstr['xml_not_compliant'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse);
329 329
 
330 330
             /// @todo echo something for the user? check if it was already done by the parser...
331 331
             //if ($this->debug > 0) {
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         }
335 335
         // third error check: parsing of the response has somehow gone boink.
336 336
         /// @todo shall we omit this check, since we trust the parsing code?
337
-        elseif ($xmlRpcParser->_xh['isf'] > 3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) {
337
+        elseif ($xmlRpcParser->_xh['isf']>3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) {
338 338
             // something odd has happened and it's time to generate a client side error indicating something odd went on
339 339
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_parsing_error'], PhpXmlRpc::$xmlrpcstr['xml_parsing_error'],
340 340
                 '', $httpResponse
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
             /// @todo echo something for the user?
344 344
         } else {
345
-            if ($this->debug > 1) {
345
+            if ($this->debug>1) {
346 346
                 $this->getLogger()->debug(
347 347
                     "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---"
348 348
                 );
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                 if ($errNo == 0) {
367 367
                     // FAULT returned, errno needs to reflect that
368 368
                     /// @todo feature creep - add this code to PhpXmlRpc::$xmlrpcerr
369
-                    $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': fault response received with faultCode 0 or null. Converted it to -1');
369
+                    $this->getLogger()->error('XML-RPC: '.__METHOD__.': fault response received with faultCode 0 or null. Converted it to -1');
370 370
                     $errNo = -1;
371 371
                 }
372 372
 
Please login to merge, or discard this patch.
demo/client/parallel.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once __DIR__ . "/_prepend.php";
2
+require_once __DIR__."/_prepend.php";
3 3
 
4 4
 use PhpXmlRpc\Encoder;
5 5
 use PhpXmlRpc\Client;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $handles = array();
27 27
         $curl = curl_multi_init();
28 28
 
29
-        foreach($requests as $k => $req) {
29
+        foreach ($requests as $k => $req) {
30 30
             $req->setDebug($this->debug);
31 31
 
32 32
             $handle = $this->prepareCurlHandle(
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
         $running = 0;
60 60
         do {
61 61
             curl_multi_exec($curl, $running);
62
-        } while($running > 0);
62
+        } while ($running>0);
63 63
 
64 64
         $responses = array();
65
-        foreach($handles as $k => $h) {
65
+        foreach ($handles as $k => $h) {
66 66
             $responses[$k] = curl_multi_getcontent($handles[$k]);
67 67
 
68
-            if ($this->debug > 1) {
68
+            if ($this->debug>1) {
69 69
                 $message = "---CURL INFO---\n";
70 70
                 foreach (curl_getinfo($h) as $name => $val) {
71 71
                     if (is_array($val)) {
72 72
                         $val = implode("\n", $val);
73 73
                     }
74
-                    $message .= $name . ': ' . $val . "\n";
74
+                    $message .= $name.': '.$val."\n";
75 75
                 }
76 76
                 $message .= '---END---';
77 77
                 $this->getLogger()->debugMessage($message);
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
         }
83 83
         curl_multi_close($curl);
84 84
 
85
-        foreach($responses as $k => $resp) {
85
+        foreach ($responses as $k => $resp) {
86 86
             if (!$resp) {
87
-                $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl));
87
+                $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl));
88 88
             } else {
89 89
                 $responses[$k] = $requests[$k]->parseResponse($resp, true, $this->return_type);
90 90
             }
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 $value = $encoder->encode($data, array('auto_dates'));
102 102
 $req = new Request('interopEchoTests.echoValue', array($value));
103 103
 $reqs = array();
104
-for ($i = 0; $i < $num_tests; $i++) {
104
+for ($i = 0; $i<$num_tests; $i++) {
105 105
     $reqs[] = $req;
106 106
 }
107 107
 
108 108
 $client = new ParallelClient(XMLRPCSERVER);
109
-$client->setOption(Client::OPT_NO_MULTICALL,  true);
109
+$client->setOption(Client::OPT_NO_MULTICALL, true);
110 110
 
111 111
 // a minimal benchmark - use 3 strategies to execute the same 25 calls: sequentially, using parallel http requests, and
112 112
 // using a single system.multiCall request
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 
117 117
 $t = microtime(true);
118 118
 $resp = $client->send($reqs);
119
-$t = microtime(true) - $t;
120
-echo "Sequential send: " . sprintf('%.3f', $t) . " secs.\n";
119
+$t = microtime(true)-$t;
120
+echo "Sequential send: ".sprintf('%.3f', $t)." secs.\n";
121 121
 flush();
122 122
 
123 123
 $t = microtime(true);
124 124
 $resp = $client->sendParallel($reqs);
125
-$t = microtime(true) - $t;
126
-echo "Parallel send: " . sprintf('%.3f', $t) . " secs.\n";
125
+$t = microtime(true)-$t;
126
+echo "Parallel send: ".sprintf('%.3f', $t)." secs.\n";
127 127
 flush();
128 128
 
129 129
 $client->setOption(Client::OPT_NO_MULTICALL, false);
130 130
 $t = microtime(true);
131 131
 $resp = $client->send($reqs);
132
-$t = microtime(true) - $t;
133
-echo "Multicall send: " . sprintf('%.3f', $t) . " secs.\n";
132
+$t = microtime(true)-$t;
133
+echo "Multicall send: ".sprintf('%.3f', $t)." secs.\n";
Please login to merge, or discard this patch.