Completed
Push — master ( cc5276...9a47a0 )
by Kamil
03:04
created
src/MySQL/Protocol/Support/BinarySupport.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -382,6 +382,7 @@
 block discarded – undo
382 382
 
383 383
     /**
384 384
      * @see BinarySupport::int2bytes
385
+     * @param integer $bytes
385 386
      */
386 387
     public static function i2b($bytes, $int = 0, $l = false)
387 388
     {
Please login to merge, or discard this patch.
Braces   +47 added lines, -21 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
         {
21 21
             $r .= chr(strlen($e[$i])) . $e[$i];
22 22
         }
23
-        if (static::binarySubstr($r, -1) !== "\x00") {
23
+        if (static::binarySubstr($r, -1) !== "\x00")
24
+        {
24 25
             $r .= "\x00";
25 26
         }
26 27
         return $r;
@@ -40,7 +41,8 @@  discard block
 block discarded – undo
40 41
         {
41 42
             $l = ord($data[0]);
42 43
 
43
-            if ($l >= 192) {
44
+            if ($l >= 192)
45
+            {
44 46
                 $pos  = static::bytes2int(chr($l - 192) . static::binarySubstr($data, 1, 1));
45 47
                 $data = static::binarySubstr($data, 2);
46 48
                 $ref  = static::binarySubstr($orig, $pos);
@@ -51,7 +53,8 @@  discard block
 block discarded – undo
51 53
             $p = substr($data, 1, $l);
52 54
             $str .= $p . (($l !== 0) ? '.' : '');
53 55
             $data = substr($data, $l + 1);
54
-            if ($l === 0) {
56
+            if ($l === 0)
57
+            {
55 58
                 break;
56 59
             }
57 60
         }
@@ -68,7 +71,8 @@  discard block
 block discarded – undo
68 71
     public static function LV($str, $len = 1, $lrev = false)
69 72
     {
70 73
         $l = static::i2b($len, strlen($str));
71
-        if ($lrev) {
74
+        if ($lrev)
75
+        {
72 76
             $l = strrev($l);
73 77
         }
74 78
         return $l . $str;
@@ -216,7 +220,8 @@  discard block
 block discarded – undo
216 220
     {
217 221
         $r = static::binarySubstr($p, 0, 2);
218 222
         $p = static::binarySubstr($p, 2);
219
-        if ($l) {
223
+        if ($l)
224
+        {
220 225
             $r = strrev($r);
221 226
         }
222 227
         return $r;
@@ -262,7 +267,8 @@  discard block
 block discarded – undo
262 267
     public static function getStrQWord(&$p, $l = false)
263 268
     {
264 269
         $r = static::binarySubstr($p, 0, 8);
265
-        if ($l) {
270
+        if ($l)
271
+        {
266 272
             $r = strrev($r);
267 273
         }
268 274
         $p = static::binarySubstr($p, 8);
@@ -279,7 +285,8 @@  discard block
 block discarded – undo
279 285
     public static function getString(&$str)
280 286
     {
281 287
         $p = strpos($str, "\x00");
282
-        if ($p === false) {
288
+        if ($p === false)
289
+        {
283 290
             return '';
284 291
         }
285 292
         $r   = static::binarySubstr($str, 0, $p);
@@ -302,19 +309,26 @@  discard block
 block discarded – undo
302 309
         $s = static::b2i(static::binarySubstr($p, 0, $l), !!$lrev);
303 310
         $p = static::binarySubstr($p, $l);
304 311
 
305
-        if ($s == 0) {
312
+        if ($s == 0)
313
+        {
306 314
             return '';
307 315
         }
308 316
 
309 317
         $r = '';
310 318
 
311
-        if (strlen($p) < $s) {
319
+        if (strlen($p) < $s)
320
+        {
312 321
             echo("getLV error: buf length (" . strlen($p) . "): " . Debug::exportBytes($p) . ", must be >= string length (" . $s . ")\n");
313 322
 
314
-        } else if ($nul) {
315
-            if ($p{$s - 1} != "\x00") {
323
+        }
324
+        else if ($nul)
325
+        {
326
+            if ($p{$s - 1} != "\x00")
327
+            {
316 328
                 echo("getLV error: Wrong end of NUL-string (" . Debug::exportBytes($p{$s - 1}) . "), len " . $s . "\n");
317
-            } else {
329
+            }
330
+            else
331
+            {
318 332
                 $d = $s - 1;
319 333
                 if ($d < 0)
320 334
                 {
@@ -324,7 +338,9 @@  discard block
 block discarded – undo
324 338
                 $p = static::binarySubstr($p, $s);
325 339
             }
326 340
 
327
-        } else {
341
+        }
342
+        else
343
+        {
328 344
             $r = static::binarySubstr($p, 0, $s);
329 345
             $p = static::binarySubstr($p, $s);
330 346
         }
@@ -344,11 +360,15 @@  discard block
 block discarded – undo
344 360
     {
345 361
         $hexstr = dechex($int);
346 362
 
347
-        if ($len === null) {
348
-            if (strlen($hexstr) % 2) {
363
+        if ($len === null)
364
+        {
365
+            if (strlen($hexstr) % 2)
366
+            {
349 367
                 $hexstr = "0" . $hexstr;
350 368
             }
351
-        } else {
369
+        }
370
+        else
371
+        {
352 372
             $hexstr = str_repeat('0', $len * 2 - strlen($hexstr)) . $hexstr;
353 373
         }
354 374
 
@@ -397,7 +417,8 @@  discard block
 block discarded – undo
397 417
      */
398 418
     public static function bytes2int($str, $l = false)
399 419
     {
400
-        if ($l) {
420
+        if ($l)
421
+        {
401 422
             $str = strrev($str);
402 423
         }
403 424
 
@@ -437,7 +458,8 @@  discard block
 block discarded – undo
437 458
         {
438 459
             $r .= chr((int) bindec(static::binarySubstr($bitmap, $i * 8, 8)));
439 460
         }
440
-        if ($checkLen && (strlen($r) != $checkLen)) {
461
+        if ($checkLen && (strlen($r) != $checkLen))
462
+        {
441 463
             throw new Exception('Warning! Bitmap incorrect.');
442 464
         }
443 465
 
@@ -465,13 +487,17 @@  discard block
 block discarded – undo
465 487
      */
466 488
     protected static function binarySubstr($s, $p, $len = null)
467 489
     {
468
-        if ($len === null) {
490
+        if ($len === null)
491
+        {
469 492
             $ret = substr($s, $p);
470
-        } else {
493
+        }
494
+        else
495
+        {
471 496
             $ret = substr($s, $p, $len);
472 497
         }
473 498
 
474
-        if ($ret === false) {
499
+        if ($ret === false)
500
+        {
475 501
             $ret = '';
476 502
         }
477 503
 
Please login to merge, or discard this patch.
src/MySQL/Query.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,6 @@
 block discarded – undo
44 44
     /**
45 45
      * Binding params for the query, mutiple arguments support.
46 46
      *
47
-     * @param  mixed              $param
48 47
      * @return Query
49 48
      */
50 49
     public function bindParams()
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function bindParams()
51 51
     {
52 52
         $this->sqlPrepared = null;
53
-        $this->params   = func_get_args();
53
+        $this->params = func_get_args();
54 54
 
55 55
         return $this;
56 56
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public function bindParamsFromArray(array $params)
59 59
     {
60 60
         $this->sqlPrepared = null;
61
-        $this->params   = $params;
61
+        $this->params = $params;
62 62
 
63 63
         return $this;
64 64
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,8 @@
 block discarded – undo
89 89
                 break;
90 90
             case 'array':
91 91
                 $nvalue = [];
92
-                foreach ($value as $v) {
92
+                foreach ($value as $v)
93
+                {
93 94
                     $nvalue[] = $this->resolveValueForSql($v);
94 95
                 }
95 96
                 $value = implode(',', $nvalue);
Please login to merge, or discard this patch.
src/MySQL/Command/Concrete/QuitCommand.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
     }
13 13
 
14 14
     public function buildPacket()
15
-    {}
15
+    {
16
+}
16 17
 
17 18
     public function getSql()
18 19
     {
Please login to merge, or discard this patch.
src/MySQL/Command/Concrete/AuthCommand.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,5 +20,6 @@
 block discarded – undo
20 20
      * @inheritDoc
21 21
      */
22 22
     public function buildPacket()
23
-    {}
23
+    {
24
+}
24 25
 }
Please login to merge, or discard this patch.
src/MySQL/Command/Concrete/PingCommand.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
      * @inheritDoc
21 21
      */
22 22
     public function buildPacket()
23
-    {}
23
+    {
24
+}
24 25
 
25 26
     /**
26 27
      * @override
Please login to merge, or discard this patch.
src/MySQL/Command/Concrete/QueryCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
     public function setQuery($query)
26 26
     {
27
-        if (! $query instanceof Query)
27
+        if (!$query instanceof Query)
28 28
         {
29 29
             $query = new Query($query);
30 30
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,5 +43,6 @@
 block discarded – undo
43 43
     }
44 44
 
45 45
     public function buildPacket()
46
-    {}
46
+    {
47
+}
47 48
 }
Please login to merge, or discard this patch.
src/MySQL/Protocol/ProtocolParser.php 2 patches
Doc Comments   +25 added lines patch added patch discarded remove patch
@@ -84,6 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
     protected $queue;
86 86
 
87
+    /**
88
+     * @param \Dazzle\MySQL\Executor $executor
89
+     */
87 90
     public function __construct($stream, $executor)
88 91
     {
89 92
         $this->stream   = $stream;
@@ -106,6 +109,9 @@  discard block
 block discarded – undo
106 109
         }
107 110
     }
108 111
 
112
+    /**
113
+     * @param string $message
114
+     */
109 115
     public function debug($message)
110 116
     {
111 117
         if ($this->debug)
@@ -380,6 +386,9 @@  discard block
 block discarded – undo
380 386
         $this->buffer .= $str;
381 387
     }
382 388
 
389
+    /**
390
+     * @param string $str
391
+     */
383 392
     public function prepend($str)
384 393
     {
385 394
         $this->buffer = $str . substr($this->buffer, $this->bufferPos);
@@ -402,11 +411,17 @@  discard block
 block discarded – undo
402 411
         return $buffer;
403 412
     }
404 413
 
414
+    /**
415
+     * @param integer $len
416
+     */
405 417
     public function skip($len)
406 418
     {
407 419
         $this->bufferPos += $len;
408 420
     }
409 421
 
422
+    /**
423
+     * @param double $len
424
+     */
410 425
     public function restBuffer($len)
411 426
     {
412 427
         if(strlen($this->buffer) === ($this->bufferPos+$len))
@@ -425,6 +440,9 @@  discard block
 block discarded – undo
425 440
         return strlen($this->buffer) - $this->bufferPos;
426 441
     }
427 442
 
443
+    /**
444
+     * @param string $what
445
+     */
428 446
     public function search($what)
429 447
     {
430 448
         if (($p = strpos($this->buffer, $what, $this->bufferPos)) !== false)
@@ -466,6 +484,9 @@  discard block
 block discarded – undo
466 484
         $this->debug('Auth packet sent');
467 485
     }
468 486
 
487
+    /**
488
+     * @param string $scramble
489
+     */
469 490
     public function getAuthToken($scramble, $password = '')
470 491
     {
471 492
         if ($password === '')
@@ -480,6 +501,7 @@  discard block
 block discarded – undo
480 501
     /**
481 502
      * Builds length-encoded BinarySupport string
482 503
      * @param string String
504
+     * @param string $s
483 505
      * @return string Resulting BinarySupport string
484 506
      */
485 507
     public function buildLenEncodedBinarySupport($s)
@@ -555,6 +577,9 @@  discard block
 block discarded – undo
555 577
         return $this->read($l);
556 578
     }
557 579
 
580
+    /**
581
+     * @param string $packet
582
+     */
558 583
     public function sendPacket($packet)
559 584
     {
560 585
         return $this->stream->write(BinarySupport::int2bytes(3, strlen($packet), true) . chr($this->seq++) . $packet);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 
95 95
     public function start()
96 96
     {
97
-        $this->stream->on('data', [ $this, 'handleData' ]);
98
-        $this->stream->on('close', [ $this, 'handleClose' ]);
97
+        $this->stream->on('data', [$this, 'handleData']);
98
+        $this->stream->on('close', [$this, 'handleClose']);
99 99
     }
100 100
 
101 101
     public function handleNewCommand()
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 }
257 257
                 else
258 258
                 {
259
-                    ++ $this->rsState;
259
+                    ++$this->rsState;
260 260
                 }
261 261
             }
262 262
             //Data packet
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 
410 410
     public function restBuffer($len)
411 411
     {
412
-        if(strlen($this->buffer) === ($this->bufferPos+$len))
412
+        if (strlen($this->buffer) === ($this->bufferPos + $len))
413 413
         {
414 414
             $this->buffer = '';
415 415
         }
416 416
         else
417 417
         {
418
-            $this->buffer = substr($this->buffer,$this->bufferPos+$len);
418
+            $this->buffer = substr($this->buffer, $this->bufferPos + $len);
419 419
         }
420 420
         $this->bufferPos = 0;
421 421
     }
Please login to merge, or discard this patch.
src/MySQL/Database.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
             $options = $this->config;
106 106
             $streamRef = $this->stream;
107 107
 
108
-            $errorHandler = function ($reason) use ($reject) {
108
+            $errorHandler = function($reason) use ($reject) {
109 109
                 $this->state = self::STATE_AUTH_FAILED;
110 110
                 return $reject($reason);
111 111
             };
112 112
 
113
-            $connectedHandler = function ($serverOptions) use ($resolve) {
113
+            $connectedHandler = function($serverOptions) use ($resolve) {
114 114
                 $this->state = self::STATE_AUTH_SUCCEEDED;
115 115
                 $this->serverOptions = $serverOptions;
116 116
                 return $resolve($serverOptions);
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 
119 119
             $this
120 120
                 ->connect()
121
-                ->then(function ($stream) use (&$streamRef, $options, $errorHandler, $connectedHandler) {
121
+                ->then(function($stream) use (&$streamRef, $options, $errorHandler, $connectedHandler) {
122 122
                     $streamRef = $stream;
123 123
 
124
-                    $stream->on('error', [ $this, 'handleConnectionError' ]);
125
-                    $stream->on('close', [ $this, 'handleConnectionClosed' ]);
124
+                    $stream->on('error', [$this, 'handleConnectionError']);
125
+                    $stream->on('close', [$this, 'handleConnectionClosed']);
126 126
 
127 127
                     $parser = $this->parser = new ProtocolParser($stream, $this->executor);
128 128
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                     //$parser->on('close', $closeHandler);
136 136
                     $parser->start();
137 137
 
138
-                }, [ $this, 'handleConnectionError' ]);
138
+                }, [$this, 'handleConnectionError']);
139 139
         });
140 140
     }
141 141
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
                 ->doCommand(new QuitCommand($this))
151 151
                 ->on('success', function() use($resolve) {
152 152
                     $this->state = self::STATE_STOPPED;
153
-                    $this->emit('end', [ $this ]);
154
-                    $this->emit('close', [ $this ]);
153
+                    $this->emit('end', [$this]);
154
+                    $this->emit('close', [$this]);
155 155
                     $resolve($this);
156 156
                 });
157 157
             $this->state = self::STATE_CLOSEING;
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
         $query->bindParamsFromArray($sqlParams);
176 176
         $this->doCommand($command);
177 177
 
178
-        $command->on('results', function ($rows, $command) use ($promise) {
178
+        $command->on('results', function($rows, $command) use ($promise) {
179 179
             return $promise->resolve($command);
180 180
         });
181
-        $command->on('error', function ($err, $command) use ($promise) {
181
+        $command->on('error', function($err, $command) use ($promise) {
182 182
             return $promise->reject($err);
183 183
         });
184
-        $command->on('success', function ($command) use ($promise) {
184
+        $command->on('success', function($command) use ($promise) {
185 185
             return $promise->resolve($command);
186 186
         });
187 187
 
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
         $promise = new Promise();
194 194
 
195 195
         $this->doCommand(new PingCommand($this))
196
-            ->on('error', function ($reason) use ($promise) {
196
+            ->on('error', function($reason) use ($promise) {
197 197
                 return $promise->reject($reason);
198 198
             })
199
-            ->on('success', function () use ($promise) {
199
+            ->on('success', function() use ($promise) {
200 200
                 return $promise->resolve();
201 201
             });
202 202
     }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
     public function handleConnectionError($err)
232 232
     {
233
-        $this->emit('error', [ $err, $this ]);
233
+        $this->emit('error', [$err, $this]);
234 234
     }
235 235
 
236 236
     public function handleConnectionClosed()
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         if ($this->state < self::STATE_CLOSEING)
239 239
         {
240 240
             $this->state = self::STATE_STOPPED;
241
-            $this->emit('error', [ new RuntimeException('mysql server has gone away'), $this ]);
241
+            $this->emit('error', [new RuntimeException('mysql server has gone away'), $this]);
242 242
         }
243 243
     }
244 244
 
Please login to merge, or discard this patch.