@@ -84,6 +84,9 @@ discard block |
||
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; |
@@ -105,6 +108,9 @@ discard block |
||
105 | 108 | } |
106 | 109 | } |
107 | 110 | |
111 | + /** |
|
112 | + * @param string $message |
|
113 | + */ |
|
108 | 114 | public function debug($message) |
109 | 115 | { |
110 | 116 | if ($this->debug) { |
@@ -343,6 +349,9 @@ discard block |
||
343 | 349 | $this->buffer .= $str; |
344 | 350 | } |
345 | 351 | |
352 | + /** |
|
353 | + * @param string $str |
|
354 | + */ |
|
346 | 355 | public function prepend($str) |
347 | 356 | { |
348 | 357 | $this->buffer = $str . substr($this->buffer, $this->bufferPos); |
@@ -363,11 +372,17 @@ discard block |
||
363 | 372 | return $buffer; |
364 | 373 | } |
365 | 374 | |
375 | + /** |
|
376 | + * @param integer $len |
|
377 | + */ |
|
366 | 378 | public function skip($len) |
367 | 379 | { |
368 | 380 | $this->bufferPos += $len; |
369 | 381 | } |
370 | 382 | |
383 | + /** |
|
384 | + * @param double $len |
|
385 | + */ |
|
371 | 386 | public function restBuffer($len) |
372 | 387 | { |
373 | 388 | if(strlen($this->buffer) === ($this->bufferPos+$len)){ |
@@ -383,6 +398,9 @@ discard block |
||
383 | 398 | return strlen($this->buffer) - $this->bufferPos; |
384 | 399 | } |
385 | 400 | |
401 | + /** |
|
402 | + * @param string $what |
|
403 | + */ |
|
386 | 404 | public function search($what) |
387 | 405 | { |
388 | 406 | if (($p = strpos($this->buffer, $what, $this->bufferPos)) !== false) { |
@@ -421,6 +439,9 @@ discard block |
||
421 | 439 | $this->debug('Auth packet sent'); |
422 | 440 | } |
423 | 441 | |
442 | + /** |
|
443 | + * @param string $scramble |
|
444 | + */ |
|
424 | 445 | public function getAuthToken($scramble, $password = '') |
425 | 446 | { |
426 | 447 | if ($password === '') { |
@@ -434,6 +455,7 @@ discard block |
||
434 | 455 | /** |
435 | 456 | * Builds length-encoded BinarySupport string |
436 | 457 | * @param string String |
458 | + * @param string $s |
|
437 | 459 | * @return string Resulting BinarySupport string |
438 | 460 | */ |
439 | 461 | public function buildLenEncodedBinarySupport($s) |
@@ -499,6 +521,9 @@ discard block |
||
499 | 521 | return $this->read($l); |
500 | 522 | } |
501 | 523 | |
524 | + /** |
|
525 | + * @param string $packet |
|
526 | + */ |
|
502 | 527 | public function sendPacket($packet) |
503 | 528 | { |
504 | 529 | return $this->stream->write(BinarySupport::int2bytes(3, strlen($packet), true) . chr($this->seq++) . $packet); |
@@ -94,8 +94,8 @@ discard block |
||
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() |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $this->nextRequest(); |
231 | 231 | $this->onResultDone(); |
232 | 232 | } else { |
233 | - ++ $this->rsState; |
|
233 | + ++$this->rsState; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | } else { //Data packet |
@@ -370,10 +370,10 @@ discard block |
||
370 | 370 | |
371 | 371 | public function restBuffer($len) |
372 | 372 | { |
373 | - if(strlen($this->buffer) === ($this->bufferPos+$len)){ |
|
373 | + if (strlen($this->buffer) === ($this->bufferPos + $len)) { |
|
374 | 374 | $this->buffer = ''; |
375 | - }else{ |
|
376 | - $this->buffer = substr($this->buffer,$this->bufferPos+$len); |
|
375 | + } else { |
|
376 | + $this->buffer = substr($this->buffer, $this->bufferPos + $len); |
|
377 | 377 | } |
378 | 378 | $this->bufferPos = 0; |
379 | 379 | } |
@@ -382,6 +382,7 @@ |
||
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 | { |
@@ -44,7 +44,6 @@ |
||
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() |
@@ -50,7 +50,7 @@ discard block |
||
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 |
||
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 | } |
@@ -24,7 +24,7 @@ |
||
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 | } |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | throw new Exception('Not Implemented'); |
109 | 109 | } |
110 | 110 | |
111 | - $errorHandler = function ($reason) use ($args) { |
|
111 | + $errorHandler = function($reason) use ($args) { |
|
112 | 112 | $this->state = self::STATE_AUTH_FAILED; |
113 | 113 | $args[0]($reason, $this); |
114 | 114 | }; |
115 | 115 | |
116 | - $connectedHandler = function ($serverOptions) use ($args) { |
|
116 | + $connectedHandler = function($serverOptions) use ($args) { |
|
117 | 117 | $this->state = self::STATE_AUTH_SUCCEEDED; |
118 | 118 | $this->serverOptions = $serverOptions; |
119 | 119 | $args[0](null, $this); |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | |
122 | 122 | $this |
123 | 123 | ->connect() |
124 | - ->then(function ($stream) use (&$streamRef, $options, $errorHandler, $connectedHandler) { |
|
124 | + ->then(function($stream) use (&$streamRef, $options, $errorHandler, $connectedHandler) { |
|
125 | 125 | $streamRef = $stream; |
126 | 126 | |
127 | - $stream->on('error', [ $this, 'handleConnectionError' ]); |
|
128 | - $stream->on('close', [ $this, 'handleConnectionClosed' ]); |
|
127 | + $stream->on('error', [$this, 'handleConnectionError']); |
|
128 | + $stream->on('close', [$this, 'handleConnectionClosed']); |
|
129 | 129 | |
130 | 130 | $parser = $this->parser = new ProtocolParser($stream, $this->executor); |
131 | 131 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | //$parser->on('close', $closeHandler); |
139 | 139 | $parser->start(); |
140 | 140 | |
141 | - }, [ $this, 'handleConnectionError' ]); |
|
141 | + }, [$this, 'handleConnectionError']); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | ->doCommand(new QuitCommand($this)) |
152 | 152 | ->on('success', function() { |
153 | 153 | $this->state = self::STATE_STOPPED; |
154 | - $this->emit('end', [ $this ]); |
|
155 | - $this->emit('close', [ $this ]); |
|
154 | + $this->emit('end', [$this]); |
|
155 | + $this->emit('close', [$this]); |
|
156 | 156 | }); |
157 | 157 | $this->state = self::STATE_CLOSEING; |
158 | 158 | } |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | $query->bindParamsFromArray($args); |
192 | 192 | $this->doCommand($command); |
193 | 193 | |
194 | - $command->on('results', function ($rows, $command) use ($callback) { |
|
194 | + $command->on('results', function($rows, $command) use ($callback) { |
|
195 | 195 | $callback($command, $this); |
196 | 196 | }); |
197 | - $command->on('error', function ($err, $command) use ($callback) { |
|
197 | + $command->on('error', function($err, $command) use ($callback) { |
|
198 | 198 | $callback($command, $this); |
199 | 199 | }); |
200 | - $command->on('success', function ($command) use ($callback) { |
|
200 | + $command->on('success', function($command) use ($callback) { |
|
201 | 201 | $callback($command, $this); |
202 | 202 | }); |
203 | 203 | } |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | throw new InvalidArgumentException('Callback is not a valid callable'); |
210 | 210 | } |
211 | 211 | $this->doCommand(new PingCommand($this)) |
212 | - ->on('error', function ($reason) use ($callback) { |
|
212 | + ->on('error', function($reason) use ($callback) { |
|
213 | 213 | $callback($reason, $this); |
214 | 214 | }) |
215 | - ->on('success', function () use ($callback) { |
|
215 | + ->on('success', function() use ($callback) { |
|
216 | 216 | $callback(null, $this); |
217 | 217 | }); |
218 | 218 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | public function handleConnectionError($err) |
248 | 248 | { |
249 | - $this->emit('error', [ $err, $this ]); |
|
249 | + $this->emit('error', [$err, $this]); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | public function handleConnectionClosed() |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | if ($this->state < self::STATE_CLOSEING) |
255 | 255 | { |
256 | 256 | $this->state = self::STATE_STOPPED; |
257 | - $this->emit('error', [ new RuntimeException('mysql server has gone away'), $this ]); |
|
257 | + $this->emit('error', [new RuntimeException('mysql server has gone away'), $this]); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 |