@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | /** |
| 113 | 113 | * @inheritDoc |
| 114 | 114 | */ |
| 115 | - public function createConnection(array $options): AbstractConnection|null |
|
| 115 | + public function createConnection(array $options): AbstractConnection | null |
|
| 116 | 116 | { |
| 117 | 117 | return $this->driver->createConnection($options); |
| 118 | 118 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @inheritDoc |
| 164 | 164 | */ |
| 165 | - public function execute(string $query): StatementInterface|bool |
|
| 165 | + public function execute(string $query): StatementInterface | bool |
|
| 166 | 166 | { |
| 167 | 167 | $result = $this->driver->execute($query); |
| 168 | 168 | // Call the query callbacks. |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | // From edit.inc.php |
| 64 | 64 | $fields = $this->driver->fields($table); |
| 65 | 65 | // Important: get the where clauses before filtering the fields. |
| 66 | - $where = $this->operation === 'insert' ? [] : |
|
| 67 | - $this->driver->where($options, $fields); |
|
| 66 | + $where = $this->operation === 'insert' ? [] : $this->driver->where($options, $fields); |
|
| 68 | 67 | // Remove fields without the required privilege, or that cannot be edited. |
| 69 | 68 | $fields = array_filter($fields, fn(TableFieldEntity $field) => |
| 70 | 69 | isset($field->privileges[$this->operation]) && |
@@ -86,7 +85,7 @@ discard block |
||
| 86 | 85 | $this->action = 'read'; |
| 87 | 86 | $this->operation = 'insert'; |
| 88 | 87 | |
| 89 | - [$fields,] = $this->getFields($table, $options); |
|
| 88 | + [$fields, ] = $this->getFields($table, $options); |
|
| 90 | 89 | if (empty($fields)) { |
| 91 | 90 | return [ |
| 92 | 91 | 'error' => $this->utils->trans->lang('You have no privileges to update this table.'), |
@@ -114,8 +113,7 @@ discard block |
||
| 114 | 113 | $select = []; |
| 115 | 114 | foreach ($fields as $name => $field) { |
| 116 | 115 | if (isset($field->privileges["select"])) { |
| 117 | - $as = $this->action === 'clone' && $field->autoIncrement ? "''" : |
|
| 118 | - $this->driver->convertField($field); |
|
| 116 | + $as = $this->action === 'clone' && $field->autoIncrement ? "''" : $this->driver->convertField($field); |
|
| 119 | 117 | $select[] = ($as ? "$as AS " : "") . $this->driver->escapeId($name); |
| 120 | 118 | } |
| 121 | 119 | } |
@@ -160,7 +158,7 @@ discard block |
||
| 160 | 158 | } |
| 161 | 159 | |
| 162 | 160 | $rowData = $statement->fetchAssoc(); |
| 163 | - if($this->action === 'select' && (!$rowData || $statement->fetchAssoc())) |
|
| 161 | + if ($this->action === 'select' && (!$rowData || $statement->fetchAssoc())) |
|
| 164 | 162 | { |
| 165 | 163 | // $statement->rowCount() != 1 isn't available in all drivers |
| 166 | 164 | return [ |
@@ -187,7 +185,7 @@ discard block |
||
| 187 | 185 | $this->action = 'save'; |
| 188 | 186 | $this->operation = 'insert'; |
| 189 | 187 | |
| 190 | - [$fields,] = $this->getFields($table, $options); |
|
| 188 | + [$fields, ] = $this->getFields($table, $options); |
|
| 191 | 189 | $values = $this->reader()->getInputValues($fields, $values); |
| 192 | 190 | |
| 193 | 191 | if (!$this->driver->insert($table, $values)) { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param QueryLogger|null $queryLogger |
| 48 | 48 | */ |
| 49 | 49 | public function __construct(AbstractFacade $dbFacade, |
| 50 | - protected TimerService $timer, protected QueryLogger|null $queryLogger) |
|
| 50 | + protected TimerService $timer, protected QueryLogger | null $queryLogger) |
|
| 51 | 51 | { |
| 52 | 52 | parent::__construct($dbFacade); |
| 53 | 53 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | ini_set('memory_limit', max($this->utils->iniBytes('memory_limit'), |
| 232 | 232 | 2 * strlen($queries) + memory_get_usage() + 8e6)); |
| 233 | 233 | } |
| 234 | - catch(\Exception $e) { |
|
| 234 | + catch (\Exception $e) { |
|
| 235 | 235 | // Do nothing if the option is not modified. |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | if ($commands === 0) { |
| 259 | 259 | $messages[] = $this->utils->trans->lang('No commands to execute.'); |
| 260 | 260 | } elseif ($onlyErrors) { |
| 261 | - $messages[] = $this->utils->trans->lang('%d query(s) executed OK.', $commands - $errors); |
|
| 261 | + $messages[] = $this->utils->trans->lang('%d query(s) executed OK.', $commands - $errors); |
|
| 262 | 262 | } |
| 263 | 263 | return [ |
| 264 | 264 | 'results' => $this->results, |
@@ -230,8 +230,7 @@ |
||
| 230 | 230 | try { |
| 231 | 231 | ini_set('memory_limit', max($this->utils->iniBytes('memory_limit'), |
| 232 | 232 | 2 * strlen($queries) + memory_get_usage() + 8e6)); |
| 233 | - } |
|
| 234 | - catch(\Exception $e) { |
|
| 233 | + } catch(\Exception $e) { |
|
| 235 | 234 | // Do nothing if the option is not modified. |
| 236 | 235 | } |
| 237 | 236 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @var SelectEntity|null |
| 36 | 36 | */ |
| 37 | - private SelectEntity|null $selectEntity = null; |
|
| 37 | + private SelectEntity | null $selectEntity = null; |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @param AbstractFacade $dbFacade |
@@ -117,11 +117,9 @@ discard block |
||
| 117 | 117 | $value = $this->selectEntity->queryOptions["columns"][$valueKey] ?? []; |
| 118 | 118 | |
| 119 | 119 | $fun = $value["fun"] ?? ''; |
| 120 | - $fieldKey = !$this->selectEntity->select ? $key : |
|
| 121 | - ($value["col"] ?? current($this->selectEntity->select)); |
|
| 120 | + $fieldKey = !$this->selectEntity->select ? $key : ($value["col"] ?? current($this->selectEntity->select)); |
|
| 122 | 121 | $field = $this->selectEntity->fields[$fieldKey]; |
| 123 | - $name = !$field ? ($fun ? "*" : $key) : |
|
| 124 | - $this->page->fieldName($field, $rank); |
|
| 122 | + $name = !$field ? ($fun ? "*" : $key) : $this->page->fieldName($field, $rank); |
|
| 125 | 123 | |
| 126 | 124 | return [$fun, $name, $field]; |
| 127 | 125 | } |
@@ -247,8 +245,7 @@ discard block |
||
| 247 | 245 | private function getRowIdMd5Key(string $key, string $collation): string |
| 248 | 246 | { |
| 249 | 247 | return $this->driver->jush() != 'sql' || |
| 250 | - preg_match("~^utf8~", $collation) ? $key : |
|
| 251 | - "CONVERT($key USING " . $this->driver->charset() . ")"; |
|
| 248 | + preg_match("~^utf8~", $collation) ? $key : "CONVERT($key USING " . $this->driver->charset() . ")"; |
|
| 252 | 249 | } |
| 253 | 250 | |
| 254 | 251 | /** |
@@ -357,8 +354,8 @@ discard block |
||
| 357 | 354 | $query = $this->driver->getRowCountQuery($table, |
| 358 | 355 | $this->selectEntity->where, $this->hasGroupsInFields(), |
| 359 | 356 | $this->selectEntity->group); |
| 360 | - return (int)$this->driver->result($query); |
|
| 361 | - } catch(Exception $_) { |
|
| 357 | + return (int) $this->driver->result($query); |
|
| 358 | + } catch (Exception $_) { |
|
| 362 | 359 | return -1; |
| 363 | 360 | } |
| 364 | 361 | } |
@@ -126,8 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | $foreignKey = $this->foreignKeys[$field->type] ?? null; |
| 128 | 128 | //! Can collide with user defined type |
| 129 | - $typeField = ($foreignKey === null ? $field : |
|
| 130 | - TableFieldEntity::make($this->referencableTables[$foreignKey])); |
|
| 129 | + $typeField = ($foreignKey === null ? $field : TableFieldEntity::make($this->referencableTables[$foreignKey])); |
|
| 131 | 130 | $processedField = $this->driver->processField($field, $typeField); |
| 132 | 131 | $origField = $this->fields[$field->name] ?? null; |
| 133 | 132 | $this->after = ''; |
@@ -374,14 +373,14 @@ discard block |
||
| 374 | 373 | $target .= '<b>' . $this->utils->str->html($foreignKey->schema) . '</b>.'; |
| 375 | 374 | } |
| 376 | 375 | $target = $this->utils->str->html($foreignKey->table) . |
| 377 | - '(' . implode(', ', array_map(function ($key) { |
|
| 376 | + '(' . implode(', ', array_map(function($key) { |
|
| 378 | 377 | return $this->utils->str->html($key); |
| 379 | 378 | }, $foreignKey->target)) . ')'; |
| 380 | 379 | $details[] = [ |
| 381 | 380 | 'name' => $this->utils->str->html($name), |
| 382 | 381 | 'source' => '<i>' . implode( |
| 383 | 382 | '</i>, <i>', |
| 384 | - array_map(function ($key) { |
|
| 383 | + array_map(function($key) { |
|
| 385 | 384 | return $this->utils->str->html($key); |
| 386 | 385 | }, $foreignKey->source) |
| 387 | 386 | ) . '</i>', |
@@ -144,8 +144,7 @@ discard block |
||
| 144 | 144 | $key = $this->driver->escapeId($field->name()); |
| 145 | 145 | $values[] = "$key = VALUES($key)"; |
| 146 | 146 | } |
| 147 | - $dump->suffix = $this->options['data_style'] !== 'INSERT+UPDATE' ? ';' : |
|
| 148 | - "\nON DUPLICATE KEY UPDATE " . implode(', ', $values) . ';'; |
|
| 147 | + $dump->suffix = $this->options['data_style'] !== 'INSERT+UPDATE' ? ';' : "\nON DUPLICATE KEY UPDATE " . implode(', ', $values) . ';'; |
|
| 149 | 148 | |
| 150 | 149 | return $keys; |
| 151 | 150 | } |
@@ -171,7 +170,7 @@ discard block |
||
| 171 | 170 | |
| 172 | 171 | if ($dump->insert === '') { |
| 173 | 172 | $dump->insert = 'INSERT INTO ' . $this->driver->escapeTableName($dump->table) . ' (' . |
| 174 | - implode(', ', array_map(function ($key) { |
|
| 173 | + implode(', ', array_map(function($key) { |
|
| 175 | 174 | return $this->driver->escapeId($key); |
| 176 | 175 | }, $keys)) . ') VALUES'; |
| 177 | 176 | } |
@@ -197,8 +196,7 @@ discard block |
||
| 197 | 196 | $fields = $this->options['format'] !== 'sql' ? [] : $this->driver->fields($dump->table); |
| 198 | 197 | $keys = []; |
| 199 | 198 | $fetchFunction = $dump->table !== '' ? |
| 200 | - fn($statement) => $statement->fetchAssoc() : |
|
| 201 | - fn($statement) => $statement->fetchRow(); |
|
| 199 | + fn($statement) => $statement->fetchAssoc() : fn($statement) => $statement->fetchRow(); |
|
| 202 | 200 | while ($row = $fetchFunction($statement)) { |
| 203 | 201 | if (empty($keys)) { |
| 204 | 202 | $keys = $this->getDataRowKeys($dump, $row, $statement); |
@@ -467,12 +465,10 @@ discard block |
||
| 467 | 465 | // From dump.inc.php create_routine() |
| 468 | 466 | $routineName = $this->driver->escapeId(trim($routine->name)); |
| 469 | 467 | $routineParams = $this->getRoutineParams($routineInfo->params); |
| 470 | - $routineReturns = $routine->type !== 'FUNCTION' ? '' : |
|
| 471 | - ' RETURNS' . $this->driver->processType($routineInfo->return, 'CHARACTER SET'); |
|
| 468 | + $routineReturns = $routine->type !== 'FUNCTION' ? '' : ' RETURNS' . $this->driver->processType($routineInfo->return, 'CHARACTER SET'); |
|
| 472 | 469 | $routineLanguage = $routineInfo->language ? " LANGUAGE {$routineInfo->language}" : ''; |
| 473 | 470 | $definition = rtrim($routineInfo->definition, ';'); |
| 474 | - $routineDefinition = $this->driver->jush() !== 'pgsql' ? "\n$definition;" : |
|
| 475 | - ' AS ' . $this->driver->quote($definition); |
|
| 471 | + $routineDefinition = $this->driver->jush() !== 'pgsql' ? "\n$definition;" : ' AS ' . $this->driver->quote($definition); |
|
| 476 | 472 | |
| 477 | 473 | return "CREATE {$routine->type} $routineName ($routineParams)" . |
| 478 | 474 | "{$routineReturns}{$routineLanguage}{$routineDefinition};"; |
@@ -638,7 +634,7 @@ discard block |
||
| 638 | 634 | * |
| 639 | 635 | * @return array|string |
| 640 | 636 | */ |
| 641 | - public function exportDatabases(array $databases, array $options): array|string |
|
| 637 | + public function exportDatabases(array $databases, array $options): array | string |
|
| 642 | 638 | { |
| 643 | 639 | // From dump.inc.php |
| 644 | 640 | // $tables = array_flip($options['tables']) + array_flip($options['data']); |
@@ -279,8 +279,7 @@ |
||
| 279 | 279 | foreach ($databases as $database => $tables) { |
| 280 | 280 | try { |
| 281 | 281 | $this->dumpDatabase($database, $tables); |
| 282 | - } |
|
| 283 | - catch (Exception $e) { |
|
| 282 | + } catch (Exception $e) { |
|
| 284 | 283 | return $e->getMessage(); |
| 285 | 284 | } |
| 286 | 285 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * @var AppDriver|null |
| 16 | 16 | */ |
| 17 | - protected AppDriver|null $driver = null; |
|
| 17 | + protected AppDriver | null $driver = null; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @var AppPage |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | return [ |
| 27 | 27 | 'select' => $select, |
| 28 | - 'values' => (array)$options["columns"], |
|
| 28 | + 'values' => (array) $options["columns"], |
|
| 29 | 29 | 'columns' => $columns, |
| 30 | 30 | 'functions' => $this->driver->functions(), |
| 31 | 31 | 'grouping' => $this->driver->grouping(), |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | return [ |
| 51 | 51 | // 'where' => $where, |
| 52 | - 'values' => (array)$options["where"], |
|
| 52 | + 'values' => (array) $options["where"], |
|
| 53 | 53 | 'columns' => $columns, |
| 54 | 54 | 'indexes' => $indexes, |
| 55 | 55 | 'operators' => $this->driver->operators(), |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | private function getSortingOptions(array $columns, array $options): array |
| 69 | 69 | { |
| 70 | 70 | $values = []; |
| 71 | - $descs = (array)$options["desc"]; |
|
| 72 | - foreach ((array)$options["order"] as $key => $value) { |
|
| 71 | + $descs = (array) $options["desc"]; |
|
| 72 | + foreach ((array) $options["order"] as $key => $value) { |
|
| 73 | 73 | $values[] = [ |
| 74 | 74 | 'col' => $value, |
| 75 | 75 | 'desc' => $descs[$key] ?? 0, |
@@ -203,7 +203,7 @@ |
||
| 203 | 203 | $editField->fullType = $this->utils->str->html($field->fullType); |
| 204 | 204 | |
| 205 | 205 | if (is_array($editField->value) && !$editField->function) { |
| 206 | - // 128 - JSON_PRETTY_PRINT, 64 - JSON_UNESCAPED_SLASHES, 256 - JSON_UNESCAPED_UNICODE available since PHP 5.4 |
|
| 206 | + // 128 - JSON_PRETTY_PRINT, 64 - JSON_UNESCAPED_SLASHES, 256 - JSON_UNESCAPED_UNICODE available since PHP 5.4 |
|
| 207 | 207 | $editField->value = json_encode($editField->value, |
| 208 | 208 | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
| 209 | 209 | $editField->function = 'json'; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return mixed |
| 114 | 114 | */ |
| 115 | - private function getFieldDefaultValue(TableFieldEntity $field, array|null $rowData): mixed |
|
| 115 | + private function getFieldDefaultValue(TableFieldEntity $field, array | null $rowData): mixed |
|
| 116 | 116 | { |
| 117 | 117 | $update = $this->operation === 'update'; |
| 118 | 118 | // $default = $options["set"][$this->driver->bracketEscape($name)] ?? null; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return array |
| 152 | 152 | */ |
| 153 | - private function getInputValues(TableFieldEntity $field, array|null $rowData): array |
|
| 153 | + private function getInputValues(TableFieldEntity $field, array | null $rowData): array |
|
| 154 | 154 | { |
| 155 | 155 | $value = $this->getFieldDefaultValue($field, $rowData); |
| 156 | 156 | // if (!$this->action !== 'save' && is_string($value)) { |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return FieldEditEntity |
| 193 | 193 | */ |
| 194 | - public function getFieldInputValues(TableFieldEntity $field, array|null $rowData): FieldEditEntity |
|
| 194 | + public function getFieldInputValues(TableFieldEntity $field, array | null $rowData): FieldEditEntity |
|
| 195 | 195 | { |
| 196 | 196 | $editField = new FieldEditEntity($field); |
| 197 | 197 | |