@@ -8,6 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | 10 | * @inheritDoc |
| 11 | + * @param string $queryString |
|
| 11 | 12 | */ |
| 12 | 13 | public function __construct(MysqliAdapter $connection, array $values = null, $queryString) |
| 13 | 14 | { |
@@ -321,7 +321,6 @@ |
||
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | 323 | * @param CredentialsInterface $credentials |
| 324 | - * @param bool $resolveNamedParameters |
|
| 325 | 324 | * @return MysqliAdapter |
| 326 | 325 | */ |
| 327 | 326 | public static function factory(CredentialsInterface $credentials, array $options = null): self |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $this->cnx = $cnx; |
| 57 | 57 | $this->credentials = $credentials; |
| 58 | 58 | if (null !== $options) { |
| 59 | - $this->options = array_replace($this->getDefaultOptions(), $options); |
|
| 59 | + $this->options = array_replace($this->getDefaultOptions(), $options); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | try { |
| 140 | - $wrappedStmt = self::wrapWithErrorHandler(function () use ($runnableQueryString) { |
|
| 140 | + $wrappedStmt = self::wrapWithErrorHandler(function() use ($runnableQueryString) { |
|
| 141 | 141 | return $this->cnx->prepare($runnableQueryString); |
| 142 | 142 | }); |
| 143 | 143 | } catch (mysqli_sql_exception $e) { |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | return $this->executeParallel($stmt, $values); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - $promise = new Promise(function () use (&$promise, $stmt, $values) { |
|
| 203 | + $promise = new Promise(function() use (&$promise, $stmt, $values) { |
|
| 204 | 204 | try { |
| 205 | 205 | $promise->resolve($this->execute($stmt, $values)); |
| 206 | 206 | } catch (Throwable $e) { |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | $stmt->bind(); |
| 244 | - $promise = MysqliAsync::query($stmt->getRunnableQuery(), $cnx)->then(function ($result) use ($cnx, $stmt) { |
|
| 244 | + $promise = MysqliAsync::query($stmt->getRunnableQuery(), $cnx)->then(function($result) use ($cnx, $stmt) { |
|
| 245 | 245 | if (!$result instanceof mysqli_result) { |
| 246 | 246 | $result = null; |
| 247 | 247 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | private function runStmt(Statement $stmt) |
| 255 | 255 | { |
| 256 | 256 | try { |
| 257 | - return self::wrapWithErrorHandler(function () use ($stmt) { |
|
| 257 | + return self::wrapWithErrorHandler(function() use ($stmt) { |
|
| 258 | 258 | return $stmt->createResult(); |
| 259 | 259 | }); |
| 260 | 260 | } catch (mysqli_sql_exception $e) { |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | private static function wrapWithErrorHandler(callable $run) |
| 351 | 351 | { |
| 352 | - $errorHandler = function ($errno, $errstr) { |
|
| 352 | + $errorHandler = function($errno, $errstr) { |
|
| 353 | 353 | throw new mysqli_sql_exception($errstr, $errno); |
| 354 | 354 | }; |
| 355 | 355 | set_error_handler($errorHandler, E_WARNING); |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | use BenTools\SimpleDBAL\Model\Exception\ParamBindingException; |
| 16 | 16 | use GuzzleHttp\Promise\Promise; |
| 17 | 17 | use GuzzleHttp\Promise\PromiseInterface; |
| 18 | +use Throwable; |
|
| 18 | 19 | use mysqli; |
| 19 | 20 | use mysqli_result; |
| 20 | 21 | use mysqli_sql_exception; |
| 21 | -use Throwable; |
|
| 22 | 22 | |
| 23 | 23 | class MysqliAdapter implements AdapterInterface, TransactionAdapterInterface, ReconnectableAdapterInterface |
| 24 | 24 | { |
@@ -180,7 +180,6 @@ |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * @param \PDOStatement $wrappedStmt |
|
| 184 | 183 | */ |
| 185 | 184 | private function runStmt(Statement $stmt) |
| 186 | 185 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | $this->credentials = $credentials; |
| 54 | 54 | if (null !== $options) { |
| 55 | - $this->options = array_replace($this->getDefaultOptions(), $options); |
|
| 55 | + $this->options = array_replace($this->getDefaultOptions(), $options); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function isConnected(): bool |
| 79 | 79 | { |
| 80 | 80 | try { |
| 81 | - self::wrapWithErrorHandler(function () { |
|
| 81 | + self::wrapWithErrorHandler(function() { |
|
| 82 | 82 | $this->cnx->getAttribute(PDO::ATTR_SERVER_INFO); |
| 83 | 83 | }); |
| 84 | 84 | return true; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function executeAsync($stmt, array $values = null): PromiseInterface |
| 171 | 171 | { |
| 172 | - $promise = new Promise(function () use (&$promise, $stmt, $values) { |
|
| 172 | + $promise = new Promise(function() use (&$promise, $stmt, $values) { |
|
| 173 | 173 | try { |
| 174 | 174 | $promise->resolve($this->execute($stmt, $values)); |
| 175 | 175 | } catch (DBALException $e) { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $wrappedStmt = $stmt->getWrappedStatement(); |
| 188 | 188 | try { |
| 189 | - self::wrapWithErrorHandler(function () use ($stmt, $wrappedStmt) { |
|
| 189 | + self::wrapWithErrorHandler(function() use ($stmt, $wrappedStmt) { |
|
| 190 | 190 | $stmt->bind(); |
| 191 | 191 | $wrappedStmt->execute(); |
| 192 | 192 | }); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | private static function wrapWithErrorHandler(callable $run) |
| 275 | 275 | { |
| 276 | - $errorHandler = function ($errno, $errstr) { |
|
| 276 | + $errorHandler = function($errno, $errstr) { |
|
| 277 | 277 | throw new PDOException($errstr, $errno); |
| 278 | 278 | }; |
| 279 | 279 | set_error_handler($errorHandler, E_WARNING); |
@@ -5,8 +5,8 @@ |
||
| 5 | 5 | use BenTools\SimpleDBAL\Contract\AdapterInterface; |
| 6 | 6 | use BenTools\SimpleDBAL\Contract\CredentialsInterface; |
| 7 | 7 | use BenTools\SimpleDBAL\Contract\ReconnectableAdapterInterface; |
| 8 | -use BenTools\SimpleDBAL\Contract\StatementInterface; |
|
| 9 | 8 | use BenTools\SimpleDBAL\Contract\ResultInterface; |
| 9 | +use BenTools\SimpleDBAL\Contract\StatementInterface; |
|
| 10 | 10 | use BenTools\SimpleDBAL\Contract\TransactionAdapterInterface; |
| 11 | 11 | use BenTools\SimpleDBAL\Model\ConfigurableTrait; |
| 12 | 12 | use BenTools\SimpleDBAL\Model\Exception\AccessDeniedException; |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | /** |
| 29 | 29 | * Result constructor. |
| 30 | 30 | * @param PDO $pdo |
| 31 | - * @param Statement $stmt |
|
| 31 | + * @param PDOStatement $stmt |
|
| 32 | 32 | */ |
| 33 | 33 | public function __construct(PDO $pdo, PDOStatement $stmt = null) |
| 34 | 34 | { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | /** |
| 77 | 77 | * @inheritDoc |
| 78 | 78 | */ |
| 79 | - public function asRow(): ?array |
|
| 79 | + public function asRow(): ? array |
|
| 80 | 80 | { |
| 81 | 81 | if (null === $this->stmt) { |
| 82 | 82 | throw new DBALException("No \PDOStatement object provided."); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $this->resetResultset(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $generator = function (\PDOStatement $stmt) { |
|
| 114 | + $generator = function(\PDOStatement $stmt) { |
|
| 115 | 115 | while ($value = $stmt->fetchColumn(0)) { |
| 116 | 116 | yield $value; |
| 117 | 117 | } |
@@ -126,6 +126,7 @@ |
||
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * @param $var |
| 129 | + * @param string $value |
|
| 129 | 130 | * @return int |
| 130 | 131 | */ |
| 131 | 132 | protected function getPdoType($value) |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | return $this->stmt->queryString; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $escape = function ($value) { |
|
| 159 | + $escape = function($value) { |
|
| 160 | 160 | if (null === $value) { |
| 161 | 161 | return 'NULL'; |
| 162 | 162 | } |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | namespace BenTools\SimpleDBAL\Model\Adapter\PDO; |
| 4 | 4 | |
| 5 | 5 | use BenTools\SimpleDBAL\Contract\AdapterInterface; |
| 6 | -use BenTools\SimpleDBAL\Contract\StatementInterface; |
|
| 7 | 6 | use BenTools\SimpleDBAL\Contract\ResultInterface; |
| 7 | +use BenTools\SimpleDBAL\Contract\StatementInterface; |
|
| 8 | 8 | use BenTools\SimpleDBAL\Model\StatementTrait; |
| 9 | 9 | use PDO; |
| 10 | 10 | use PDOStatement; |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function getValues(): ?array |
|
| 17 | + public function getValues(): ? array |
|
| 18 | 18 | { |
| 19 | 19 | return $this->values; |
| 20 | 20 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * @inheritdoc |
| 76 | 76 | */ |
| 77 | - public function getPassword(): ?string |
|
| 77 | + public function getPassword(): ? string |
|
| 78 | 78 | { |
| 79 | 79 | return $this->password; |
| 80 | 80 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * @inheritdoc |
| 84 | 84 | */ |
| 85 | - public function getDatabase(): ?string |
|
| 85 | + public function getDatabase(): ? string |
|
| 86 | 86 | { |
| 87 | 87 | return $this->database; |
| 88 | 88 | } |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | return $this->queryString; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $escape = function ($value) { |
|
| 166 | + $escape = function($value) { |
|
| 167 | 167 | if (null === $value) { |
| 168 | 168 | return 'NULL'; |
| 169 | 169 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function query(string $query, mysqli $cnx) |
| 34 | 34 | { |
| 35 | - $promise = new Promise(function () { |
|
| 35 | + $promise = new Promise(function() { |
|
| 36 | 36 | self::getInstance()->wait(); |
| 37 | 37 | }); |
| 38 | 38 | $cnx->query($query, MYSQLI_ASYNC); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | foreach ($this->queries as $l => $link) { |
| 120 | 120 | $promise = $this->getPromise($link); |
| 121 | - $cnx = $this->getConnection($link); |
|
| 121 | + $cnx = $this->getConnection($link); |
|
| 122 | 122 | try { |
| 123 | 123 | $result = $cnx->reap_async_query(); |
| 124 | 124 | if ($result instanceof mysqli_result) { |