Passed
Push — master ( 5b4cde...5c6492 )
by Gaetano
12:19 queued 02:18
created
demo/client/parallel.php 1 patch
Spacing   +26 added lines, -26 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;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $handles = array();
36 36
         $curl = curl_multi_init();
37 37
 
38
-        foreach($requests as $k => $req) {
38
+        foreach ($requests as $k => $req) {
39 39
             $req->setDebug($this->debug);
40 40
             $handle = $this->createCurlHandle($req, $method, $this->server, $this->port, $this->path, $opts);
41 41
             if (($error = curl_multi_add_handle($curl, $handle)) !== 0) {
@@ -60,27 +60,27 @@  discard block
 block discarded – undo
60 60
                     }
61 61
                 }
62 62
             }
63
-            if ($running > 0) {
63
+            if ($running>0) {
64 64
                 if (curl_multi_select($curl) === -1) {
65 65
                     throw new \Exception("Curl multi error");
66 66
                 }
67 67
             }
68
-        } while ($running > 0);
68
+        } while ($running>0);
69 69
 
70 70
         curl_multi_close($curl);
71 71
 
72 72
         $responses = array();
73 73
         $errors = array();
74
-        foreach($handles as $k => $h) {
74
+        foreach ($handles as $k => $h) {
75 75
             $responses[$k] = curl_multi_getcontent($h);
76 76
 
77
-            if ($this->debug > 1) {
77
+            if ($this->debug>1) {
78 78
                 $message = "---CURL INFO---\n";
79 79
                 foreach (curl_getinfo($h) as $name => $val) {
80 80
                     if (is_array($val)) {
81 81
                         $val = implode("\n", $val);
82 82
                     }
83
-                    $message .= $name . ': ' . $val . "\n";
83
+                    $message .= $name.': '.$val."\n";
84 84
                 }
85 85
                 $message .= '---END---';
86 86
                 $this->getLogger()->debugMessage($message);
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
             }
92 92
         }
93 93
 
94
-        foreach($responses as $k => $resp) {
94
+        foreach ($responses as $k => $resp) {
95 95
             if (!$resp) {
96
-                $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . $errors[$k]);
96
+                $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.$errors[$k]);
97 97
             } else {
98 98
                 $responses[$k] = $requests[$k]->parseResponse($resp, true, $this->return_type);
99 99
             }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 $encoder = new Encoder();
112 112
 $reqs = array();
113
-for ($i = 0; $i < $num_tests; $i++) {
113
+for ($i = 0; $i<$num_tests; $i++) {
114 114
     $data = array($i, 1.0, 'hello world', true, '20051021T23:43:00', -1, 11.0, '~!@#$%^&*()_+|', false, '20051021T23:43:00');
115 115
     $value = $encoder->encode($data, array('auto_dates'));
116 116
     $req = new Request('interopEchoTests.echoValue', array($value));
@@ -122,40 +122,40 @@  discard block
 block discarded – undo
122 122
 // avoid storing http info in the responses, to make the checksums comparable
123 123
 $client->setDebug(-1);
124 124
 
125
-echo "Making $num_tests calls to method interopEchoTests.echoValue on server " . XMLRPCSERVER . " ...\n";
125
+echo "Making $num_tests calls to method interopEchoTests.echoValue on server ".XMLRPCSERVER." ...\n";
126 126
 flush();
127 127
 
128
-$client->setOption(Client::OPT_NO_MULTICALL,  true);
128
+$client->setOption(Client::OPT_NO_MULTICALL, true);
129 129
 $t = microtime(true);
130 130
 $resp = $client->send($reqs);
131
-$t = microtime(true) - $t;
132
-echo "Sequential send: " . sprintf('%.3f', $t) . " secs.\n";
133
-echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
131
+$t = microtime(true)-$t;
132
+echo "Sequential send: ".sprintf('%.3f', $t)." secs.\n";
133
+echo "Response checksum: ".md5(var_export($resp, true))."\n";
134 134
 flush();
135 135
 
136 136
 if (strpos(XMLRPCSERVER, 'http://') === 0) {
137
-    $client->setOption(Client::OPT_USE_CURL,  Client::USE_CURL_ALWAYS);
137
+    $client->setOption(Client::OPT_USE_CURL, Client::USE_CURL_ALWAYS);
138 138
     $t = microtime(true);
139 139
     $resp = $client->send($reqs);
140
-    $t = microtime(true) - $t;
141
-    echo "Sequential send, curl (w. keepalive): " . sprintf('%.3f', $t) . " secs.\n";
142
-    echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
140
+    $t = microtime(true)-$t;
141
+    echo "Sequential send, curl (w. keepalive): ".sprintf('%.3f', $t)." secs.\n";
142
+    echo "Response checksum: ".md5(var_export($resp, true))."\n";
143 143
     flush();
144 144
 }
145 145
 
146 146
 $t = microtime(true);
147 147
 $resp = $client->sendParallel($reqs);
148
-$t = microtime(true) - $t;
149
-echo "Parallel send: " . sprintf('%.3f', $t) . " secs.\n";
150
-echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
148
+$t = microtime(true)-$t;
149
+echo "Parallel send: ".sprintf('%.3f', $t)." secs.\n";
150
+echo "Response checksum: ".md5(var_export($resp, true))."\n";
151 151
 flush();
152 152
 
153 153
 $client->setOption(Client::OPT_NO_MULTICALL, false);
154 154
 // make sure we don't reuse the keepalive handle
155
-$client->setOption(Client::OPT_USE_CURL,  Client::USE_CURL_NEVER);
155
+$client->setOption(Client::OPT_USE_CURL, Client::USE_CURL_NEVER);
156 156
 $t = microtime(true);
157 157
 $resp = $client->send($reqs);
158
-$t = microtime(true) - $t;
159
-echo "Multicall send: " . sprintf('%.3f', $t) . " secs.\n";
160
-echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
158
+$t = microtime(true)-$t;
159
+echo "Multicall send: ".sprintf('%.3f', $t)." secs.\n";
160
+echo "Response checksum: ".md5(var_export($resp, true))."\n";
161 161
 flush();
Please login to merge, or discard this patch.