@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | |