From eaa9f2d051caba56ce983c0a5d9559c623347a73 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 17 Dec 2024 21:37:51 +0000 Subject: [PATCH 1/4] Fix type hints Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 52 +++++-------------------------------------- psalm-baseline.xml | 37 ++++++------------------------ src/Table/Table.php | 12 +++++----- 3 files changed, 18 insertions(+), 83 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 28dc3da2e5..3e0e1d43ff 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4660,7 +4660,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#1 \$destinationForeignDb of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#1 \$destinationForeignDb of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -4696,7 +4696,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#2 \$multiEditColumnsName of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#2 \$multiEditColumnsName of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\\>, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -4714,7 +4714,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#3 \$destinationForeignTable of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#3 \$destinationForeignTable of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -4738,7 +4738,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#4 \$destinationForeignColumn of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#4 \$destinationForeignColumn of method PhpMyAdmin\\Table\\Table\:\:updateForeignKeys\(\) expects array\\>, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -17133,12 +17133,6 @@ parameters: count: 1 path: src/Table/Search.php - - - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/Table/Table.php - - message: '#^Binary operation "\." between string and mixed results in an error\.$#' identifier: binaryOp.invalid @@ -17235,12 +17229,6 @@ parameters: count: 3 path: src/Table/Table.php - - - message: '#^Cannot access offset mixed on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 5 - path: src/Table/Table.php - - message: '#^Cannot access offset string on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -17346,7 +17334,7 @@ parameters: - message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#' identifier: argument.type - count: 5 + count: 3 path: src/Table/Table.php - @@ -17373,18 +17361,6 @@ parameters: count: 1 path: src/Table/Table.php - - - message: '#^Parameter \#2 \$array of function implode expects array\|null, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Table/Table.php - - - - message: '#^Parameter \#2 \$field of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects array\, mixed given\.$#' - identifier: argument.type - count: 2 - path: src/Table/Table.php - - message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#' identifier: argument.type @@ -17397,36 +17373,18 @@ parameters: count: 1 path: src/Table/Table.php - - - message: '#^Parameter \#3 \$foreignDb of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Table/Table.php - - message: '#^Parameter \#3 \$foreignDb of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects string, string\|null given\.$#' identifier: argument.type count: 1 path: src/Table/Table.php - - - message: '#^Parameter \#4 \$foreignTable of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Table/Table.php - - message: '#^Parameter \#4 \$foreignTable of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects string, string\|null given\.$#' identifier: argument.type count: 1 path: src/Table/Table.php - - - message: '#^Parameter \#5 \$foreignField of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects array\, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Table/Table.php - - message: '#^Parameter \#6 \$name of method PhpMyAdmin\\Table\\Table\:\:getSQLToCreateForeignKey\(\) expects string\|null, mixed given\.$#' identifier: argument.type diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 524f464675..e01098506a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2982,14 +2982,15 @@ + + + + - - - @@ -2999,7 +3000,6 @@ - @@ -9931,11 +9931,8 @@ - - - @@ -9943,20 +9940,12 @@ - - - uiprefs[$property->value]]]> uiprefs[$property->value]]]> - - - - - dbName][$this->name]]]> @@ -9965,10 +9954,8 @@ - - @@ -9985,11 +9972,6 @@ - - - - - @@ -9998,18 +9980,10 @@ - - - - - - - - @@ -10059,6 +10033,9 @@ onDelete)]]> onUpdate)]]> + + + uiprefs =& $_SESSION['tmpval']['table_uiprefs'][$serverId][$this->dbName][$this->name]]]> diff --git a/src/Table/Table.php b/src/Table/Table.php index 79e17e9b75..b25d46d23f 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -1437,10 +1437,10 @@ class Table implements Stringable /** * Function to handle foreign key updates * - * @param mixed[] $destinationForeignDb destination foreign database - * @param mixed[] $multiEditColumnsName multi edit column names - * @param mixed[] $destinationForeignTable destination foreign table - * @param mixed[] $destinationForeignColumn destination foreign column + * @param string[] $destinationForeignDb destination foreign database + * @param string[][] $multiEditColumnsName multi edit column names + * @param string[] $destinationForeignTable destination foreign table + * @param string[][] $destinationForeignColumn destination foreign column * @param string[] $optionsArray options array * @param string $table current table * @param ForeignKey[] $existrelForeign db, table, column @@ -1616,10 +1616,10 @@ class Table implements Stringable * Returns the SQL query for foreign key constraint creation * * @param string $table table name - * @param mixed[] $field field names + * @param string[] $field field names * @param string $foreignDb foreign database name * @param string $foreignTable foreign table name - * @param mixed[] $foreignField foreign field names + * @param string[] $foreignField foreign field names * @param string|null $name name of the constraint * @param string|null $onDelete on delete action * @param string|null $onUpdate on update action From fb130367a03c5ab1aa9719fdff5cdba685927096 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 17 Dec 2024 21:56:46 +0000 Subject: [PATCH 2/4] Fix type hints Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 14 ++++---------- psalm-baseline.xml | 25 ++++++------------------- src/Table/Table.php | 10 +++++----- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3e0e1d43ff..bc2c4acc87 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4678,7 +4678,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#1 \$multiEditColumnsName of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#1 \$multiEditColumnsName of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -4690,7 +4690,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#2 \$destinationDb of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#2 \$destinationDb of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -4720,7 +4720,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#3 \$destinationTable of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#3 \$destinationTable of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -4732,7 +4732,7 @@ parameters: path: src/Controllers/Table/RelationController.php - - message: '#^Parameter \#4 \$destinationColumn of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' + message: '#^Parameter \#4 \$destinationColumn of method PhpMyAdmin\\Table\\Table\:\:updateInternalRelations\(\) expects array\, mixed given\.$#' identifier: argument.type count: 1 path: src/Controllers/Table/RelationController.php @@ -17337,12 +17337,6 @@ parameters: count: 3 path: src/Table/Table.php - - - message: '#^Parameter \#1 \$str of method PhpMyAdmin\\DatabaseInterface\:\:quoteString\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 9 - path: src/Table/Table.php - - message: '#^Parameter \#1 \$string of function substr expects string, mixed given\.$#' identifier: argument.type diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e01098506a..dc7b1863d6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2982,16 +2982,17 @@ + + + + - - - @@ -2999,7 +3000,6 @@ - @@ -9929,17 +9929,8 @@ - - - - - - - - - uiprefs[$property->value]]]> @@ -9970,8 +9961,6 @@ - - @@ -9979,11 +9968,7 @@ - - - - @@ -10033,9 +10018,11 @@ onDelete)]]> onUpdate)]]> + + uiprefs =& $_SESSION['tmpval']['table_uiprefs'][$serverId][$this->dbName][$this->name]]]> diff --git a/src/Table/Table.php b/src/Table/Table.php index b25d46d23f..28b49ba638 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -1355,11 +1355,11 @@ class Table implements Stringable /** * Function to get update query for updating internal relations * - * @param mixed[] $multiEditColumnsName multi edit column names - * @param mixed[] $destinationDb destination tables - * @param mixed[] $destinationTable destination tables - * @param mixed[] $destinationColumn destination columns - * @param mixed[]|null $existrel db, table, column + * @param string[] $multiEditColumnsName multi edit column names + * @param string[] $destinationDb destination tables + * @param (string|null)[] $destinationTable destination tables + * @param (string|null)[] $destinationColumn destination columns + * @param mixed[]|null $existrel db, table, column */ public function updateInternalRelations( array $multiEditColumnsName, From cbdaff3356ef15336fa38d987132bfd8fb0904cf Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 17 Dec 2024 22:00:27 +0000 Subject: [PATCH 3/4] Fix type hints Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 14 +++++++------- psalm-baseline.xml | 7 ++++--- src/Table/Table.php | 6 +++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index bc2c4acc87..8e92615f1f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -17133,12 +17133,6 @@ parameters: count: 1 path: src/Table/Search.php - - - message: '#^Binary operation "\." between string and mixed results in an error\.$#' - identifier: binaryOp.invalid - count: 1 - path: src/Table/Table.php - - message: '#^Binary operation "\.\=" between string and mixed results in an error\.$#' identifier: assignOp.invalid @@ -17334,7 +17328,13 @@ parameters: - message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#' identifier: argument.type - count: 3 + count: 2 + path: src/Table/Table.php + + - + message: '#^Parameter \#1 \$indexed of method PhpMyAdmin\\Table\\Table\:\:formatColumns\(\) expects array\, array\ given\.$#' + identifier: argument.type + count: 2 path: src/Table/Table.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index dc7b1863d6..a2c246613d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -9925,7 +9925,6 @@ - @@ -9937,6 +9936,10 @@ uiprefs[$property->value]]]> + + + + dbName][$this->name]]]> @@ -9965,7 +9968,6 @@ - @@ -9979,7 +9981,6 @@ - diff --git a/src/Table/Table.php b/src/Table/Table.php index 28b49ba638..cc8748f19c 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -939,9 +939,9 @@ class Table implements Stringable * * e.g. index(col1, col2) would return col1, col2 * - * @param mixed[] $indexed column data - * @param bool $backquoted whether to quote name with backticks `` - * @param bool $fullName whether to include full name of the table as a prefix + * @param string[] $indexed column data + * @param bool $backquoted whether to quote name with backticks `` + * @param bool $fullName whether to include full name of the table as a prefix * * @return string[] */ From d950ad89499d22497219f4ba13d46660a0a29b44 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 17 Dec 2024 22:03:27 +0000 Subject: [PATCH 4/4] Fix type hints Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 12 ------------ psalm-baseline.xml | 4 ---- src/Table/Table.php | 4 ++-- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8e92615f1f..8512ace12a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -17265,18 +17265,6 @@ parameters: count: 1 path: src/Table/Table.php - - - message: '#^Method PhpMyAdmin\\Table\\Table\:\:getLastError\(\) should return string but returns mixed\.$#' - identifier: return.type - count: 1 - path: src/Table/Table.php - - - - message: '#^Method PhpMyAdmin\\Table\\Table\:\:getLastMessage\(\) should return string but returns mixed\.$#' - identifier: return.type - count: 1 - path: src/Table/Table.php - - message: '#^Method PhpMyAdmin\\Table\\Table\:\:getNameAndTypeOfTheColumns\(\) should return array\ but returns array\.$#' identifier: return.type diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a2c246613d..e1a7d70a5a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -9977,15 +9977,11 @@ - - - errors)]]> - messages)]]> diff --git a/src/Table/Table.php b/src/Table/Table.php index cc8748f19c..b74b109b2a 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -69,10 +69,10 @@ class Table implements Stringable /** @var mixed[] UI preferences */ public array $uiprefs = []; - /** @var mixed[] errors occurred */ + /** @var string[] errors occurred */ public array $errors = []; - /** @var mixed[] messages */ + /** @var string[] messages */ public array $messages = []; private Relation $relation;