Merge pull request #19591 from kamil-tekiela/Fix-type-hints

Removed some mixed type hints
This commit is contained in:
Maurício Meneghini Fauth 2025-02-17 19:31:12 -03:00 committed by GitHub
commit 607071afb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 107 additions and 455 deletions

View File

@ -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\<string\|null\> 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\>, 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\>\|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\<int\|string\>, array\<mixed, mixed\> 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\>\|string, \(int\|string\) given\.$#'
identifier: argument.type

View File

@ -71,10 +71,6 @@
</PossiblyNullArgument>
</file>
<file src="src/BrowseForeigners.php">
<MixedArgument>
<code><![CDATA[$descriptions[$indexByDescription]]]></code>
<code><![CDATA[$descriptions[$indexByKeyname]]]></code>
</MixedArgument>
<MixedArrayOffset>
<code><![CDATA[$relrow[$foreignData->foreignField]]]></code>
</MixedArrayOffset>
@ -129,10 +125,6 @@
</file>
<file src="src/Command/TwigLintCommand.php">
<MixedArgument>
<code><![CDATA[$info['exception']]]></code>
<code><![CDATA[$info['file']]]></code>
<code><![CDATA[$info['file']]]></code>
<code><![CDATA[$info['template']]]></code>
<code><![CDATA[static function (int $level, string $message, string $file, int $line) use (&$prevErrorHandler) {
if ($level === E_USER_DEPRECATED) {
$templateLine = 0;
@ -146,17 +138,7 @@
return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;
}]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$info['exception']]]></code>
<code><![CDATA[$info['file']]]></code>
<code><![CDATA[$info['file']]]></code>
<code><![CDATA[$info['file']]]></code>
<code><![CDATA[$info['template']]]></code>
<code><![CDATA[$info['valid']]]></code>
<code><![CDATA[$info['valid']]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$info]]></code>
<code><![CDATA[$showDeprecations]]></code>
</MixedAssignment>
<UndefinedVariable>
@ -783,6 +765,9 @@
<MixedArgument>
<code><![CDATA[Current::$database]]></code>
</MixedArgument>
<MixedArrayOffset>
<code><![CDATA[$pkArray[$row['Column_name']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$relation]]></code>
</MixedAssignment>
@ -4478,7 +4463,6 @@
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$this->dumpBufferObjects[$objectName]]]></code>
<code><![CDATA[$tmpSelect]]></code>
</MixedOperand>
<PossiblyNullArgument>
@ -4571,8 +4555,12 @@
<FalsableReturnStatement>
<code><![CDATA[$this->compression ?? $this->detectCompression()]]></code>
</FalsableReturnStatement>
<InvalidArrayAccess>
<code><![CDATA[$_FILES['fields_upload']['error']['multi_edit']]]></code>
</InvalidArrayAccess>
<InvalidArrayOffset>
<code><![CDATA[$_FILES['fields_upload']['name']['multi_edit']]]></code>
<code><![CDATA[$_FILES['fields_upload']['tmp_name']['multi_edit']]]></code>
</InvalidArrayOffset>
<InvalidFalsableReturnType>
<code><![CDATA[string]]></code>
@ -4581,25 +4569,18 @@
<code><![CDATA[$this->handle]]></code>
</InvalidPropertyAssignmentValue>
<MixedArgument>
<code><![CDATA[$file['tmp_name']]]></code>
<code><![CDATA[$tempName]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$file['error']['multi_edit']]]></code>
<code><![CDATA[$file['error']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$file['error']['multi_edit'][$rownumber][$key]]]></code>
<code><![CDATA[$file['name']['multi_edit']]]></code>
<code><![CDATA[$file['name']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$file['name']['multi_edit'][$rownumber][$key]]]></code>
<code><![CDATA[$file['size']['multi_edit']]]></code>
<code><![CDATA[$file['size']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$file['size']['multi_edit'][$rownumber][$key]]]></code>
<code><![CDATA[$file['tmp_name']['multi_edit']]]></code>
<code><![CDATA[$file['tmp_name']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$file['tmp_name']['multi_edit'][$rownumber][$key]]]></code>
<code><![CDATA[$file['type']['multi_edit']]]></code>
<code><![CDATA[$file['type']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$file['type']['multi_edit'][$rownumber][$key]]]></code>
<code><![CDATA[$_FILES['fields_upload']['error']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$_FILES['fields_upload']['error']['multi_edit'][$rownumber][$key]]]></code>
<code><![CDATA[$_FILES['fields_upload']['tmp_name']['multi_edit'][$rownumber]]]></code>
<code><![CDATA[$_FILES['fields_upload']['tmp_name']['multi_edit'][$rownumber][$key]]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$error]]></code>
<code><![CDATA[$tempName]]></code>
</MixedAssignment>
<PossiblyNullArgument>
<code><![CDATA[$this->getName()]]></code>
<code><![CDATA[$this->getName()]]></code>
@ -5778,7 +5759,6 @@
<code><![CDATA[$arr['foreign_table']]]></code>
<code><![CDATA[$foreignTable]]></code>
<code><![CDATA[$oldPriv]]></code>
<code><![CDATA[$query]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$master]]></code>
@ -5827,7 +5807,6 @@
<code><![CDATA[$oldPriv]]></code>
<code><![CDATA[$oldPriv]]></code>
<code><![CDATA[$oldPriv]]></code>
<code><![CDATA[$query]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$oldPriv[$i]]]></code>
@ -8523,14 +8502,7 @@
<file src="src/Session.php">
<MixedArgument>
<code><![CDATA[$config->getCookie('phpMyAdmin')]]></code>
<code><![CDATA[$error->getMessage()]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$error]]></code>
</MixedAssignment>
<MixedMethodCall>
<code><![CDATA[getMessage]]></code>
</MixedMethodCall>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty(ini_get('session.auto_start'))]]></code>
<code><![CDATA[empty(session_id())]]></code>
@ -8633,11 +8605,7 @@
</MixedArrayAssignment>
<MixedAssignment>
<code><![CDATA[$maxRows]]></code>
<code><![CDATA[$oneFieldMeta]]></code>
<code><![CDATA[$oneMeta]]></code>
<code><![CDATA[$pos]]></code>
<code><![CDATA[$prevTable]]></code>
<code><![CDATA[$resultSetColumnNames[]]]></code>
<code><![CDATA[$sortCol]]></code>
<code><![CDATA[$unlimNumRows]]></code>
</MixedAssignment>
@ -8649,8 +8617,6 @@
<code><![CDATA[$maxRows]]></code>
</MixedOperand>
<MixedPropertyFetch>
<code><![CDATA[$oneFieldMeta->table]]></code>
<code><![CDATA[$oneMeta->name]]></code>
<code><![CDATA[$statementInfo->statement->where[0]->expr]]></code>
</MixedPropertyFetch>
<MixedReturnStatement>
@ -9419,58 +9385,19 @@
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$_SESSION['tmpval']['table_limit_offset']]]></code>
<code><![CDATA[$row['Cardinality']]]></code>
<code><![CDATA[$row['Column_name']]]></code>
<code><![CDATA[$row['Column_name']]]></code>
<code><![CDATA[$row['Column_name']]]></code>
<code><![CDATA[$row['Comment']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Key_name']]]></code>
<code><![CDATA[$row['Non_unique']]]></code>
<code><![CDATA[$row['Seq_in_index']]]></code>
<code><![CDATA[$row['Seq_in_index']]]></code>
<code><![CDATA[$row['Seq_in_index']]]></code>
<code><![CDATA[$row['Sub_part']]]></code>
</MixedArrayAccess>
<MixedArrayAssignment>
<code><![CDATA[$_SESSION['tmpval']['table_limit_offset']]]></code>
<code><![CDATA[$_SESSION['tmpval']['table_limit_offset']]]></code>
<code><![CDATA[$_SESSION['tmpval']['table_limit_offset_db']]]></code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$indexesData[$row['Key_name']]]]></code>
<code><![CDATA[$indexesData[$row['Key_name']]]]></code>
<code><![CDATA[$indexesData[$row['Key_name']][$row['Seq_in_index']]]]></code>
<code><![CDATA[$indexesData[$row['Key_name']][$row['Seq_in_index']]]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]]]></code>
<code><![CDATA[$pkArray[$row['Column_name']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$array]]></code>
<code><![CDATA[$columnNames[]]]></code>
<code><![CDATA[$indexesData[$row['Key_name']][$row['Seq_in_index']]['Column_name']]]></code>
<code><![CDATA[$indexesData[$row['Key_name']][$row['Seq_in_index']]['Sub_part']]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]['Cardinality']]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]['Comment']]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]['Non_unique']]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]['Sequences'][]]]></code>
<code><![CDATA[$lastIndex]]></code>
<code><![CDATA[$row]]></code>
<code><![CDATA[$unit]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$row['Column_name']]]></code>
<code><![CDATA[$unit]]></code>
<code><![CDATA[$unit]]></code>
<code><![CDATA[$value]]></code>
@ -9711,18 +9638,10 @@
<code><![CDATA[$regex]]></code>
<code><![CDATA[$specificEntry]]></code>
</ArgumentTypeCoercion>
<MixedArgument>
<code><![CDATA[$dump]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$name]]></code>
<code><![CDATA[$table]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$dump]]></code>
<code><![CDATA[$newData[$newName]]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<PossiblyInvalidArgument>
<code><![CDATA[$tempName]]></code>
<code><![CDATA[$tempName]]></code>

View File

@ -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
*/

View File

@ -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('<info>OK</info>' . ($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']);
}

View File

@ -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;

View File

@ -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<true> 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;
}
}

View File

@ -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

View File

@ -206,7 +206,7 @@ final class VariablesController extends AbstractController implements InvocableC
/**
* Returns a list of variable descriptions
*
* @return mixed[]
* @return array<string, string>
*/
private function getDescriptions(): array
{

View File

@ -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);
}

View File

@ -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

View File

@ -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
{

View File

@ -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
*
* <code>
* $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]
* </code>
*
* @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
*

View File

@ -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
{

View File

@ -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
*/

View File

@ -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
{

View File

@ -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<int|string, array<string, mixed>> */
/** @return array<string, array{name: string, comment: string, is_default: bool}> */
public static function getArray(): array
{
$engines = [];

View File

@ -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.
*

View File

@ -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.
*/

View File

@ -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',