Completed
Push — master ( d1f44d...2f7083 )
by Kamil
02:59
created
src/MySQL/Protocol/ProtocolParser.php 2 patches
Doc Comments   +19 added lines patch added patch discarded remove patch
@@ -165,6 +165,9 @@  discard block
 block discarded – undo
165 165
         }
166 166
     }
167 167
 
168
+    /**
169
+     * @param string $message
170
+     */
168 171
     public function debug($message)
169 172
     {
170 173
         if ($this->debug)
@@ -426,6 +429,9 @@  discard block
 block discarded – undo
426 429
         $this->buffer .= $str;
427 430
     }
428 431
 
432
+    /**
433
+     * @param string $str
434
+     */
429 435
     public function prepend($str)
430 436
     {
431 437
         $this->buffer = $str . substr($this->buffer, $this->bufferPos);
@@ -448,11 +454,17 @@  discard block
 block discarded – undo
448 454
         return $buffer;
449 455
     }
450 456
 
457
+    /**
458
+     * @param integer $len
459
+     */
451 460
     public function skip($len)
452 461
     {
453 462
         $this->bufferPos += $len;
454 463
     }
455 464
 
465
+    /**
466
+     * @param double $len
467
+     */
456 468
     public function restBuffer($len)
457 469
     {
458 470
         if (strlen($this->buffer) === ($this->bufferPos+$len))
@@ -471,6 +483,9 @@  discard block
 block discarded – undo
471 483
         return strlen($this->buffer) - $this->bufferPos;
472 484
     }
473 485
 
486
+    /**
487
+     * @param string $what
488
+     */
474 489
     public function search($what)
475 490
     {
476 491
         if (($p = strpos($this->buffer, $what, $this->bufferPos)) !== false)
@@ -512,6 +527,9 @@  discard block
 block discarded – undo
512 527
         $this->debug('Auth packet sent');
513 528
     }
514 529
 
530
+    /**
531
+     * @param string $scramble
532
+     */
515 533
     public function getAuthToken($scramble, $password = '')
