Skip to content

Commit

Permalink
Use short list syntax and single line arrays
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed May 26, 2020
1 parent 91bf091 commit 3ae05c7
Show file tree
Hide file tree
Showing 103 changed files with 318 additions and 661 deletions.
2 changes: 1 addition & 1 deletion examples/openid.php
Expand Up @@ -145,7 +145,7 @@ function Die_error($e)
} else {
/* Grab query string */
if (! count($_POST)) {
list(, $queryString) = explode('?', $_SERVER['REQUEST_URI']);
[, $queryString] = explode('?', $_SERVER['REQUEST_URI']);
} else {
// I hate php sometimes
$queryString = file_get_contents('php://input');
Expand Down
18 changes: 9 additions & 9 deletions libraries/classes/BrowseForeigners.php
Expand Up @@ -87,18 +87,18 @@ private function getHtmlForOneKey(
// key names and descriptions for the left section,
// sorted by key names
$leftKeyname = $keys[$indexByKeyname];
list(
[
$leftDescription,
$leftDescriptionTitle
) = $this->getDescriptionAndTitle($descriptions[$indexByKeyname]);
$leftDescriptionTitle,
] = $this->getDescriptionAndTitle($descriptions[$indexByKeyname]);

// key names and descriptions for the right section,
// sorted by descriptions
$rightKeyname = $keys[$indexByDescription];
list(
[
$rightDescription,
$rightDescriptionTitle
) = $this->getDescriptionAndTitle($descriptions[$indexByDescription]);
$rightDescriptionTitle,
] = $this->getDescriptionAndTitle($descriptions[$indexByDescription]);

$indexByDescription++;

Expand Down Expand Up @@ -245,11 +245,11 @@ public function getHtmlForRelationalFieldSelection(
$indexByDescription = 0;

foreach ($keys as $indexByKeyname => $value) {
list(
[
$html,
$horizontal_count,
$indexByDescription
) = $this->getHtmlForOneKey(
$indexByDescription,
] = $this->getHtmlForOneKey(
$horizontal_count,
$header,
$keys,
Expand Down
8 changes: 2 additions & 6 deletions libraries/classes/CentralColumns.php
Expand Up @@ -741,9 +741,7 @@ public function updateMultipleColumn(array $params)
*/
private function getEditTableHeader(array $headers): string
{
return $this->template->render('database/central_columns/edit_table_header', [
'headers' => $headers,
]);
return $this->template->render('database/central_columns/edit_table_header', ['headers' => $headers]);
}

/**
Expand All @@ -768,9 +766,7 @@ private function getHtmlForEditTableRow(array $row, int $row_num): string
'column_meta' => [
'Field' => $row['col_name'],
],
'cfg_relation' => [
'centralcolumnswork' => false,
],
'cfg_relation' => ['centralcolumnswork' => false],
'max_rows' => $this->maxRows,
])
. '</td>';
Expand Down
8 changes: 4 additions & 4 deletions libraries/classes/CheckUserPrivileges.php
Expand Up @@ -218,11 +218,11 @@ private function analyseShowGrant(): void
$re1 = '(^|[^\\\\])(\\\)+'; // escaped wildcards

while ($row = $this->dbi->fetchRow($rs_usr)) {
list(
[
$show_grants_str,
$show_grants_dbname,
$show_grants_tblname
) = $this->getItemsFromShowGrantsRow($row[0]);
$show_grants_tblname,
] = $this->getItemsFromShowGrantsRow($row[0]);

if ($show_grants_dbname == '*') {
if ($show_grants_str != 'USAGE') {
Expand Down Expand Up @@ -339,7 +339,7 @@ public function getPrivileges(): void

$current = $this->dbi->getCurrentUserAndHost();
if (! empty($current)) {
list($username, ) = $current;
[$username] = $current;
}

// If MySQL is started with --skip-grant-tables
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Common.php
Expand Up @@ -129,7 +129,7 @@ public static function database(): void
if (isset($_POST['change_all_tables_collations']) &&
$_POST['change_all_tables_collations'] === 'on'
) {
list($tables, , , , , , , ,) = Util::getDbInfo($db, null);
[$tables] = Util::getDbInfo($db, null);
foreach ($tables as $tableName => $data) {
if ($dbi->getTable($db, $tableName)->isView()) {
// Skip views, we can not change the collation of a view.
Expand Down
4 changes: 1 addition & 3 deletions libraries/classes/Config/FormDisplayTemplate.php
Expand Up @@ -486,9 +486,7 @@ public function displayJavascript(array $jsArray): string
return '';
}

return $this->template->render('javascript/display', [
'js_array' => $jsArray,
]);
return $this->template->render('javascript/display', ['js_array' => $jsArray]);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions libraries/classes/Config/Forms/User/ExportForm.php
Expand Up @@ -75,9 +75,7 @@ public static function getForms()
'Export/sql_hex_for_binary',
'Export/sql_utc_time',
],
'CodeGen' => [
'Export/codegen_format',
],
'CodeGen' => ['Export/codegen_format'],
'Csv' => [
':group:' . __('CSV'),
'Export/csv_separator',
Expand Down
4 changes: 1 addition & 3 deletions libraries/classes/Config/Forms/User/FeaturesForm.php
Expand Up @@ -73,9 +73,7 @@ public static function getForms()
];
// skip Developer form if no setting is available
if ($GLOBALS['cfg']['UserprefsDeveloperTab']) {
$result['Developer'] = [
'DBG/sql',
];
$result['Developer'] = ['DBG/sql'];
}

return $result;
Expand Down
4 changes: 1 addition & 3 deletions libraries/classes/Config/Forms/User/MainForm.php
Expand Up @@ -76,9 +76,7 @@ public static function getForms()
'DefaultTabDatabase',
'DefaultTabTable',
],
'DisplayRelationalSchema' => [
'PDFDefaultPageSize',
],
'DisplayRelationalSchema' => ['PDFDefaultPageSize'],
];
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/classes/Config/ServerConfigChecks.php
Expand Up @@ -51,7 +51,7 @@ public function performConfigChecks()
$blowfishSecretSet = false;
$cookieAuthUsed = false;

list($cookieAuthUsed, $blowfishSecret, $blowfishSecretSet)
[$cookieAuthUsed, $blowfishSecret, $blowfishSecretSet]
= $this->performConfigChecksServers(
$cookieAuthUsed,
$blowfishSecret,
Expand Down Expand Up @@ -149,7 +149,7 @@ protected function performConfigChecksServers(
);
$serverName = htmlspecialchars($serverName);

list($blowfishSecret, $blowfishSecretSet)
[$blowfishSecret, $blowfishSecretSet]
= $this->performConfigChecksServersSetBlowfishSecret(
$blowfishSecret,
$cookieAuthServer,
Expand Down
Expand Up @@ -60,11 +60,11 @@ public function index(): void
$tableName
)->getStatusInfo('TABLE_COMMENT');

list(, $primaryKeys, , ) = Util::processIndexData(
[, $primaryKeys] = Util::processIndexData(
$this->dbi->getTableIndexes($this->db, $tableName)
);

list($foreigners, $hasRelation) = $this->relation->getRelationsAndStatus(
[$foreigners, $hasRelation] = $this->relation->getRelationsAndStatus(
! empty($cfgRelation['relation']),
$this->db,
$tableName
Expand Down
10 changes: 5 additions & 5 deletions libraries/classes/Controllers/Database/DesignerController.php
Expand Up @@ -127,7 +127,7 @@ public function index(): void
$this->response->setRequestStatus($success);
$this->response->addJSON('message', $message);
} elseif ($_POST['operation'] == 'addNewRelation') {
list($success, $message) = $this->designerCommon->addNewRelation(
[$success, $message] = $this->designerCommon->addNewRelation(
$_POST['db'],
$_POST['T1'],
$_POST['F1'],
Expand All @@ -141,7 +141,7 @@ public function index(): void
$this->response->setRequestStatus($success);
$this->response->addJSON('message', $message);
} elseif ($_POST['operation'] == 'removeRelation') {
list($success, $message) = $this->designerCommon->removeRelation(
[$success, $message] = $this->designerCommon->removeRelation(
$_POST['T1'],
$_POST['F1'],
$_POST['T2'],
Expand Down Expand Up @@ -217,7 +217,7 @@ public function index(): void
$scripts->addFile('designer/move.js');
$scripts->addFile('designer/init.js');

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -226,8 +226,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');

// Embed some data into HTML, later it will be read
// by designer/init.js and converted to JS variables.
Expand Down
6 changes: 3 additions & 3 deletions libraries/classes/Controllers/Database/EventsController.php
Expand Up @@ -39,7 +39,7 @@ public function index(): void
if (! $this->response->isAjax()) {
Common::database();

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -48,8 +48,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');
} elseif (strlen($db) > 0) {
$this->dbi->selectDb($db);
$url_query = $url_query ?? Url::getCommon(['db' => $db]);
Expand Down
6 changes: 3 additions & 3 deletions libraries/classes/Controllers/Database/ExportController.php
Expand Up @@ -57,7 +57,7 @@ public function index(): void
$url_params['goto'] = Url::getFromRoute('/database/export');
$url_query .= Url::getCommon($url_params, '&');

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -66,8 +66,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');

/**
* Displays the form
Expand Down
6 changes: 3 additions & 3 deletions libraries/classes/Controllers/Database/ImportController.php
Expand Up @@ -27,7 +27,7 @@ public function index(): void
*/
Common::database();

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -36,8 +36,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');

$this->response->addHTML(
Import::get(
Expand Down
Expand Up @@ -134,7 +134,7 @@ public function index(): void
$url_params['goto'] = Url::getFromRoute('/database/qbe');
$url_query .= Url::getCommon($url_params, '&');

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -143,8 +143,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');

$databaseQbe = new Qbe($this->relation, $this->template, $this->dbi, $db, $savedSearchList, $savedSearch);

Expand Down
6 changes: 3 additions & 3 deletions libraries/classes/Controllers/Database/RoutinesController.php
Expand Up @@ -59,7 +59,7 @@ public function index(): void
$table = '';
Common::database();

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -68,8 +68,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');
}
} else {
/**
Expand Down
Expand Up @@ -503,7 +503,7 @@ public function multiSubmitAction(): void
} elseif (strlen($db) > 0) {
Common::database();

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -512,8 +512,8 @@ public function multiSubmitAction(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');
} else {
Common::server();
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/classes/Controllers/Database/TriggersController.php
Expand Up @@ -35,7 +35,7 @@ public function index(): void
$table = '';
Common::database();

list(
[
$tables,
$num_tables,
$total_num_tables,
Expand All @@ -44,8 +44,8 @@ public function index(): void
$db_is_system_schema,
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, $sub_part ?? '');
$pos,
] = Util::getDbInfo($db, $sub_part ?? '');
}
} else {
/**
Expand Down
10 changes: 4 additions & 6 deletions libraries/classes/Controllers/ExportController.php
Expand Up @@ -336,9 +336,7 @@ public function index(): void
'table' => $table,
]);
} elseif ($export_type === 'raw') {
$err_url = Url::getFromRoute('/server/export', [
'sql_query' => $sql_query,
]);
$err_url = Url::getFromRoute('/server/export', ['sql_query' => $sql_query]);
} else {
Core::fatalError(__('Bad parameters!'));
}
Expand Down Expand Up @@ -403,7 +401,7 @@ public function index(): void
if (empty($remember_template)) {
$remember_template = '';
}
list($filename, $mime_type) = $this->export->getFilenameAndMimetype(
[$filename, $mime_type] = $this->export->getFilenameAndMimetype(
$export_type,
$remember_template,
$export_plugin,
Expand All @@ -425,7 +423,7 @@ public function index(): void

// Open file on server if needed
if ($save_on_server) {
list($save_filename, $message, $file_handle) = $this->export->openFile(
[$save_filename, $message, $file_handle] = $this->export->openFile(
$filename,
$quick_export
);
Expand Down Expand Up @@ -462,7 +460,7 @@ public function index(): void
exit;
}
}
list($html, $back_button, $refreshButton) = $this->export->getHtmlForDisplayedExportHeader(
[$html, $back_button, $refreshButton] = $this->export->getHtmlForDisplayedExportHeader(
$export_type,
$db,
$table
Expand Down

0 comments on commit 3ae05c7

Please sign in to comment.