Completed
Pull Request — master (#329)
by De Cramer
03:46
created
src_experimantal/eXpansionExperimantal/Bundle/Dedimania/Classes/Request.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -7,11 +7,17 @@  discard block
 block discarded – undo
7 7
 
8 8
     private $requests = array();
9 9
 
10
+    /**
11
+     * @param string $method
12
+     */
10 13
     public function __construct($method, $args)
11 14
     {
12 15
         $this->requests[] = $this->generate($method, $args);
13 16
     }
14 17
 
18
+    /**
19
+     * @param string $method
20
+     */
15 21
     public function add($method, $args)
16 22
     {
17 23
         $this->requests[] = $this->generate($method, $args);
@@ -63,6 +69,9 @@  discard block
 block discarded – undo
63 69
 {
64 70
     private $data;
65 71
 
72
+    /**
73
+     * @param string|false $data
74
+     */
66 75
     public function __construct($data)
67 76
     {
68 77
         $this->data = $data;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function getXml()
72 72
     {
73
-        return '<base64>' . base64_encode($this->data) . '</base64>';
73
+        return '<base64>'.base64_encode($this->data).'</base64>';
74 74
     }
75 75
 }
76 76
 
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
         // Return XML for this value
147 147
         switch ($this->type) {
148 148
             case 'boolean':
149
-                return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
149
+                return '<boolean>'.($this->data ? '1' : '0').'</boolean>';
150 150
                 break;
151 151
             case 'int':
152
-                return '<int>' . $this->data . '</int>';
152
+                return '<int>'.$this->data.'</int>';
153 153
                 break;
154 154
             case 'double':
155
-                return '<double>' . $this->data . '</double>';
155
+                return '<double>'.$this->data.'</double>';
156 156
                 break;
157 157
             case 'string':
158
-                return '<string>' . htmlspecialchars($this->data) . '</string>';
158
+                return '<string>'.htmlspecialchars($this->data).'</string>';
159 159
                 break;
160 160
             case 'array':
161 161
                 $xml = '';
162 162
                 foreach ($this->data as $item) {
163
-                    $xml .= '<value>' . $item->getXml() . '</value>';
163
+                    $xml .= '<value>'.$item->getXml().'</value>';
164 164
                 }
165 165
 
166
-                return '<array><data>' . $xml . '</data></array>';
166
+                return '<array><data>'.$xml.'</data></array>';
167 167
                 break;
168 168
             case 'struct':
169 169
                 $xml = '';
170 170
                 foreach ($this->data as $name => $value) {
171
-                    $xml .= '<member><name>' . $name . '</name><value>' . $value->getXml() . '</value></member>';
171
+                    $xml .= '<member><name>'.$name.'</name><value>'.$value->getXml().'</value></member>';
172 172
                 }
173 173
 
174
-                return '<struct>' . $xml . '</struct>';
174
+                return '<struct>'.$xml.'</struct>';
175 175
                 break;
176 176
             case 'date':
177 177
             case 'base64':
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     {
187 187
         $expected = 0;
188 188
         foreach ($array as $key => $value) {
189
-            if ((string)$key != (string)$expected) {
189
+            if ((string) $key != (string) $expected) {
190 190
                 return true;
191 191
             }
192 192
             $expected++;
Please login to merge, or discard this patch.
eXpansionExperimantal/Bundle/Dedimania/Classes/Webaccess.php 3 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -131,6 +131,11 @@  discard block
 block discarded – undo
131 131
         $this->console = $console;
132 132
     }
133 133
 
134
+    /**
135
+     * @param string $url
136
+     * @param callable[] $callback
137
+     * @param string $datas
138
+     */
134 139
     public function request(
135 140
         $url,
136 141
         $callback,
@@ -204,6 +209,9 @@  discard block
 block discarded – undo
204 209
         }
205 210
     }  // retry
206 211
 
212
+    /**
213
+     * @param integer $tv_sec
214
+     */
207 215
     public function select(&$read, &$write, &$except, $tv_sec, $tv_usec = 0)
208 216
     {
209 217
         $timeout = (int)($tv_sec * 1000000 + $tv_usec);
@@ -421,6 +429,9 @@  discard block
 block discarded – undo
421 429
     // Methods
422 430
     //-----------------------------
423 431
 
432
+    /**
433
+     * @param Webaccess $wa
434
+     */
424 435
     public function __construct(
425 436
         &$wa,
426 437
         $host,
@@ -1058,6 +1069,9 @@  discard block
 block discarded – undo
1058 1069
         }
1059 1070
     }  // _receive
1060 1071
 
1072
+    /**
1073
+     * @param string $error
1074
+     */
1061 1075
     private function _callCallback($error = null)
1062 1076
     {
1063 1077
         if ($error !== null) {
@@ -1406,6 +1420,9 @@  discard block
 block discarded – undo
1406 1420
     return array(false, false, false);
1407 1421
 }
1408 1422
 
1423
+/**
1424
+ * @param string $input
1425
+ */
1409 1426
 function urlsafe_base64_encode($input)
1410 1427
 {
1411 1428
     return strtr(\base64_encode($input), '+/=', '-_,');
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 global $_web_access_compress_xmlrpc_request, $_web_access_compress_reply,
64
-       $_web_access_keepalive, $_web_access_keepalive_timeout,
65
-       $_web_access_keepalive_max, $_web_access_retry_timeout,
66
-       $_web_access_retry_timeout_max, $_web_access_post_xmlrpc;
64
+        $_web_access_keepalive, $_web_access_keepalive_timeout,
65
+        $_web_access_keepalive_max, $_web_access_retry_timeout,
66
+        $_web_access_retry_timeout_max, $_web_access_post_xmlrpc;
67 67
 
68 68
 
69 69
 // Will compress xmlrpc request ('never','accept','force','force-gzip','force-deflate')
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
             }
1154 1154
         } else {
1155 1155
             $headers = &$this->_spool[0]['Headers'];
1156
-          //  echo "Previous Headers! (".strlen($datas[0]).")\n"; // for debugging purposes, don't remove
1156
+            //  echo "Previous Headers! (".strlen($datas[0]).")\n"; // for debugging purposes, don't remove
1157 1157
         }
1158 1158
 
1159 1159
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
     public function select(&$read, &$write, &$except, $tv_sec, $tv_usec = 0)
208 208
     {
209
-        $timeout = (int)($tv_sec * 1000000 + $tv_usec);
209
+        $timeout = (int) ($tv_sec * 1000000 + $tv_usec);
210 210
 
211 211
         if ($read == null) {
212 212
             $read = array();
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
             return 0;
233 233
         }
234 234
 
235
-        $utime = (int)(microtime(true) * 1000000);
235
+        $utime = (int) (microtime(true) * 1000000);
236 236
         $nb = @stream_select($read, $write, $except, $tv_sec, $tv_usec);
237 237
         if ($nb === false) {
238 238
             // in case stream_select "forgot" to wait, sleep the remaining asked timeout...
239
-            $dtime = (int)(microtime(true) * 1000000) - $utime;
239
+            $dtime = (int) (microtime(true) * 1000000) - $utime;
240 240
             $timeout -= $dtime;
241 241
             if ($timeout > 1000) {
242 242
                 usleep($timeout);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                 }
804 804
             } // else just do a send on the current
805 805
             elseif (isset($this->_spool[0]['State']) && $this->_spool[0]['State'] == 'OPEN') {
806
-                @stream_set_timeout($this->_socket, 0, 2000);  // timeout 2 ms
806
+                @stream_set_timeout($this->_socket, 0, 2000); // timeout 2 ms
807 807
                 $this->_send($waittimeout);
808 808
             }
809 809
         }
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
         // reply is complete :)
1033 1033
         if ($state === true) {
1034 1034
             $this->_bad_timeout = 0; // reset error timeout
1035
-            $time = microtime(true);  // @todo see if this is needed ?
1035
+            $time = microtime(true); // @todo see if this is needed ?
1036 1036
             $this->_spool[0]['Times']['receive'][1] = $time - $this->_spool[0]['Times']['receive'][0];
1037 1037
             $this->_spool[0]['State'] = 'DONE';
1038 1038
 
Please login to merge, or discard this patch.
eXpansionExperimantal/Bundle/Dedimania/Plugins/Dedimania.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 
623 623
     /**
624 624
      * Sets new Ghost replay for the map
625
-     * @param $login
625
+     * @param string $login
626 626
      */
627 627
     protected function setGReplay($login)
628 628
     {
@@ -711,6 +711,9 @@  discard block
 block discarded – undo
711 711
         }
712 712
     }
713 713
 
714
+    /**
715
+     * @param string $titleId
716
+     */
714 717
     protected function getPackMask($titleId)
715 718
     {
716 719
         foreach ($this->titles as $title => $data) {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 
363 363
         $request = new Request('dedimania.OpenSession', [$params]);
364 364
 
365
-        $this->sendRequest($request, function ($response) {
365
+        $this->sendRequest($request, function($response) {
366 366
             $this->sessionId = $response['SessionId'];
367 367
             $this->getRecords();
368 368
             $this->connectAllPlayers();
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
         $request = new Request('dedimania.GetChallengeRecords', $params);
406 406
 
407
-        $this->sendRequest($request, function ($response) {
407
+        $this->sendRequest($request, function($response) {
408 408
 
409 409
             $this->dedimaniaService->setServerMaxRank($response['ServerMaxRank']);
410 410
             /** @var DedimaniaRecord[] $recs */
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
         ];
449 449
         $request = new Request('dedimania.UpdateServerPlayers', $params);
450 450
 
451
-        $this->sendRequest($request, function ($response) {
451
+        $this->sendRequest($request, function($response) {
452 452
             // do nothing
453 453
         });
454 454
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
         ];
469 469
 
470 470
         $request = new Request('dedimania.PlayerConnect', $params);
471
-        $this->sendRequest($request, function ($response) use ($player) {
471
+        $this->sendRequest($request, function($response) use ($player) {
472 472
             $dediplayer = DedimaniaPlayer::fromArray($response);
473 473
 
474 474
             if ($dediplayer->banned) {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
         ];
498 498
 
499 499
         $request = new Request('dedimania.PlayerConnect', $params);
500
-        $this->sendRequest($request, function ($response) use ($player) {
500
+        $this->sendRequest($request, function($response) use ($player) {
501 501
             $this->dedimaniaService->disconnectPlayer($player->getLogin());
502 502
         });
503 503
     }
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
             return;
529 529
         }
530 530
 
531
-        $this->sendRequest($request, function ($response) {
531
+        $this->sendRequest($request, function($response) {
532 532
 
533 533
             if (array_key_exists("Login", $response)) {
534 534
                 $response = [0 => $response];
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         }
549 549
 
550 550
         $that = $this;
551
-        $this->getScores->get(function ($scores) use ($that) {
551
+        $this->getScores->get(function($scores) use ($that) {
552 552
             if (count($scores['players']) > 0 && isset($scores['players'][0]['login'])) {
553 553
 
554 554
                 $player = new Player();
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 
580 580
                     $request = new Request("dedimania.SetChallengeTimes", $params);
581 581
 
582
-                    $that->sendRequest($request, function ($response) {
582
+                    $that->sendRequest($request, function($response) {
583 583
                         $this->console->writeln('Dedimania: $0f0records saved.');
584 584
                     });
585 585
                 } catch (\Exception $e) {
Please login to merge, or discard this patch.
eXpansionExperimantal/Bundle/Dedimania/Services/DedimaniaService.php 1 patch
Doc Comments   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,6 +86,9 @@  discard block
 block discarded – undo
86 86
         $this->dispatcher->dispatch('expansion.dedimania.records.load', [$records]);
87 87
     }
88 88
 
89
+    /**
90
+     * @param integer $login
91
+     */
89 92
     public function getRecord($login)
90 93
     {
91 94
         if (isset($this->recordsByLogin[$login])) {
@@ -200,7 +203,7 @@  discard block
 block discarded – undo
200 203
 
201 204
 
202 205
     /**
203
-     * @return mixed
206
+     * @return integer
204 207
      */
205 208
     public function getServerMaxRank()
206 209
     {
@@ -241,7 +244,7 @@  discard block
 block discarded – undo
241 244
     }
242 245
 
243 246
     /**
244
-     * @param $login
247
+     * @param string $login
245 248
      */
246 249
     public function disconnectPlayer($login)
247 250
     {
@@ -269,7 +272,7 @@  discard block
 block discarded – undo
269 272
     }
270 273
 
271 274
     /**
272
-     * @return array
275
+     * @return string[]
273 276
      */
274 277
     public function getGReplay()
275 278
     {
@@ -287,7 +290,7 @@  discard block
 block discarded – undo
287 290
     }
288 291
 
289 292
     /**
290
-     * @return string|false
293
+     * @return boolean
291 294
      */
292 295
     public function isDisabled()
293 296
     {
Please login to merge, or discard this patch.