516 534
     {
517 535
         if ($password === '')
@@ -526,6 +544,7 @@  discard block
 block discarded – undo
526 544
     /**
527 545
      * Builds length-encoded BinSupport string
528 546
      * @param string String
547
+     * @param string $s
529 548
      * @return string Resulting BinSupport string
530 549
      */
531 550
     public function buildLenEncodedBinSupport($s)
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * @var int
20 20
      */
21
-    const PHASE_INIT       = 1;
21
+    const PHASE_INIT = 1;
22 22
 
23 23
     /**
24 24
      * @var int
25 25
      */
26
-    const PHASE_AUTH_SENT  = 2;
26
+    const PHASE_AUTH_SENT = 2;
27 27
 
28 28
     /**
29 29
      * @var int
30 30
      */
31
-    const PHASE_AUTH_ERR   = 3;
31
+    const PHASE_AUTH_ERR = 3;
32 32
 
33 33
     /**
34 34
      * @var int
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @var int
40 40
      */
41
-    const RS_STATE_HEADER  = 0;
41
+    const RS_STATE_HEADER = 0;
42 42
 
43 43
     /**
44 44
      * @var int
45 45
      */
46
-    const RS_STATE_FIELD   = 1;
46
+    const RS_STATE_FIELD = 1;
47 47
 
48 48
     /**
49 49
      * @var int
50 50
      */
51
-    const RS_STATE_ROW     = 2;
51
+    const RS_STATE_ROW = 2;
52 52
 
53 53
     /**
54 54
      * @var int
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
     /**
59 59
      * @var int
60 60
      */
61
-    const STATE_BODY    = 1;
61
+    const STATE_BODY = 1;
62 62
 
63 63
     /**
64 64
      * @var string
65 65
      */
66
-    protected $user     = 'root';
66
+    protected $user = 'root';
67 67
 
68 68
     /**
69 69
      * @var string
70 70
      */
71
-    protected $pass     = '';
71
+    protected $pass = '';
72 72
 
73 73
     /**
74 74
      * @var string
75 75
      */
76
-    protected $dbname   = '';
76
+    protected $dbname = '';
77 77
 
78 78
     /**
79 79
      * @var CommandInterface
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
         $this->executor = $executor;
149 149
         $this->queue    = new SplQueue($this);
150 150
         $this->configure($config);
151
-        $executor->on('new', [ $this, 'handleNewCommand' ]);
151
+        $executor->on('new', [$this, 'handleNewCommand']);
152 152
     }
153 153
 
154 154
     public function start()
155 155
     {
156
-        $this->stream->on('data', [ $this, 'handleData' ]);
157
-        $this->stream->on('close', [ $this, 'handleClose' ]);
156
+        $this->stream->on('data', [$this, 'handleData']);
157
+        $this->stream->on('close', [$this, 'handleClose']);
158 158
     }
159 159
 
160 160
     public function handleNewCommand()
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                 }
305 305
                 else
306 306
                 {
307
-                    ++ $this->rsState;
307
+                    ++$this->rsState;
308 308
                 }
309 309
             }
310 310
             //Data packet
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $command = $this->queue->dequeue();
373 373
         $error = new Exception($this->errmsg, $this->errno);
374 374
         $command->setError($error);
375
-        $command->emit('error', [ $command, $error ]);
375
+        $command->emit('error', [$command, $error]);
376 376
         $this->errmsg = '';
377 377
         $this->errno  = 0;
378 378
     }
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         $command->resultRows   = $this->resultRows;
385 385
         $command->resultFields = $this->resultFields;
386 386
 
387
-        $command->emit('success', [ $command, $this->resultRows ]);
387
+        $command->emit('success', [$command, $this->resultRows]);
388 388
 
389 389
         $this->rsState      = self::RS_STATE_HEADER;
390 390
         $this->resultRows   = $this->resultFields = [];
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
         $command->warnCount    = $this->warnCount;
400 400
         $command->message      = $this->message;
401 401
 
402
-        $command->emit('success', [ $command ]);
402
+        $command->emit('success', [$command]);
403 403
     }
404 404
 
405 405
     protected function onAuthenticated()
406 406
     {
407 407
         $command = $this->queue->dequeue();
408
-        $command->emit('success', [ $command, $this->connectOptions ]);
408
+        $command->emit('success', [$command, $this->connectOptions]);
409 409
     }
410 410
 
411 411
     protected function handleClose()
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
             $command = $this->queue->dequeue();
417 417
             if ($command->equals(Command::QUIT))
418 418
             {
419
-                $command->emit('success', [ $command ]);
419
+                $command->emit('success', [$command]);
420 420
             }
421 421
         }
422 422
     }
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 
456 456
     public function restBuffer($len)
457 457
     {
458
-        if (strlen($this->buffer) === ($this->bufferPos+$len))
458
+        if (strlen($this->buffer) === ($this->bufferPos + $len))
459 459
         {
460 460
             $this->buffer = '';
461 461
         }
462 462
         else
463 463
         {
464
-            $this->buffer = substr($this->buffer,$this->bufferPos+$len);
464
+            $this->buffer = substr($this->buffer, $this->bufferPos + $len);
465 465
         }
466 466
         $this->bufferPos = 0;
467 467
     }
Please login to merge, or discard this patch.
src/MySQL/Transaction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@
 block discarded – undo
61 61
         $query   = new Query($sql, $sqlParams);
62 62
         $command = new QueryCommand($this->database, $query);
63 63
 
64
-        $command->on('error', function ($command, $err) use ($promise) {
64
+        $command->on('error', function($command, $err) use ($promise) {
65 65
             return $promise->reject($err);
66 66
         });
67
-        $command->on('success', function ($command) use ($promise) {
67
+        $command->on('success', function($command) use ($promise) {
68 68
             return $promise->resolve($command);
69 69
         });
70 70
 
Please login to merge, or discard this patch.
src/MySQL/Database.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * @var int
34 34
      */
35
-    const STATE_INIT                 = 0;
35
+    const STATE_INIT = 0;
36 36
 
37 37
     /**
38 38
      * @var int
39 39
      */
40
-    const STATE_CONNECT_PENDING      = 4;
40
+    const STATE_CONNECT_PENDING = 4;
41 41
 
42 42
     /**
43 43
      * @var int
44 44
      */
45
-    const STATE_CONNECT_FAILED       = 2;
45
+    const STATE_CONNECT_FAILED = 2;
46 46
 
47 47
     /**
48 48
      * @var int
49 49
      */
50
-    const STATE_CONNECT_SUCCEEDED    = 6;
50
+    const STATE_CONNECT_SUCCEEDED = 6;
51 51
 
52 52
     /**
53 53
      * @var int
54 54
      */
55
-    const STATE_AUTH_PENDING         = 5;
55
+    const STATE_AUTH_PENDING = 5;
56 56
 
57 57
     /**
58 58
      * @var int
59 59
      */
60
-    const STATE_AUTH_FAILED          = 3;
60
+    const STATE_AUTH_FAILED = 3;
61 61
 
62 62
     /**
63 63
      * @var int
64 64
      */
65
-    const STATE_AUTH_SUCCEEDED       = 7;
65
+    const STATE_AUTH_SUCCEEDED = 7;
66 66
 
67 67
     /**
68 68
      * @var int
69 69
      */
70
-    const STATE_DISCONNECT_PENDING   = 8;
70
+    const STATE_DISCONNECT_PENDING = 8;
71 71
 
72 72
     /**
73 73
      * @var int
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
         $this->state = self::STATE_CONNECT_PENDING;
170 170
         $config = $this->config;
171 171
 
172
-        $errorHandler = function ($command, $reason) use ($promise) {
172
+        $errorHandler = function($command, $reason) use ($promise) {
173 173
             $this->state = self::STATE_AUTH_FAILED;
174 174
             return $promise->reject($reason);
175 175
         };
176 176
 
177
-        $connectedHandler = function ($command, $info) use ($promise) {
177
+        $connectedHandler = function($command, $info) use ($promise) {
178 178
             $this->state = self::STATE_AUTH_SUCCEEDED;
179 179
             $this->serverInfo = $info;
180 180
             return $promise->resolve($info);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
             ->then(function($stream) use ($config, $errorHandler, $connectedHandler) {
186 186
                 $this->stream = $stream;
187 187
 
188
-                $stream->on('error', [ $this, 'handleSocketError' ]);
189
-                $stream->on('close', [ $this, 'handleSocketClose' ]);
188
+                $stream->on('error', [$this, 'handleSocketError']);
189
+                $stream->on('close', [$this, 'handleSocketClose']);
190 190
 
191 191
                 $this->state  = self::STATE_AUTH_PENDING;
192 192
                 $this->parser = new ProtocolParser($stream, $this->queue, $config);
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                 //$parser->on('close', $closeHandler);
199 199
                 $this->parser->start();
200 200
             })
201
-            ->done(null, [ $this, 'handleError' ]);
201
+            ->done(null, [$this, 'handleError']);
202 202
 
203 203
         return $promise;
204 204
     }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 ->doCommand(new QuitCommand($this))
219 219
                 ->on('success', function() use($resolve) {
220 220
                     $this->state = self::STATE_DISCONNECT_SUCCEEDED;
221
-                    $this->emit('stop', [ $this ]);
221
+                    $this->emit('stop', [$this]);
222 222
                     $resolve($this);
223 223
                 });
224 224
             $this->state = self::STATE_DISCONNECT_PENDING;
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 
274 274
         $this->doCommand($command);
275 275
 
276
-        $command->on('error', function ($command, $err) use ($promise) {
276
+        $command->on('error', function($command, $err) use ($promise) {
277 277
             return $promise->reject($err);
278 278
         });
279
-        $command->on('success', function ($command) use ($promise) {
279
+        $command->on('success', function($command) use ($promise) {
280 280
             return $promise->resolve($command);
281 281
         });
282 282
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
         $promise = new Promise();
304 304
 
305 305
         $command = $this->doCommand(new PingCommand($this));
306
-        $command->on('error', function ($command, $reason) use ($promise) {
306
+        $command->on('error', function($command, $reason) use ($promise) {
307 307
             return $promise->reject($reason);
308 308
         });
309
-        $command->on('success', function () use ($promise) {
309
+        $command->on('success', function() use ($promise) {
310 310
             return $promise->resolve();
311 311
         });
312 312
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      */
346 346
     public function handleError($err)
347 347
     {
348
-        $this->emit('error', [ $this, $err ]);
348
+        $this->emit('error', [$this, $err]);
349 349
     }
350 350
 
351 351
     /**
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public function handleSocketError($socket, $err)
355 355
     {
356
-        $this->emit('error', [ $this, $err ]);
356
+        $this->emit('error', [$this, $err]);
357 357
     }
358 358
 
359 359
     /**
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         if ($this->state < self::STATE_DISCONNECT_PENDING)
365 365
         {
366 366
             $this->state = self::STATE_DISCONNECT_SUCCEEDED;
367
-            $this->emit('error', [ $this, new RuntimeException('MySQL server has gone away!') ]);
367
+            $this->emit('error', [$this, new RuntimeException('MySQL server has gone away!')]);
368 368
         }
369 369
     }
370 370
 
Please login to merge, or discard this patch.
src/MySQL/Protocol/Command.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,8 @@
 block discarded – undo
267 267
     }
268 268
 
269 269
     public function buildPacket()
270
-    {}
270
+    {
271
+}
271 272
 
272 273
     public function getState($name, $default = null)
273 274
     {
Please login to merge, or discard this patch.