diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0509e845aa..47e5c54072 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -327,12 +327,6 @@ parameters: count: 2 path: src/BrowseForeigners.php - - - message: '#^Parameter \#1 \$description of method PhpMyAdmin\\BrowseForeigners\:\:getDescriptionAndTitle\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 2 - path: src/BrowseForeigners.php - - message: '#^Parameter \#1 \$state of static method PhpMyAdmin\\Charsets\\Charset\:\:fromServer\(\) expects array\{Charset\?\: string, Description\?\: string, Default collation\?\: string, Maxlen\?\: string\}, array\ given\.$#' identifier: argument.type @@ -402,42 +396,6 @@ parameters: count: 1 path: src/Command/FixPoTwigCommand.php - - - message: '#^Cannot access offset ''exception'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Command/TwigLintCommand.php - - - - message: '#^Cannot access offset ''file'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 2 - path: src/Command/TwigLintCommand.php - - - - message: '#^Cannot access offset ''template'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Command/TwigLintCommand.php - - - - message: '#^Cannot access offset ''valid'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 2 - path: src/Command/TwigLintCommand.php - - - - message: '#^Only booleans are allowed in &&, mixed given on the left side\.$#' - identifier: booleanAnd.leftNotBoolean - count: 1 - path: src/Command/TwigLintCommand.php - - - - message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' - identifier: booleanNot.exprNotBoolean - count: 1 - path: src/Command/TwigLintCommand.php - - message: '#^Only booleans are allowed in a ternary operator condition, \(callable\)\|null given\.$#' identifier: ternary.condNotBoolean @@ -445,7 +403,7 @@ parameters: path: src/Command/TwigLintCommand.php - - message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#' + message: '#^Only booleans are allowed in a ternary operator condition, string given\.$#' identifier: ternary.condNotBoolean count: 1 path: src/Command/TwigLintCommand.php @@ -462,30 +420,6 @@ parameters: count: 1 path: src/Command/TwigLintCommand.php - - - message: '#^Parameter \#2 \$template of method PhpMyAdmin\\Command\\TwigLintCommand\:\:renderException\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Command/TwigLintCommand.php - - - - message: '#^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Command/TwigLintCommand.php - - - - message: '#^Parameter \#3 \$exception of method PhpMyAdmin\\Command\\TwigLintCommand\:\:renderException\(\) expects Twig\\Error\\Error, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Command/TwigLintCommand.php - - - - message: '#^Parameter \#4 \$file of method PhpMyAdmin\\Command\\TwigLintCommand\:\:renderException\(\) expects string\|null, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Command/TwigLintCommand.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\: @@ -1815,12 +1749,6 @@ parameters: count: 4 path: src/ConfigStorage/UserGroups.php - - - message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 1 - path: src/ConfigStorage/UserGroups.php - - message: '#^Only booleans are allowed in &&, int\|string given on the right side\.$#' identifier: booleanAnd.rightNotBoolean @@ -1893,12 +1821,6 @@ parameters: count: 1 path: src/Controllers/Database/DataDictionaryController.php - - - message: '#^Cannot access offset string on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Controllers/Database/DataDictionaryController.php - - message: '#^Binary operation "\." between mixed and ''\.'' results in an error\.$#' identifier: binaryOp.invalid @@ -7047,12 +6969,6 @@ parameters: count: 2 path: src/Export/Export.php - - - message: '#^Binary operation "\.\=" between mixed and non\-empty\-string results in an error\.$#' - identifier: assignOp.invalid - count: 1 - path: src/Export/Export.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: @@ -7341,10 +7257,16 @@ parameters: count: 1 path: src/File.php + - + message: '#^Cannot access offset ''error'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: src/File.php + - message: '#^Cannot access offset ''multi_edit'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible - count: 7 + count: 4 path: src/File.php - @@ -7353,10 +7275,16 @@ parameters: count: 1 path: src/File.php + - + message: '#^Cannot access offset ''tmp_name'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: src/File.php + - message: '#^Cannot access offset string on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible - count: 13 + count: 7 path: src/File.php - @@ -7407,12 +7335,6 @@ parameters: count: 1 path: src/File.php - - - message: '#^Parameter \#1 \$file of method PhpMyAdmin\\File\:\:fetchUploadedFromTblChangeRequestMultiple\(\) expects array\, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/File.php - - message: '#^Parameter \#1 \$file of method PhpMyAdmin\\ZipExtension\:\:getContents\(\) expects string, string\|null given\.$#' identifier: argument.type @@ -9684,12 +9606,6 @@ parameters: count: 4 path: src/Normalization.php - - - message: '#^Binary operation "\." between "\\n" and mixed results in an error\.$#' - identifier: binaryOp.invalid - count: 1 - path: src/Operations.php - - message: '#^Binary operation "\." between '', "'' and mixed results in an error\.$#' identifier: binaryOp.invalid @@ -9798,12 +9714,6 @@ parameters: count: 8 path: src/Operations.php - - - message: '#^Parameter \#1 \$query of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:query\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Operations.php - - message: '#^Parameter \#1 \$query of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:query\(\) expects string, string\|null given\.$#' identifier: argument.type @@ -14484,12 +14394,6 @@ parameters: count: 1 path: src/Server/SysInfo/WindowsNt.php - - - message: '#^Cannot call method getMessage\(\) on mixed\.$#' - identifier: method.nonObject - count: 1 - path: src/Session.php - - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' identifier: empty.notAllowed @@ -14502,12 +14406,6 @@ parameters: count: 1 path: src/Session.php - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Session.php - - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable @@ -14724,18 +14622,6 @@ parameters: count: 1 path: src/Sql.php - - - message: '#^Cannot access property \$name on mixed\.$#' - identifier: property.nonObject - count: 1 - path: src/Sql.php - - - - message: '#^Cannot access property \$table on mixed\.$#' - identifier: property.nonObject - count: 4 - path: src/Sql.php - - message: '#^Cannot call method has\(\) on PhpMyAdmin\\SqlParser\\Components\\OptionsArray\|null\.$#' identifier: method.nonObject @@ -16146,12 +16032,6 @@ parameters: count: 1 path: src/Util.php - - - message: '#^Binary operation "\." between mixed and '', '' results in an error\.$#' - identifier: binaryOp.invalid - count: 1 - path: src/Util.php - - message: '#^Binary operation "\." between non\-empty\-string and array\\|string\|false results in an error\.$#' identifier: binaryOp.invalid @@ -16182,48 +16062,6 @@ parameters: count: 9 path: src/Util.php - - - message: '#^Cannot access offset ''Cardinality'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Util.php - - - - message: '#^Cannot access offset ''Column_name'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 3 - path: src/Util.php - - - - message: '#^Cannot access offset ''Comment'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Util.php - - - - message: '#^Cannot access offset ''Key_name'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Util.php - - - - message: '#^Cannot access offset ''Non_unique'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Util.php - - - - message: '#^Cannot access offset ''Seq_in_index'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 3 - path: src/Util.php - - - - message: '#^Cannot access offset ''Sub_part'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/Util.php - - message: '#^Cannot access offset ''table_limit_offset'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -16257,7 +16095,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 4 + count: 3 path: src/Util.php - @@ -16821,30 +16659,12 @@ parameters: count: 1 path: src/ZipExtension.php - - - message: '#^Parameter \#1 \$data of function gzcompress expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/ZipExtension.php - - message: '#^Parameter \#1 \$keys of function array_combine expects array\, array\ given\.$#' identifier: argument.type count: 1 path: src/ZipExtension.php - - - message: '#^Parameter \#1 \$string of function crc32 expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/ZipExtension.php - - - - message: '#^Parameter \#1 \$string of function strlen expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/ZipExtension.php - - message: '#^Parameter \#3 \$subject of function str_replace expects array\\|string, \(int\|string\) given\.$#' identifier: argument.type diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b118cfe56d..bcc86789da 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -71,10 +71,6 @@ - - - - foreignField]]]> @@ -129,10 +125,6 @@ - - - - - - - - - - - - - - @@ -783,6 +765,9 @@ + + + @@ -4478,7 +4463,6 @@ - dumpBufferObjects[$objectName]]]> @@ -4571,8 +4555,12 @@ compression ?? $this->detectCompression()]]> + + + + @@ -4581,25 +4569,18 @@ handle]]> - + - - - - - - - - - - - - - - - + + + + + + + + getName()]]> getName()]]> @@ -5778,7 +5759,6 @@ - @@ -5827,7 +5807,6 @@ - @@ -8523,14 +8502,7 @@ getCookie('phpMyAdmin')]]> - getMessage()]]> - - - - - - @@ -8633,11 +8605,7 @@ - - - - @@ -8649,8 +8617,6 @@ - table]]> - name]]> statement->where[0]->expr]]> @@ -9419,58 +9385,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -9711,18 +9638,10 @@ - - - - - - - - diff --git a/src/BrowseForeigners.php b/src/BrowseForeigners.php index 0b49aa8c1d..8efc9a9896 100644 --- a/src/BrowseForeigners.php +++ b/src/BrowseForeigners.php @@ -35,13 +35,13 @@ class BrowseForeigners /** * Function to get html for one relational key * - * @param int $horizontalCount the current horizontal count - * @param string $header table header - * @param mixed[] $keys all the keys - * @param int $indexByKeyname index by keyname - * @param mixed[] $descriptions descriptions - * @param int $indexByDescription index by description - * @param string $currentValue current value on the edit form + * @param int $horizontalCount the current horizontal count + * @param string $header table header + * @param mixed[] $keys all the keys + * @param int $indexByKeyname index by keyname + * @param string[] $descriptions descriptions + * @param int $indexByDescription index by description + * @param string $currentValue current value on the edit form * * @return array{string, int, int} the generated html */ diff --git a/src/Command/TwigLintCommand.php b/src/Command/TwigLintCommand.php index 47b14ef95e..3d28aad886 100644 --- a/src/Command/TwigLintCommand.php +++ b/src/Command/TwigLintCommand.php @@ -15,6 +15,7 @@ use Twig\Error\Error; use Twig\Loader\ArrayLoader; use Twig\Source; +use function array_key_exists; use function array_push; use function closedir; use function count; @@ -137,7 +138,7 @@ class TwigLintCommand extends Command return $this->display($output, $io, $filesInfo); } - /** @return mixed[] */ + /** @return array{template: string, file: string, exception?:Error}[] */ protected function getFilesInfo(string $templatesPath): array { $filesInfo = []; @@ -157,7 +158,7 @@ class TwigLintCommand extends Command return (string) file_get_contents($filePath); } - /** @return mixed[] */ + /** @return array{template: string, file: string, exception?:Error} */ private function validate(string $template, string $file): array { $twig = Template::getTwigEnvironment(null, false); @@ -175,24 +176,22 @@ class TwigLintCommand extends Command return [ 'template' => $template, 'file' => $file, - 'line' => $e->getTemplateLine(), - 'valid' => false, 'exception' => $e, ]; } - return ['template' => $template, 'file' => $file, 'valid' => true]; + return ['template' => $template, 'file' => $file]; } - /** @param mixed[] $filesInfo */ + /** @param array{template: string, file: string, exception?:Error}[] $filesInfo */ private function display(OutputInterface $output, SymfonyStyle $io, array $filesInfo): int { $errors = 0; foreach ($filesInfo as $info) { - if ($info['valid'] && $output->isVerbose()) { + if (! array_key_exists('exception', $info) && $output->isVerbose()) { $io->comment('OK' . ($info['file'] ? sprintf(' in %s', $info['file']) : '')); - } elseif (! $info['valid']) { + } elseif (array_key_exists('exception', $info)) { ++$errors; $this->renderException($io, $info['template'], $info['exception'], $info['file']); } diff --git a/src/ConfigStorage/UserGroups.php b/src/ConfigStorage/UserGroups.php index c102f3ec09..a1040c03dc 100644 --- a/src/ConfigStorage/UserGroups.php +++ b/src/ConfigStorage/UserGroups.php @@ -255,8 +255,8 @@ class UserGroups * Returns HTML for checkbox groups to choose * tabs of 'server', 'db' or 'table' levels. * - * @param string $title title of the checkbox group - * @param mixed[] $selected array of selected allowed tabs + * @param string $title title of the checkbox group + * @param string[] $selected array of selected allowed tabs * * @return string HTML for checkbox groups */ @@ -266,7 +266,7 @@ class UserGroups $tabDetails = []; foreach ($tabs as $tab => $tabName) { $tabDetail = []; - $tabDetail['in_array'] = in_array($tab, $selected) ? ' checked' : ''; + $tabDetail['in_array'] = in_array($tab, $selected, true) ? ' checked' : ''; $tabDetail['tab'] = $tab; $tabDetail['tab_name'] = $tabName; $tabDetails[] = $tabDetail; diff --git a/src/Controllers/Database/DataDictionaryController.php b/src/Controllers/Database/DataDictionaryController.php index 42292a03ea..f0d83e2bab 100644 --- a/src/Controllers/Database/DataDictionaryController.php +++ b/src/Controllers/Database/DataDictionaryController.php @@ -46,7 +46,7 @@ final class DataDictionaryController implements InvocableController $showComment = (string) $this->dbi->getTable(Current::$database, $tableName) ->getStatusInfo('TABLE_COMMENT'); - [, $primaryKeys] = Util::processIndexData( + $primaryKeys = $this->getPrimaryKeys( $this->dbi->getTableIndexes(Current::$database, $tableName), ); @@ -110,4 +110,23 @@ final class DataDictionaryController implements InvocableController return $this->response->response(); } + + /** + * @param mixed[][] $indexes index data + * + * @return array The list of primary key columns + */ + private function getPrimaryKeys(array $indexes): array + { + $pkArray = []; + foreach ($indexes as $row) { + if ($row['Key_name'] !== 'PRIMARY') { + continue; + } + + $pkArray[$row['Column_name']] = true; + } + + return $pkArray; + } } diff --git a/src/Controllers/Operations/TableController.php b/src/Controllers/Operations/TableController.php index 0a687e4e81..32edbd23f1 100644 --- a/src/Controllers/Operations/TableController.php +++ b/src/Controllers/Operations/TableController.php @@ -158,8 +158,7 @@ final class TableController implements InvocableController $this->response->addJSON('message', $message); if ($message->isSuccess()) { - /** @var mixed $targetDbParam */ - $targetDbParam = $request->getParsedBodyParam('target_db'); + $targetDbParam = $request->getParsedBodyParamAsStringOrNull('target_db'); if ($request->hasBodyParam('submit_move') && is_string($targetDbParam)) { Current::$database = $targetDbParam; // Used in Header::getJsParams() } @@ -180,8 +179,7 @@ final class TableController implements InvocableController * Updates table comment, type and options if required */ if ($request->hasBodyParam('submitoptions')) { - /** @var mixed $newName */ - $newName = $request->getParsedBodyParam('new_name'); + $newName = $request->getParsedBodyParamAsStringOrNull('new_name'); if (is_string($newName)) { if ($this->dbi->getLowerCaseNames() === 1) { $newName = mb_strtolower($newName); @@ -193,13 +191,12 @@ final class TableController implements InvocableController if ($pmaTable->rename($newName)) { if ($request->getParsedBodyParam('adjust_privileges')) { - /** @var mixed $dbParam */ - $dbParam = $request->getParsedBodyParam('db'); + $dbParam = $request->getParsedBodyParamAsString('db', ''); $this->operations->adjustPrivilegesRenameOrMoveTable( $userPrivileges, $oldDb, $oldTable, - is_string($dbParam) ? $dbParam : '', + $dbParam, $newName, ); } @@ -218,8 +215,7 @@ final class TableController implements InvocableController } } - /** @var mixed $newTableStorageEngine */ - $newTableStorageEngine = $request->getParsedBodyParam('new_tbl_storage_engine'); + $newTableStorageEngine = $request->getParsedBodyParamAsStringOrNull('new_tbl_storage_engine'); $newTblStorageEngine = ''; if ( is_string($newTableStorageEngine) && $newTableStorageEngine !== '' @@ -258,8 +254,7 @@ final class TableController implements InvocableController $warningMessages = $this->operations->getWarningMessagesArray($newTableStorageEngine); } - /** @var mixed $tableCollationParam */ - $tableCollationParam = $request->getParsedBodyParam('tbl_collation'); + $tableCollationParam = $request->getParsedBodyParamAsStringOrNull('tbl_collation'); if ( is_string($tableCollationParam) && $tableCollationParam !== '' && $request->getParsedBodyParam('change_all_collations') @@ -267,7 +262,7 @@ final class TableController implements InvocableController $this->operations->changeAllColumnsCollation(Current::$database, Current::$table, $tableCollationParam); } - if ($tableCollationParam !== null && (! is_string($tableCollationParam) || $tableCollationParam === '')) { + if ($tableCollationParam === '') { if ($request->isAjax()) { $this->response->setRequestStatus(false); $this->response->addJSON( @@ -280,26 +275,23 @@ final class TableController implements InvocableController } } - /** @var mixed $orderField */ - $orderField = $request->getParsedBodyParam('order_field'); + $orderField = $request->getParsedBodyParamAsStringOrNull('order_field'); /** * Reordering the table has been requested by the user */ if ($request->hasBodyParam('submitorderby') && is_string($orderField) && $orderField !== '') { - /** @var mixed $orderOrder */ - $orderOrder = $request->getParsedBodyParam('order_order'); + $orderOrder = $request->getParsedBodyParamAsString('order_order', ''); Current::$sqlQuery = QueryGenerator::getQueryForReorderingTable( Current::$table, urldecode($orderField), - is_string($orderOrder) ? $orderOrder : '', + $orderOrder, ); $this->dbi->query(Current::$sqlQuery); $result = true; } - /** @var mixed $partitionOperation */ - $partitionOperation = $request->getParsedBodyParam('partition_operation'); + $partitionOperation = $request->getParsedBodyParamAsStringOrNull('partition_operation'); /** * A partition operation has been requested by the user diff --git a/src/Controllers/Server/Status/VariablesController.php b/src/Controllers/Server/Status/VariablesController.php index 9215e519ca..ae33205a56 100644 --- a/src/Controllers/Server/Status/VariablesController.php +++ b/src/Controllers/Server/Status/VariablesController.php @@ -206,7 +206,7 @@ final class VariablesController extends AbstractController implements InvocableC /** * Returns a list of variable descriptions * - * @return mixed[] + * @return array */ private function getDescriptions(): array { diff --git a/src/Controllers/Server/UserGroupsController.php b/src/Controllers/Server/UserGroupsController.php index 2b99c15e71..c850ead650 100644 --- a/src/Controllers/Server/UserGroupsController.php +++ b/src/Controllers/Server/UserGroupsController.php @@ -54,8 +54,7 @@ final class UserGroupsController implements InvocableController 'is_super_user' => $this->dbi->isSuperUser(), ]); - /** @var mixed $userGroup */ - $userGroup = $request->getParsedBodyParam('userGroup'); + $userGroup = $request->getParsedBodyParamAsStringOrNull('userGroup'); if ($request->hasBodyParam('deleteUserGroup') && is_string($userGroup) && $userGroup !== '') { UserGroups::delete($this->dbi, $configurableMenusFeature, $userGroup); } diff --git a/src/Controllers/Setup/ShowConfigController.php b/src/Controllers/Setup/ShowConfigController.php index 608c80ce10..0792ddff2a 100644 --- a/src/Controllers/Setup/ShowConfigController.php +++ b/src/Controllers/Setup/ShowConfigController.php @@ -49,14 +49,12 @@ final class ShowConfigController implements InvocableController $formDisplay = new ConfigForm($configFile); $formDisplay->save(['Config']); - /** @var mixed $eol */ - $eol = $request->getParsedBodyParam('eol'); + $eol = $request->getParsedBodyParamAsStringOrNull('eol'); if ($eol !== null) { $_SESSION['eol'] = $eol === 'unix' ? 'unix' : 'win'; } - /** @var mixed $submitClear */ - $submitClear = $request->getParsedBodyParam('submit_clear'); + $submitClear = $request->getParsedBodyParamAsStringOrNull('submit_clear'); if (is_string($submitClear) && $submitClear !== '') { // Clear current config and return to main page $configFile->resetConfigData(); @@ -65,8 +63,7 @@ final class ShowConfigController implements InvocableController ->withHeader('Location', '../setup/index.php' . Url::getCommonRaw(['route' => '/setup'])); } - /** @var mixed $submitDownload */ - $submitDownload = $request->getParsedBodyParam('submit_download'); + $submitDownload = $request->getParsedBodyParamAsStringOrNull('submit_download'); if (is_string($submitDownload) && $submitDownload !== '') { $response = $this->responseFactory->createResponse(); // Output generated config file diff --git a/src/Export/Export.php b/src/Export/Export.php index 3e6940f5e2..01d052cc2a 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -73,7 +73,7 @@ class Export public int $dumpBufferLength = 0; - /** @var mixed[] */ + /** @var string[] */ public array $dumpBufferObjects = []; public static bool $asFile = false; @@ -446,9 +446,9 @@ class Export /** * Compress the export buffer * - * @param mixed[]|string $dumpBuffer the current dump buffer - * @param string $compression the compression mode - * @param string $filename the filename + * @param string[]|string $dumpBuffer the current dump buffer + * @param string $compression the compression mode + * @param string $filename the filename */ public function compress(array|string $dumpBuffer, string $compression, string $filename): array|string|bool { diff --git a/src/File.php b/src/File.php index 1f96e534d7..9efeb33cf8 100644 --- a/src/File.php +++ b/src/File.php @@ -249,11 +249,12 @@ class File return false; } - $file = $this->fetchUploadedFromTblChangeRequestMultiple($_FILES['fields_upload'], $rownumber, $key); + $error = $_FILES['fields_upload']['error']['multi_edit'][$rownumber][$key]; + $tempName = $_FILES['fields_upload']['tmp_name']['multi_edit'][$rownumber][$key]; - switch ($file['error']) { + switch ($error) { case UPLOAD_ERR_OK: - return $this->setUploadedFile($file['tmp_name']); + return $this->setUploadedFile($tempName); case UPLOAD_ERR_NO_FILE: break; @@ -288,45 +289,6 @@ class File return false; } - /** - * strips some dimension from the multi-dimensional array from $_FILES - * - * - * $file['name']['multi_edit'][$rownumber][$key] = [value] - * $file['type']['multi_edit'][$rownumber][$key] = [value] - * $file['size']['multi_edit'][$rownumber][$key] = [value] - * $file['tmp_name']['multi_edit'][$rownumber][$key] = [value] - * $file['error']['multi_edit'][$rownumber][$key] = [value] - * - * // becomes: - * - * $file['name'] = [value] - * $file['type'] = [value] - * $file['size'] = [value] - * $file['tmp_name'] = [value] - * $file['error'] = [value] - * - * - * @param mixed[] $file the array - * @param string $rownumber number of row to process - * @param string $key key to process - * - * @return mixed[] - */ - public function fetchUploadedFromTblChangeRequestMultiple( - array $file, - string $rownumber, - string $key, - ): array { - return [ - 'name' => $file['name']['multi_edit'][$rownumber][$key], - 'type' => $file['type']['multi_edit'][$rownumber][$key], - 'size' => $file['size']['multi_edit'][$rownumber][$key], - 'tmp_name' => $file['tmp_name']['multi_edit'][$rownumber][$key], - 'error' => $file['error']['multi_edit'][$rownumber][$key], - ]; - } - /** * sets the name if the file to the one selected in the tbl_change form * diff --git a/src/Operations.php b/src/Operations.php index 8cda2f52b2..8199b30f90 100644 --- a/src/Operations.php +++ b/src/Operations.php @@ -166,7 +166,7 @@ class Operations * @param bool $move whether database name is empty or not * @param string $db database name * - * @return mixed[] SQL queries for the constraints + * @return string[] SQL queries for the constraints */ public function copyTables(array $tables, bool $move, string $db, DatabaseName $newDatabaseName): array { @@ -438,7 +438,7 @@ class Operations /** * Create all accumulated constraints * - * @param mixed[] $sqlConstraints array of sql constraints for the database + * @param string[] $sqlConstraints array of sql constraints for the database */ public function createAllAccumulatedConstraints(array $sqlConstraints, DatabaseName $newDatabaseName): void { diff --git a/src/Session.php b/src/Session.php index 90e10d78b9..ff6a2d2669 100644 --- a/src/Session.php +++ b/src/Session.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin; +use PhpMyAdmin\Error\Error; use PhpMyAdmin\Error\ErrorHandler; use PhpMyAdmin\Exceptions\SessionHandlerException; @@ -73,7 +74,7 @@ class Session /** * Session failed function * - * @param mixed[] $errors PhpMyAdmin\Error\ErrorHandler array + * @param Error[] $errors * * @throws SessionHandlerException */ diff --git a/src/Sql.php b/src/Sql.php index 70fe199cf3..92943c9764 100644 --- a/src/Sql.php +++ b/src/Sql.php @@ -145,7 +145,7 @@ class Sql /** * Verify whether the result set has columns from just one table * - * @param mixed[] $fieldsMeta meta fields + * @param FieldMetadata[] $fieldsMeta meta fields */ private function resultSetHasJustOneTable(array $fieldsMeta): bool { @@ -170,9 +170,9 @@ class Sql * Verify whether the result set contains all the columns * of at least one unique key * - * @param string $db database name - * @param string $table table name - * @param mixed[] $fieldsMeta meta fields + * @param string $db database name + * @param string $table table name + * @param FieldMetadata[] $fieldsMeta meta fields */ private function resultSetContainsUniqueKey(string $db, string $table, array $fieldsMeta): bool { diff --git a/src/StorageEngine.php b/src/StorageEngine.php index de3a08e128..46b40dcafd 100644 --- a/src/StorageEngine.php +++ b/src/StorageEngine.php @@ -100,7 +100,6 @@ class StorageEngine if (! $dbi->isMariaDB() && $dbi->getVersion() >= 50708) { $disabled = (string) SessionCache::get( 'disabled_storage_engines', - /** @return mixed|false */ static fn () => DatabaseInterface::getInstance()->fetchValue( 'SELECT @@disabled_storage_engines', ), @@ -207,7 +206,7 @@ class StorageEngine return [$dataLength, $indexLength]; } - /** @return array> */ + /** @return array */ public static function getArray(): array { $engines = []; diff --git a/src/Util.php b/src/Util.php index 39592dbbc0..b5fab8a7bf 100644 --- a/src/Util.php +++ b/src/Util.php @@ -1482,57 +1482,6 @@ class Util return ''; } - /** - * Process the index data. - * - * @param mixed[] $indexes index data - * - * @return mixed[] processes index data - */ - public static function processIndexData(array $indexes): array - { - $lastIndex = ''; - - $primary = ''; - $pkArray = []; // will be use to emphasis prim. keys in the table - $indexesInfo = []; - $indexesData = []; - - // view - foreach ($indexes as $row) { - // Backups the list of primary keys - if ($row['Key_name'] === 'PRIMARY') { - $primary .= $row['Column_name'] . ', '; - $pkArray[$row['Column_name']] = 1; - } - - // Retains keys informations - if ($row['Key_name'] != $lastIndex) { - $lastIndex = $row['Key_name']; - } - - $indexesInfo[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; - $indexesInfo[$row['Key_name']]['Non_unique'] = $row['Non_unique']; - if (isset($row['Cardinality'])) { - $indexesInfo[$row['Key_name']]['Cardinality'] = $row['Cardinality']; - } - - // I don't know what does following column mean.... - // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; - - $indexesInfo[$row['Key_name']]['Comment'] = $row['Comment']; - - $indexesData[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; - if (! isset($row['Sub_part'])) { - continue; - } - - $indexesData[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part']; - } - - return [$primary, $pkArray, $indexesInfo, $indexesData]; - } - /** * Gets the list of tables in the current db and information about these tables if possible. * diff --git a/src/ZipExtension.php b/src/ZipExtension.php index 434999b7c5..e33ed94b8a 100644 --- a/src/ZipExtension.php +++ b/src/ZipExtension.php @@ -194,8 +194,8 @@ class ZipExtension * or if $data is an array and $name is an array, but they don't have the * same amount of elements. * - * @param mixed[]|string $data contents of the file/files - * @param mixed[]|string $name name of the file/files in the archive + * @param string[]|string $data contents of the file/files + * @param mixed[]|string $name name of the file/files in the archive * * @return string|false the ZIP file contents, or false if there was an error. */ diff --git a/tests/unit/Command/TwigLintCommandTest.php b/tests/unit/Command/TwigLintCommandTest.php index 4a8d0e186e..277793a6e9 100644 --- a/tests/unit/Command/TwigLintCommandTest.php +++ b/tests/unit/Command/TwigLintCommandTest.php @@ -71,17 +71,15 @@ class TwigLintCommandTest extends AbstractTestCase sort($filesInfos, SORT_REGULAR); self::assertSame([ - ['template' => '', 'file' => $path . DIRECTORY_SEPARATOR . 'one.txt', 'valid' => true], - ['template' => '', 'file' => $path . DIRECTORY_SEPARATOR . 'two.md', 'valid' => true], + ['template' => '', 'file' => $path . DIRECTORY_SEPARATOR . 'one.txt'], + ['template' => '', 'file' => $path . DIRECTORY_SEPARATOR . 'two.md'], [ 'template' => '0000' . "\n", 'file' => $path . DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'zero.txt', - 'valid' => true, ], [ 'template' => 'key=value' . "\n", 'file' => $path . DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'one.ini', - 'valid' => true, ], ], $filesInfos); } @@ -108,12 +106,10 @@ class TwigLintCommandTest extends AbstractTestCase ]); self::assertEquals([ - ['template' => '{{ file }}', 'file' => 'foo.twig', 'valid' => true], + ['template' => '{{ file }}', 'file' => 'foo.twig'], [ 'template' => '{{ file }', 'file' => 'foo-invalid.twig', - 'valid' => false, - 'line' => 1, 'exception' => new SyntaxError('Unexpected "}".', 1, new Source( '{{ file }', 'foo-invalid.twig',