@@ -78,7 +78,7 @@ |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * @return array |
|
| 81 | + * @return string[] |
|
| 82 | 82 | */ |
| 83 | 83 | public function getFields() { |
| 84 | 84 | return $this->fields; |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | protected function buildLimit($query, $offset = null) { |
| 30 | 30 | $limit = $this->limit; |
| 31 | - if($limit === null && $offset !== null) { |
|
| 31 | + if ($limit === null && $offset !== null) { |
|
| 32 | 32 | $limit = '18446744073709551615'; |
| 33 | 33 | } |
| 34 | - if($limit !== null) { |
|
| 34 | + if ($limit !== null) { |
|
| 35 | 35 | $query .= "LIMIT\n\t{$limit}\n"; |
| 36 | 36 | } |
| 37 | 37 | return $query; |
@@ -21,16 +21,16 @@ |
||
| 21 | 21 | * @return array[]|\Generator |
| 22 | 22 | */ |
| 23 | 23 | public function generate(QueryStatement $statement, Closure $callback = null) { |
| 24 | - while($row = $statement->fetch()) { |
|
| 25 | - if($this->preserveTypes) { |
|
| 24 | + while ($row = $statement->fetch()) { |
|
| 25 | + if ($this->preserveTypes) { |
|
| 26 | 26 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 27 | 27 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 28 | 28 | } |
| 29 | - if($callback !== null) { |
|
| 29 | + if ($callback !== null) { |
|
| 30 | 30 | $result = $callback($row); |
| 31 | - if($result instanceof DBIgnoreRow) { |
|
| 31 | + if ($result instanceof DBIgnoreRow) { |
|
| 32 | 32 | // Do nothing in this case |
| 33 | - } elseif($result !== null) { |
|
| 33 | + } elseif ($result !== null) { |
|
| 34 | 34 | yield $result; |
| 35 | 35 | } else { |
| 36 | 36 | yield $row; |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | * @return $this |
| 47 | 47 | */ |
| 48 | 48 | public function setFetchMode($mode, $arg0 = null, array $arg1 = null) { |
| 49 | - if($arg1 !== null) { |
|
| 49 | + if ($arg1 !== null) { |
|
| 50 | 50 | /** @noinspection PhpMethodParametersCountMismatchInspection */ |
| 51 | 51 | $this->statement->setFetchMode($mode, $arg0, $arg1); |
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | - if($arg0 !== null) { |
|
| 54 | + if ($arg0 !== null) { |
|
| 55 | 55 | /** @noinspection PhpMethodParametersCountMismatchInspection */ |
| 56 | 56 | $this->statement->setFetchMode($mode, $arg0); |
| 57 | 57 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $timer = microtime(true); |
| 71 | 71 | $response = $this->statement->execute($params); |
| 72 | 72 | $this->queryLoggers->log($this->query, microtime(true)-$timer); |
| 73 | - if(!$response) { |
|
| 73 | + if (!$response) { |
|
| 74 | 74 | throw new SqlException('Execution returned with "false".'); |
| 75 | 75 | } |
| 76 | 76 | }); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorArgs = []) { |
| 87 | 87 | return $this->exceptionHandler(function() use ($fetchStyle, $fetchArgument, $ctorArgs) { |
| 88 | - if($fetchArgument !== null) { |
|
| 88 | + if ($fetchArgument !== null) { |
|
| 89 | 89 | return $this->statement->fetchAll($fetchStyle, $fetchArgument, $ctorArgs); |
| 90 | 90 | } |
| 91 | 91 | return $this->statement->fetchAll($fetchStyle); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | - * @return bool |
|
| 179 | + * @return integer |
|
| 180 | 180 | */ |
| 181 | 181 | public function getFoundRows() { |
| 182 | 182 | return $this->foundRows; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | /** |
| 225 | 225 | * @param callable $callback |
| 226 | 226 | * @param int $mode |
| 227 | - * @param mixed $arg0 |
|
| 227 | + * @param string $arg0 |
|
| 228 | 228 | * @return mixed |
| 229 | 229 | * @throws \Exception |
| 230 | 230 | */ |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | /** |
| 259 | 259 | * @param callable $callback |
| 260 | 260 | * @param int $mode |
| 261 | - * @param mixed $arg0 |
|
| 261 | + * @param string $arg0 |
|
| 262 | 262 | * @return Generator|YieldPolyfillIterator|mixed[] |
| 263 | 263 | */ |
| 264 | 264 | private function fetchLazy($callback, $mode, $arg0 = null) { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | /** |
| 279 | 279 | * @param callable $callback |
| 280 | 280 | * @param int $mode |
| 281 | - * @param mixed $arg0 |
|
| 281 | + * @param string $arg0 |
|
| 282 | 282 | * @return mixed |
| 283 | 283 | * @throws \Exception |
| 284 | 284 | */ |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * @return mixed[] |
| 118 | 118 | */ |
| 119 | 119 | public function fetchKeyValue($treatValueAsArray = false) { |
| 120 | - return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) { |
|
| 121 | - if($treatValueAsArray) { |
|
| 120 | + return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) { |
|
| 121 | + if ($treatValueAsArray) { |
|
| 122 | 122 | $rows = $statement->fetchAll(\PDO::FETCH_ASSOC); |
| 123 | 123 | $result = array(); |
| 124 | - foreach($rows as $row) { |
|
| 124 | + foreach ($rows as $row) { |
|
| 125 | 125 | list($key) = array_values($row); |
| 126 | 126 | $result[$key] = $row; |
| 127 | 127 | } |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | public function fetchGroups(array $fields) { |
| 139 | 139 | $rows = $this->fetchRows(); |
| 140 | 140 | $result = array(); |
| 141 | - foreach($rows as $row) { |
|
| 141 | + foreach ($rows as $row) { |
|
| 142 | 142 | $tmp = &$result; |
| 143 | - foreach($fields as $field) { |
|
| 143 | + foreach ($fields as $field) { |
|
| 144 | 144 | $value = $row[$field]; |
| 145 | - if(!array_key_exists($value, $tmp)) { |
|
| 145 | + if (!array_key_exists($value, $tmp)) { |
|
| 146 | 146 | $tmp[$value] = []; |
| 147 | 147 | } |
| 148 | 148 | $tmp = &$tmp[$value]; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @return string[] |
| 157 | 157 | */ |
| 158 | 158 | public function fetchArray() { |
| 159 | - return $this->createTempStatement(function (QueryStatement $stmt) { |
|
| 159 | + return $this->createTempStatement(function(QueryStatement $stmt) { |
|
| 160 | 160 | return $stmt->fetchAll(\PDO::FETCH_COLUMN); |
| 161 | 161 | }); |
| 162 | 162 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | * @return null|bool|string|int|float |
| 167 | 167 | */ |
| 168 | 168 | public function fetchValue($default = null) { |
| 169 | - return $this->createTempStatement(function (QueryStatement $stmt) use ($default) { |
|
| 169 | + return $this->createTempStatement(function(QueryStatement $stmt) use ($default) { |
|
| 170 | 170 | $result = $stmt->fetch(\PDO::FETCH_NUM); |
| 171 | - if($result !== false) { |
|
| 171 | + if ($result !== false) { |
|
| 172 | 172 | return $result[0]; |
| 173 | 173 | } |
| 174 | 174 | return $default; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $query = $this->__toString(); |
| 209 | 209 | $statement = $db->prepare($query); |
| 210 | 210 | $statement->execute($this->values); |
| 211 | - if($this->getCalcFoundRows()) { |
|
| 211 | + if ($this->getCalcFoundRows()) { |
|
| 212 | 212 | $this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn(); |
| 213 | 213 | } |
| 214 | 214 | return $statement; |
@@ -229,20 +229,20 @@ discard block |
||
| 229 | 229 | * @throws \Exception |
| 230 | 230 | */ |
| 231 | 231 | private function fetchAll($callback, $mode, $arg0 = null) { |
| 232 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 232 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 233 | 233 | $statement->setFetchMode($mode, $arg0); |
| 234 | 234 | $data = $statement->fetchAll(); |
| 235 | - if($this->preserveTypes) { |
|
| 235 | + if ($this->preserveTypes) { |
|
| 236 | 236 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 237 | - foreach($data as &$row) { |
|
| 237 | + foreach ($data as &$row) { |
|
| 238 | 238 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | - if($callback !== null) { |
|
| 242 | - return call_user_func(function ($resultData = []) use ($data, $callback) { |
|
| 243 | - foreach($data as $row) { |
|
| 241 | + if ($callback !== null) { |
|
| 242 | + return call_user_func(function($resultData = []) use ($data, $callback) { |
|
| 243 | + foreach ($data as $row) { |
|
| 244 | 244 | $result = $callback($row); |
| 245 | - if($result !== null && !($result instanceof DBIgnoreRow)) { |
|
| 245 | + if ($result !== null && !($result instanceof DBIgnoreRow)) { |
|
| 246 | 246 | $resultData[] = $result; |
| 247 | 247 | } else { |
| 248 | 248 | $resultData[] = $row; |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | * @return Generator|YieldPolyfillIterator|mixed[] |
| 263 | 263 | */ |
| 264 | 264 | private function fetchLazy($callback, $mode, $arg0 = null) { |
| 265 | - if(version_compare(PHP_VERSION, '5.5', '<')) { |
|
| 266 | - return new YieldPolyfillIterator($callback, $this->preserveTypes, function () use ($mode, $arg0) { |
|
| 265 | + if (version_compare(PHP_VERSION, '5.5', '<')) { |
|
| 266 | + return new YieldPolyfillIterator($callback, $this->preserveTypes, function() use ($mode, $arg0) { |
|
| 267 | 267 | $statement = $this->createStatement(); |
| 268 | 268 | $statement->setFetchMode($mode, $arg0); |
| 269 | 269 | return $statement; |
@@ -283,19 +283,19 @@ discard block |
||
| 283 | 283 | * @throws \Exception |
| 284 | 284 | */ |
| 285 | 285 | private function fetch($callback, $mode, $arg0 = null) { |
| 286 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 286 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 287 | 287 | $statement->setFetchMode($mode, $arg0); |
| 288 | 288 | $row = $statement->fetch(); |
| 289 | - if(!is_array($row)) { |
|
| 289 | + if (!is_array($row)) { |
|
| 290 | 290 | return []; |
| 291 | 291 | } |
| 292 | - if($this->preserveTypes) { |
|
| 292 | + if ($this->preserveTypes) { |
|
| 293 | 293 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 294 | 294 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 295 | 295 | } |
| 296 | - if($callback !== null) { |
|
| 296 | + if ($callback !== null) { |
|
| 297 | 297 | $result = $callback($row); |
| 298 | - if($result !== null) { |
|
| 298 | + if ($result !== null) { |
|
| 299 | 299 | $row = $result; |
| 300 | 300 | } |
| 301 | 301 | } |