@@ -10,10 +10,10 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | public static function getFieldTypes(QueryStatement $statement): array { |
| 12 | 12 | $fieldTypes = []; |
| 13 | - for($i = 0; $column = $statement->getColumnMeta($i); $i++) { |
|
| 13 | + for ($i = 0; $column = $statement->getColumnMeta($i); $i++) { |
|
| 14 | 14 | $name = $column['name'] ?? null; |
| 15 | 15 | $nativeType = $column['native_type'] ?? null; |
| 16 | - if(is_string($name) && is_string($nativeType)) { |
|
| 16 | + if (is_string($name) && is_string($nativeType)) { |
|
| 17 | 17 | $fieldTypes[$name] = self::getTypeFromNativeType($nativeType); |
| 18 | 18 | } |
| 19 | 19 | } |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function setFetchMode(int $mode = PDO::FETCH_ASSOC, $arg0 = null, ?array $arg1 = null) { |
| 49 | 49 | $args = [$mode]; |
| 50 | - if($arg0 !== null) { |
|
| 50 | + if ($arg0 !== null) { |
|
| 51 | 51 | $args[] = $arg0; |
| 52 | 52 | } |
| 53 | - if($arg1 !== null) { |
|
| 53 | + if ($arg1 !== null) { |
|
| 54 | 54 | $args[] = $arg1; |
| 55 | 55 | } |
| 56 | 56 | $this->statement->setFetchMode(...$args); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $this->exceptionHandler(function() use ($params) { |
| 67 | 67 | $this->queryLoggers->logRegion($this->query, function() use ($params) { |
| 68 | 68 | $response = $this->statement->execute($params); |
| 69 | - if(!$response) { |
|
| 69 | + if (!$response) { |
|
| 70 | 70 | throw new SqlException('Execution returned with "false".'); |
| 71 | 71 | } |
| 72 | 72 | }); |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function fetchAll($fetchStyle = PDO::FETCH_ASSOC, $fetchArgument = null, array $ctorArgs = []): array { |
| 84 | 84 | $result = $x = $this->exceptionHandler(function() use ($fetchStyle, $fetchArgument, $ctorArgs) { |
| 85 | - if($fetchArgument !== null) { |
|
| 85 | + if ($fetchArgument !== null) { |
|
| 86 | 86 | return $this->statement->fetchAll($fetchStyle, $fetchArgument, ...$ctorArgs); |
| 87 | 87 | } |
| 88 | 88 | return $this->statement->fetchAll($fetchStyle); |
| 89 | 89 | }); |
| 90 | 90 | /** @var array<mixed, mixed>|false $x */ |
| 91 | - if($x === false) { |
|
| 91 | + if ($x === false) { |
|
| 92 | 92 | return []; |
| 93 | 93 | } |
| 94 | 94 | return $result; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | public function getColumnMeta(int $columnNo): ?array { |
| 142 | 142 | return $this->exceptionHandler(function() use ($columnNo) { |
| 143 | 143 | $columnMeta = $this->statement->getColumnMeta($columnNo); |
| 144 | - if($columnMeta === false) { |
|
| 144 | + if ($columnMeta === false) { |
|
| 145 | 145 | return null; |
| 146 | 146 | } |
| 147 | 147 | return $columnMeta; |
@@ -9,13 +9,13 @@ |
||
| 9 | 9 | use Rector\Set\ValueObject\LevelSetList; |
| 10 | 10 | |
| 11 | 11 | return static function (RectorConfig $rectorConfig): void { |
| 12 | - $rectorConfig->paths([ |
|
| 13 | - __DIR__ . '/src', |
|
| 14 | - __DIR__ . '/tests', |
|
| 15 | - ]); |
|
| 12 | + $rectorConfig->paths([ |
|
| 13 | + __DIR__ . '/src', |
|
| 14 | + __DIR__ . '/tests', |
|
| 15 | + ]); |
|
| 16 | 16 | |
| 17 | - // register a single rule |
|
| 18 | - $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); |
|
| 17 | + // register a single rule |
|
| 18 | + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); |
|
| 19 | 19 | |
| 20 | 20 | $rectorConfig->skip([RemoveUselessParamTagRector::class]); |
| 21 | 21 | $rectorConfig->skip([MixedTypeRector::class]); |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | use Rector\Php80\Rector\FunctionLike\MixedTypeRector; |
| 9 | 9 | use Rector\Set\ValueObject\LevelSetList; |
| 10 | 10 | |
| 11 | -return static function (RectorConfig $rectorConfig): void { |
|
| 11 | +return static function(RectorConfig $rectorConfig): void { |
|
| 12 | 12 | $rectorConfig->paths([ |
| 13 | - __DIR__ . '/src', |
|
| 14 | - __DIR__ . '/tests', |
|
| 13 | + __DIR__.'/src', |
|
| 14 | + __DIR__.'/tests', |
|
| 15 | 15 | ]); |
| 16 | 16 | |
| 17 | 17 | // register a single rule |
@@ -14,16 +14,16 @@ discard block |
||
| 14 | 14 | * @return string |
| 15 | 15 | */ |
| 16 | 16 | public static function build(Database $db, string $query, array $conditions, string $token): string { |
| 17 | - if(!count($conditions)) { |
|
| 17 | + if (!count($conditions)) { |
|
| 18 | 18 | return $query; |
| 19 | 19 | } |
| 20 | 20 | $query .= "{$token}\n"; |
| 21 | 21 | $arr = []; |
| 22 | - foreach($conditions as [$expression, $arguments]) { |
|
| 23 | - if(is_array($expression)) { |
|
| 24 | - foreach($expression as $key => $value) { |
|
| 22 | + foreach ($conditions as [$expression, $arguments]) { |
|
| 23 | + if (is_array($expression)) { |
|
| 24 | + foreach ($expression as $key => $value) { |
|
| 25 | 25 | $key = self::formatKey($key); |
| 26 | - if($value === null) { |
|
| 26 | + if ($value === null) { |
|
| 27 | 27 | $arr = self::buildCondition($arr, "ISNULL({$key})", [$value], $db); |
| 28 | 28 | } else { |
| 29 | 29 | $arr = self::buildCondition($arr, "{$key}=?", [$value], $db); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | 57 | private static function formatKey(string $key): string { |
| 58 | - if(strpos($key, '`') !== false || strpos($key, '(') !== false) { |
|
| 58 | + if (strpos($key, '`') !== false || strpos($key, '(') !== false) { |
|
| 59 | 59 | return $key; |
| 60 | 60 | } |
| 61 | 61 | $keyParts = explode('.', $key); |
@@ -14,34 +14,34 @@ |
||
| 14 | 14 | * @return string |
| 15 | 15 | */ |
| 16 | 16 | protected function buildTableName(?string $alias, $name): string { |
| 17 | - if(is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) { |
|
| 17 | + if (is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) { |
|
| 18 | 18 | $name = (string) $name; |
| 19 | 19 | $lines = explode("\n", $name); |
| 20 | 20 | $lines = array_map(static fn(string $line) => "\t{$line}", $lines); |
| 21 | 21 | $name = implode("\n", $lines); |
| 22 | - $name = '(' . trim(rtrim(trim($name), ';')) . ')'; |
|
| 22 | + $name = '('.trim(rtrim(trim($name), ';')).')'; |
|
| 23 | 23 | } |
| 24 | - if(is_array($name)) { |
|
| 24 | + if (is_array($name)) { |
|
| 25 | 25 | $parts = []; |
| 26 | - foreach($name as $index => $bucket) { |
|
| 27 | - if(is_scalar($bucket) && ctype_digit((string) $index)) { |
|
| 26 | + foreach ($name as $index => $bucket) { |
|
| 27 | + if (is_scalar($bucket) && ctype_digit((string) $index)) { |
|
| 28 | 28 | $parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}"; |
| 29 | 29 | } else { |
| 30 | 30 | $values = []; |
| 31 | - foreach($bucket as $field => $value) { |
|
| 31 | + foreach ($bucket as $field => $value) { |
|
| 32 | 32 | $values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field)); |
| 33 | 33 | } |
| 34 | 34 | $parts[] = sprintf("SELECT %s", implode(', ', $values)); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | - $name = '(' . implode("\n\tUNION ALL\n\t", $parts) . ')'; |
|
| 37 | + $name = '('.implode("\n\tUNION ALL\n\t", $parts).')'; |
|
| 38 | 38 | } |
| 39 | - if((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) { |
|
| 39 | + if ((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) { |
|
| 40 | 40 | $select = (string) $this->db()->getVirtualTables()->get($name); |
| 41 | 41 | $name = sprintf('(%s)', implode("\n\t", explode("\n", trim($select)))); |
| 42 | 42 | } |
| 43 | 43 | $name = $this->aliasReplacer()->replace((string) $name); |
| 44 | - if($alias !== null) { |
|
| 44 | + if ($alias !== null) { |
|
| 45 | 45 | return sprintf("%s %s", $name, $alias); |
| 46 | 46 | } |
| 47 | 47 | return $name; |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | * @param null|string|Select $table |
| 29 | 29 | * @return $this |
| 30 | 30 | */ |
| 31 | - public function from(string $alias, null|string|Select $table = null) { |
|
| 32 | - if($table !== null) { |
|
| 31 | + public function from(string $alias, null | string | Select $table = null) { |
|
| 32 | + if ($table !== null) { |
|
| 33 | 33 | $this->aliases[] = $alias; |
| 34 | 34 | } |
| 35 | - if($table === null) { |
|
| 35 | + if ($table === null) { |
|
| 36 | 36 | [$alias, $table] = [$table, $alias]; |
| 37 | 37 | } |
| 38 | 38 | $this->addTable($alias, $table); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function __toString(): string { |
| 52 | 52 | $query = 'DELETE '; |
| 53 | 53 | $query .= implode(', ', $this->aliases); |
| 54 | - $query = trim($query) . " FROM\n"; |
|
| 54 | + $query = trim($query)." FROM\n"; |
|
| 55 | 55 | $query = $this->buildTables($query); |
| 56 | 56 | $query = $this->buildJoins($query); |
| 57 | 57 | $query = $this->buildWhereConditions($query); |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | $this->keyPath = $this->buildKey($keyPath); |
| 31 | 31 | $this->value = RecursiveStructureAccess::recursiveGet($data, $this->keyPath, null); |
| 32 | 32 | $this->hasValue = is_scalar($this->value) ? trim((string) $this->value) !== '' : !empty($this->value); |
| 33 | - if($validator === null) { |
|
| 33 | + if ($validator === null) { |
|
| 34 | 34 | $validator = static fn() => true; |
| 35 | 35 | } |
| 36 | 36 | $this->validator = $validator; |
| 37 | - if($validationResultHandler === null) { |
|
| 38 | - $validationResultHandler = static function () {}; |
|
| 37 | + if ($validationResultHandler === null) { |
|
| 38 | + $validationResultHandler = static function() {}; |
|
| 39 | 39 | } |
| 40 | 40 | $this->validationResultHandler = $validationResultHandler; |
| 41 | 41 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | * @return bool |
| 52 | 52 | */ |
| 53 | 53 | public function isValid(): bool { |
| 54 | - if(!$this->hasValue) { |
|
| 54 | + if (!$this->hasValue) { |
|
| 55 | 55 | return false; |
| 56 | 56 | } |
| 57 | - if($this->validator !== null) { |
|
| 57 | + if ($this->validator !== null) { |
|
| 58 | 58 | $result = call_user_func($this->validator, $this->value); |
| 59 | 59 | call_user_func($this->validationResultHandler, $result, [ |
| 60 | 60 | 'value' => $this->value, |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | * @return string[] |
| 78 | 78 | */ |
| 79 | 79 | private function buildKey($keyPath): array { |
| 80 | - if(is_string($keyPath)) { |
|
| 80 | + if (is_string($keyPath)) { |
|
| 81 | 81 | $keyPath = explode('.', $keyPath); |
| 82 | 82 | } |
| 83 | - if(!is_array($keyPath)) { |
|
| 83 | + if (!is_array($keyPath)) { |
|
| 84 | 84 | throw new RuntimeException('Invalid key'); |
| 85 | 85 | } |
| 86 | 86 | return $keyPath; |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | * @inheritDoc |
| 102 | 102 | */ |
| 103 | 103 | public function fetchObjects(string $className = 'stdClass', $callback = null): array { |
| 104 | - return $this->createTempStatement(function (QueryStatement $statement) use ($className, $callback) { |
|
| 104 | + return $this->createTempStatement(function(QueryStatement $statement) use ($className, $callback) { |
|
| 105 | 105 | $data = $statement->fetchAll(PDO::FETCH_CLASS, $className); |
| 106 | - if($this->preserveTypes) { |
|
| 106 | + if ($this->preserveTypes) { |
|
| 107 | 107 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 108 | 108 | $data = array_map(static fn($row) => FieldValueConverter::convertValues($row, $columnDefinitions), $data); |
| 109 | 109 | } |
| 110 | - if($callback !== null) { |
|
| 111 | - return call_user_func(static function ($resultData = []) use ($data, $callback) { |
|
| 112 | - foreach($data as $row) { |
|
| 110 | + if ($callback !== null) { |
|
| 111 | + return call_user_func(static function($resultData = []) use ($data, $callback) { |
|
| 112 | + foreach ($data as $row) { |
|
| 113 | 113 | $result = $callback($row); |
| 114 | - if($result !== null && !($result instanceof DBIgnoreRow)) { |
|
| 114 | + if ($result !== null && !($result instanceof DBIgnoreRow)) { |
|
| 115 | 115 | $resultData[] = $result; |
| 116 | 116 | } else { |
| 117 | 117 | $resultData[] = $row; |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | * @inheritDoc |
| 148 | 148 | */ |
| 149 | 149 | public function fetchKeyValue($treatValueAsArray = false): array { |
| 150 | - return $this->createTempStatement(static function (QueryStatement $statement) use ($treatValueAsArray) { |
|
| 151 | - if($treatValueAsArray) { |
|
| 150 | + return $this->createTempStatement(static function(QueryStatement $statement) use ($treatValueAsArray) { |
|
| 151 | + if ($treatValueAsArray) { |
|
| 152 | 152 | $rows = $statement->fetchAll(PDO::FETCH_ASSOC); |
| 153 | 153 | $result = []; |
| 154 | - foreach($rows as $row) { |
|
| 154 | + foreach ($rows as $row) { |
|
| 155 | 155 | [$key] = array_values($row); |
| 156 | 156 | $result[$key] = $row; |
| 157 | 157 | } |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | public function fetchGroups(array $fields): array { |
| 168 | 168 | $rows = $this->fetchRows(); |
| 169 | 169 | $result = []; |
| 170 | - foreach($rows as $row) { |
|
| 170 | + foreach ($rows as $row) { |
|
| 171 | 171 | /** @var array<string, mixed> $tmp */ |
| 172 | 172 | $tmp = &$result; |
| 173 | - foreach($fields as $field) { |
|
| 173 | + foreach ($fields as $field) { |
|
| 174 | 174 | $value = (string) $row[$field]; |
| 175 | - if(!array_key_exists($value, $tmp)) { |
|
| 175 | + if (!array_key_exists($value, $tmp)) { |
|
| 176 | 176 | $tmp[$value] = []; |
| 177 | 177 | } |
| 178 | 178 | $tmp = &$tmp[$value]; |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | * @inheritDoc |
| 187 | 187 | */ |
| 188 | 188 | public function fetchArray(?callable $fn = null): array { |
| 189 | - return $this->createTempStatement(static function (QueryStatement $stmt) use ($fn) { |
|
| 190 | - if($fn !== null) { |
|
| 189 | + return $this->createTempStatement(static function(QueryStatement $stmt) use ($fn) { |
|
| 190 | + if ($fn !== null) { |
|
| 191 | 191 | return $stmt->fetchAll(PDO::FETCH_FUNC, $fn); |
| 192 | 192 | } |
| 193 | 193 | return $stmt->fetchAll(PDO::FETCH_COLUMN); |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * @inheritDoc |
| 199 | 199 | */ |
| 200 | 200 | public function fetchValue($default = null, ?callable $fn = null) { |
| 201 | - return $this->createTempStatement(static function (QueryStatement $stmt) use ($default, $fn) { |
|
| 201 | + return $this->createTempStatement(static function(QueryStatement $stmt) use ($default, $fn) { |
|
| 202 | 202 | $result = $stmt->fetchAll(PDO::FETCH_COLUMN); |
| 203 | - if($result !== false && array_key_exists(0, $result)) { |
|
| 203 | + if ($result !== false && array_key_exists(0, $result)) { |
|
| 204 | 204 | return $fn !== null ? $fn($result[0]) : $result[0]; |
| 205 | 205 | } |
| 206 | 206 | return $default; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $query = $this->__toString(); |
| 236 | 236 | $statement = $db->prepare($query); |
| 237 | 237 | $statement->execute($this->values); |
| 238 | - if($this->getCalcFoundRows()) { |
|
| 238 | + if ($this->getCalcFoundRows()) { |
|
| 239 | 239 | $this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn(); |
| 240 | 240 | } |
| 241 | 241 | return $statement; |
@@ -256,21 +256,21 @@ discard block |
||
| 256 | 256 | * @return ($callback is null ? array<int, ($mode is PDO::FETCH_NUM ? array<int, null|scalar> : array<string, null|scalar>)> : array<int, TFnReturnType>) |
| 257 | 257 | */ |
| 258 | 258 | private function fetchAll($callback = null, int $mode = 0, $arg0 = null) { |
| 259 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 259 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
| 260 | 260 | $statement->setFetchMode($mode, $arg0); |
| 261 | 261 | $data = $statement->fetchAll(); |
| 262 | - if($this->preserveTypes) { |
|
| 262 | + if ($this->preserveTypes) { |
|
| 263 | 263 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 264 | 264 | $data = array_map(static fn($row) => FieldValueConverter::convertValues($row, $columnDefinitions), $data); |
| 265 | 265 | } |
| 266 | - if($callback !== null) { |
|
| 267 | - return call_user_func(static function ($resultData = []) use ($data, $callback) { |
|
| 268 | - foreach($data as $row) { |
|
| 266 | + if ($callback !== null) { |
|
| 267 | + return call_user_func(static function($resultData = []) use ($data, $callback) { |
|
| 268 | + foreach ($data as $row) { |
|
| 269 | 269 | $result = $callback($row); |
| 270 | - if($result instanceof DBIgnoreRow) { |
|
| 270 | + if ($result instanceof DBIgnoreRow) { |
|
| 271 | 271 | continue; |
| 272 | 272 | } |
| 273 | - if($result !== null) { |
|
| 273 | + if ($result !== null) { |
|
| 274 | 274 | $resultData[] = $result; |
| 275 | 275 | } else { |
| 276 | 276 | $resultData[] = $row; |
@@ -294,18 +294,18 @@ discard block |
||
| 294 | 294 | $statement = $this->createStatement(); |
| 295 | 295 | $statement->setFetchMode($mode, $arg0); |
| 296 | 296 | try { |
| 297 | - while($row = $statement->fetch()) { |
|
| 297 | + while ($row = $statement->fetch()) { |
|
| 298 | 298 | /** @var T $row */ |
| 299 | 299 | // if($this->preserveTypes) { |
| 300 | 300 | // $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 301 | 301 | // $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 302 | 302 | // } |
| 303 | 303 | $result = $callback($row); |
| 304 | - if($result instanceof DBIgnoreRow) { |
|
| 304 | + if ($result instanceof DBIgnoreRow) { |
|
| 305 | 305 | // Skip row in this case |
| 306 | 306 | continue; |
| 307 | 307 | } |
| 308 | - if($result !== null) { |
|
| 308 | + if ($result !== null) { |
|
| 309 | 309 | yield $result; |
| 310 | 310 | } else { |
| 311 | 311 | yield $row; |
@@ -326,20 +326,20 @@ discard block |
||
| 326 | 326 | * @return T|U|array<string, mixed> |
| 327 | 327 | */ |
| 328 | 328 | private function fetch($callback, int $mode = PDO::FETCH_ASSOC, $arg0 = null, ?Closure $resultValidator = null) { |
| 329 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) { |
|
| 329 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) { |
|
| 330 | 330 | $statement->setFetchMode($mode, $arg0); |
| 331 | 331 | $row = $statement->fetch(); |
| 332 | 332 | $result = $resultValidator === null ? ['valid' => true] : $resultValidator($row); |
| 333 | - if(!$result['valid']) { |
|
| 333 | + if (!$result['valid']) { |
|
| 334 | 334 | return $result['default']; |
| 335 | 335 | } |
| 336 | - if($this->preserveTypes) { |
|
| 336 | + if ($this->preserveTypes) { |
|
| 337 | 337 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
| 338 | 338 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
| 339 | 339 | } |
| 340 | - if($callback !== null) { |
|
| 340 | + if ($callback !== null) { |
|
| 341 | 341 | $result = $callback($row); |
| 342 | - if($result !== null) { |
|
| 342 | + if ($result !== null) { |
|
| 343 | 343 | $row = $result; |
| 344 | 344 | } |
| 345 | 345 | } |
@@ -19,31 +19,31 @@ discard block |
||
| 19 | 19 | * @return string |
| 20 | 20 | */ |
| 21 | 21 | public function quote($value): string { |
| 22 | - if(is_null($value)) { |
|
| 22 | + if (is_null($value)) { |
|
| 23 | 23 | return 'NULL'; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - if(is_bool($value)) { |
|
| 26 | + if (is_bool($value)) { |
|
| 27 | 27 | return $value ? '1' : '0'; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if(is_array($value)) { |
|
| 30 | + if (is_array($value)) { |
|
| 31 | 31 | return implode(', ', array_map([$this, __FUNCTION__], $value)); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if($value instanceof DBExpr) { |
|
| 34 | + if ($value instanceof DBExpr) { |
|
| 35 | 35 | return $value->getExpression(); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if($value instanceof Select) { |
|
| 38 | + if ($value instanceof Select) { |
|
| 39 | 39 | return sprintf('(%s)', (string) $value); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if(is_int($value) || is_float($value)) { |
|
| 42 | + if (is_int($value) || is_float($value)) { |
|
| 43 | 43 | return (string) $value; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if($value instanceof DateTimeInterface) { |
|
| 46 | + if ($value instanceof DateTimeInterface) { |
|
| 47 | 47 | $value = (new DateTimeImmutable($value->format('c')))->setTimezone($this->timeZone)->format('Y-m-d H:i:s'); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function quoteExpression(string $expression, array $arguments = []): string { |
| 59 | 59 | $index = -1; |
| 60 | - $func = function () use ($arguments, &$index) { |
|
| 60 | + $func = function() use ($arguments, &$index) { |
|
| 61 | 61 | $index++; |
| 62 | - if(array_key_exists($index, $arguments)) { |
|
| 62 | + if (array_key_exists($index, $arguments)) { |
|
| 63 | 63 | $argument = $arguments[$index]; |
| 64 | 64 | $value = $this->quote($argument); |
| 65 | - } elseif(count($arguments) > 0) { |
|
| 65 | + } elseif (count($arguments) > 0) { |
|
| 66 | 66 | $args = $arguments; |
| 67 | 67 | $value = array_pop($args); |
| 68 | 68 | $value = $this->quote($value); |