From 57a27fd9a2bc45907fdc572d9a32e6ec5797a51c Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 27 Sep 2024 22:26:10 +0100 Subject: [PATCH 01/10] Update PHPStan Signed-off-by: Kamil Tekiela --- composer.lock | 80 ++++++++++++++++++++++--------------------- phpstan-baseline.neon | 2 +- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/composer.lock b/composer.lock index 59024b0332..fcc2ab0868 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "composer/ca-bundle", - "version": "1.5.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a" + "reference": "48a792895a2b7a6ee65dd5442c299d7b835b6137" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/063d9aa8696582f5a41dffbbaf3c81024f0a604a", - "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/48a792895a2b7a6ee65dd5442c299d7b835b6137", + "reference": "48a792895a2b7a6ee65dd5442c299d7b835b6137", "shasum": "" }, "require": { @@ -27,8 +27,8 @@ }, "require-dev": { "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8 || ^9", "psr/log": "^1.0 || ^2.0 || ^3.0", - "symfony/phpunit-bridge": "^4.2 || ^5", "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", @@ -64,7 +64,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.5.1" + "source": "https://github.com/composer/ca-bundle/tree/1.5.2" }, "funding": [ { @@ -80,7 +80,7 @@ "type": "tidelift" } ], - "time": "2024-07-08T15:28:20+00:00" + "time": "2024-09-25T07:49:53+00:00" }, { "name": "fig/http-message-util", @@ -3188,16 +3188,16 @@ }, { "name": "felixfbecker/language-server-protocol", - "version": "v1.5.2", + "version": "v1.5.3", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-language-server-protocol.git", - "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842" + "reference": "a9e113dbc7d849e35b8776da39edaf4313b7b6c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/6e82196ffd7c62f7794d778ca52b69feec9f2842", - "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/a9e113dbc7d849e35b8776da39edaf4313b7b6c9", + "reference": "a9e113dbc7d849e35b8776da39edaf4313b7b6c9", "shasum": "" }, "require": { @@ -3238,9 +3238,9 @@ ], "support": { "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", - "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.2" + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.3" }, - "time": "2022-03-02T22:36:06+00:00" + "time": "2024-04-30T00:40:11+00:00" }, { "name": "fidry/cpu-core-counter", @@ -3569,34 +3569,34 @@ }, { "name": "lcobucci/clock", - "version": "3.2.0", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/lcobucci/clock.git", - "reference": "6f28b826ea01306b07980cb8320ab30b966cd715" + "reference": "db3713a61addfffd615b79bf0bc22f0ccc61b86b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/6f28b826ea01306b07980cb8320ab30b966cd715", - "reference": "6f28b826ea01306b07980cb8320ab30b966cd715", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/db3713a61addfffd615b79bf0bc22f0ccc61b86b", + "reference": "db3713a61addfffd615b79bf0bc22f0ccc61b86b", "shasum": "" }, "require": { - "php": "~8.2.0 || ~8.3.0", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0", "psr/clock": "^1.0" }, "provide": { "psr/clock-implementation": "1.0" }, "require-dev": { - "infection/infection": "^0.27", - "lcobucci/coding-standard": "^11.0.0", + "infection/infection": "^0.29", + "lcobucci/coding-standard": "^11.1.0", "phpstan/extension-installer": "^1.3.1", "phpstan/phpstan": "^1.10.25", "phpstan/phpstan-deprecation-rules": "^1.1.3", "phpstan/phpstan-phpunit": "^1.3.13", "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^10.2.3" + "phpunit/phpunit": "^11.3.6" }, "type": "library", "autoload": { @@ -3617,7 +3617,7 @@ "description": "Yet another clock abstraction", "support": { "issues": "https://github.com/lcobucci/clock/issues", - "source": "https://github.com/lcobucci/clock/tree/3.2.0" + "source": "https://github.com/lcobucci/clock/tree/3.3.1" }, "funding": [ { @@ -3629,7 +3629,7 @@ "type": "patreon" } ], - "time": "2023-11-17T17:00:27+00:00" + "time": "2024-09-24T20:45:14+00:00" }, { "name": "myclabs/deep-copy", @@ -4395,16 +4395,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.31.0", + "version": "1.32.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "249f15fb843bf240cf058372dad29e100cee6c17" + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/249f15fb843bf240cf058372dad29e100cee6c17", - "reference": "249f15fb843bf240cf058372dad29e100cee6c17", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", "shasum": "" }, "require": { @@ -4436,22 +4436,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.31.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" }, - "time": "2024-09-22T11:32:18+00:00" + "time": "2024-09-26T07:23:32+00:00" }, { "name": "phpstan/phpstan", - "version": "1.12.4", + "version": "1.12.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "ffa517cb918591b93acc9b95c0bebdcd0e4538bd" + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ffa517cb918591b93acc9b95c0bebdcd0e4538bd", - "reference": "ffa517cb918591b93acc9b95c0bebdcd0e4538bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", "shasum": "" }, "require": { @@ -4496,7 +4496,7 @@ "type": "github" } ], - "time": "2024-09-19T07:58:01+00:00" + "time": "2024-09-26T12:45:22+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -5407,12 +5407,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "4d2e39c44028ba729fe50efdf731d3d2ede4046b" + "reference": "5bd374d4b964c449fc99b871b6d9f139d0b41502" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/4d2e39c44028ba729fe50efdf731d3d2ede4046b", - "reference": "4d2e39c44028ba729fe50efdf731d3d2ede4046b", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/5bd374d4b964c449fc99b871b6d9f139d0b41502", + "reference": "5bd374d4b964c449fc99b871b6d9f139d0b41502", "shasum": "" }, "conflict": { @@ -5423,7 +5423,7 @@ "aimeos/ai-admin-graphql": ">=2022.04.1,<2022.10.10|>=2023.04.1,<2023.10.6|>=2024.04.1,<2024.04.6", "aimeos/ai-admin-jsonadm": "<2020.10.13|>=2021.04.1,<2021.10.6|>=2022.04.1,<2022.10.3|>=2023.04.1,<2023.10.4|==2024.04.1", "aimeos/ai-client-html": ">=2020.04.1,<2020.10.27|>=2021.04.1,<2021.10.22|>=2022.04.1,<2022.10.13|>=2023.04.1,<2023.10.15|>=2024.04.1,<2024.04.7", - "aimeos/ai-controller-frontend": "<2020.10.15|>=2021.04.1,<2021.10.8|>=2022.04.1,<2022.10.8|>=2023.04.1,<2023.10.9", + "aimeos/ai-controller-frontend": "<2020.10.15|>=2021.04.1,<2021.10.8|>=2022.04.1,<2022.10.8|>=2023.04.1,<2023.10.9|==2024.04.1", "aimeos/aimeos-core": ">=2022.04.1,<2022.10.17|>=2023.04.1,<2023.10.17|>=2024.04.1,<2024.04.7", "aimeos/aimeos-typo3": "<19.10.12|>=20,<20.10.5", "airesvsg/acf-to-rest-api": "<=3.1", @@ -5595,6 +5595,8 @@ "feehi/cms": "<=2.1.1", "feehi/feehicms": "<=2.1.1", "fenom/fenom": "<=2.12.1", + "filament/infolists": ">=3,<3.2.115", + "filament/tables": ">=3,<3.2.115", "filegator/filegator": "<7.8", "filp/whoops": "<2.1.13", "fineuploader/php-traditional-server": "<=1.2.2", @@ -6224,7 +6226,7 @@ "type": "tidelift" } ], - "time": "2024-09-23T20:04:53+00:00" + "time": "2024-09-27T21:04:39+00:00" }, { "name": "sebastian/cli-parser", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index abfe03b4b6..27978e694c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4421,7 +4421,7 @@ parameters: path: src/Controllers/Table/ReplaceController.php - - message: "#^Parameter \\#1 \\$array of function array_values expects array, mixed given\\.$#" + message: "#^Parameter \\#1 \\$array of function array_values expects array\\, mixed given\\.$#" count: 1 path: src/Controllers/Table/ReplaceController.php From 9db72b5f6270b3fec4339036c210b041cccc9bea Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 27 Sep 2024 22:30:41 +0100 Subject: [PATCH 02/10] Remove invalid type union Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- psalm-baseline.xml | 3 --- src/ConfigStorage/Relation.php | 20 ++++++++++---------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 27978e694c..fa0bc51caa 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1255,11 +1255,6 @@ parameters: count: 2 path: src/ConfigStorage/Relation.php - - - message: "#^Parameter \\#1 \\$foreigners of method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:searchColumnInForeigners\\(\\) expects array, array\\|true given\\.$#" - count: 1 - path: src/ConfigStorage/Relation.php - - message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#" count: 7 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 6262b395f3..2ddd49f11c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -755,9 +755,6 @@ config->selectedServer['column_info']]]> config->selectedServer['column_info']]]> - - - diff --git a/src/ConfigStorage/Relation.php b/src/ConfigStorage/Relation.php index bcbb74be16..7162990749 100644 --- a/src/ConfigStorage/Relation.php +++ b/src/ConfigStorage/Relation.php @@ -887,17 +887,17 @@ class Relation /** * Gets foreign keys in preparation for a drop-down selector * - * @param mixed[]|bool $foreigners array of the foreign keys - * @param string $field the foreign field name - * @param bool $overrideTotal whether to override the total - * @param string $foreignFilter a possible filter - * @param string $foreignLimit a possible LIMIT clause - * @param bool $getTotal optional, whether to get total num of rows - * in $foreignData['the_total;] - * (has an effect of performance) + * @param mixed[] $foreigners array of the foreign keys + * @param string $field the foreign field name + * @param bool $overrideTotal whether to override the total + * @param string $foreignFilter a possible filter + * @param string $foreignLimit a possible LIMIT clause + * @param bool $getTotal optional, whether to get total num of rows + * in $foreignData['the_total;] + * (has an effect of performance) */ public function getForeignData( - array|bool $foreigners, + array $foreigners, string $field, bool $overrideTotal, string $foreignFilter, @@ -909,7 +909,7 @@ class Relation $foreignLink = false; $dispRow = $foreignDisplay = $theTotal = $foreignField = null; do { - if ($foreigners === false || $foreigners === []) { + if ($foreigners === []) { break; } From a38dc99c5b6f86367fe234af8b7309d21b8e27e1 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 27 Sep 2024 23:41:40 +0100 Subject: [PATCH 03/10] Remove unnecessary arguments to template Signed-off-by: Kamil Tekiela --- src/Controllers/Table/RelationController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Controllers/Table/RelationController.php b/src/Controllers/Table/RelationController.php index a61bfc8624..32fa978bf9 100644 --- a/src/Controllers/Table/RelationController.php +++ b/src/Controllers/Table/RelationController.php @@ -299,8 +299,6 @@ final class RelationController implements InvocableController 'table' => Current::$table, 'relation_parameters' => $relationParameters, 'tbl_storage_engine' => $storageEngine, - 'existrel' => $relations, - 'existrel_foreign' => $existrelForeign, 'options_array' => $options, 'internal_relation_columns' => $internalRelationColumns, 'url_params' => $GLOBALS['urlParams'], From a59de24826b3a07795375f54adee657fe6f7049f Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 27 Sep 2024 23:53:11 +0100 Subject: [PATCH 04/10] Rename variable Signed-off-by: Kamil Tekiela --- src/Controllers/Table/ReplaceController.php | 6 +++--- src/InsertEdit.php | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Controllers/Table/ReplaceController.php b/src/Controllers/Table/ReplaceController.php index ebfff1ba34..58abb6da22 100644 --- a/src/Controllers/Table/ReplaceController.php +++ b/src/Controllers/Table/ReplaceController.php @@ -381,7 +381,7 @@ final class ReplaceController implements InvocableController { $relFieldsList = $request->getParsedBodyParam('rel_fields_list', ''); if ($relFieldsList !== '') { - $map = $this->relation->getForeigners(Current::$database, Current::$table); + $foreigners = $this->relation->getForeigners(Current::$database, Current::$table); /** @var array $relationFields */ $relationFields = []; @@ -393,12 +393,12 @@ final class ReplaceController implements InvocableController $whereComparison = "='" . $relationFieldValue . "'"; $dispval = $this->insertEdit->getDisplayValueForForeignTableColumn( $whereComparison, - $map, + $foreigners, $relationField, ); $extraData['relations'][$cellIndex] = $this->insertEdit->getLinkForRelationalDisplayField( - $map, + $foreigners, $relationField, $whereComparison, $dispval, diff --git a/src/InsertEdit.php b/src/InsertEdit.php index 47277e663f..770025fecf 100644 --- a/src/InsertEdit.php +++ b/src/InsertEdit.php @@ -976,18 +976,18 @@ class InsertEdit * Column to display from the foreign table? * * @param string $whereComparison string that contain relation field value - * @param mixed[] $map all Relations to foreign tables for a given - * table or optionally a given column in a table + * @param mixed[] $foreigners all Relations to foreign tables for a given + * table or optionally a given column in a table * @param string $relationField relation field * * @return string display value from the foreign table */ public function getDisplayValueForForeignTableColumn( string $whereComparison, - array $map, + array $foreigners, string $relationField, ): string { - $foreigner = $this->relation->searchColumnInForeigners($map, $relationField); + $foreigner = $this->relation->searchColumnInForeigners($foreigners, $relationField); if (! is_array($foreigner)) { return ''; @@ -1013,8 +1013,8 @@ class InsertEdit /** * Display option in the cell according to user choices * - * @param mixed[] $map all Relations to foreign tables for a given - * table or optionally a given column in a table + * @param mixed[] $foreigners all Relations to foreign tables for a given + * table or optionally a given column in a table * @param string $relationField relation field * @param string $whereComparison string that contain relation field value * @param string $dispval display value from the foreign table @@ -1023,13 +1023,13 @@ class InsertEdit * @return string HTML tag */ public function getLinkForRelationalDisplayField( - array $map, + array $foreigners, string $relationField, string $whereComparison, string $dispval, string $relationFieldValue, ): string { - $foreigner = $this->relation->searchColumnInForeigners($map, $relationField); + $foreigner = $this->relation->searchColumnInForeigners($foreigners, $relationField); if (! is_array($foreigner)) { return ''; From 5e5630b3ee899785b0468e23d49c08082ef91493 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 28 Sep 2024 13:39:35 +0100 Subject: [PATCH 05/10] Simplify Twig condition Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 20 ----------- psalm-baseline.xml | 2 -- .../templates/table/search/input_box.twig | 2 +- .../table/zoom_search/result_form.twig | 3 +- src/Controllers/Table/SearchController.php | 11 +++--- .../Table/ZoomSearchController.php | 35 +++++++++---------- 6 files changed, 22 insertions(+), 51 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fa0bc51caa..b53f142a9b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4545,16 +4545,6 @@ parameters: count: 1 path: src/Controllers/Table/SearchController.php - - - message: "#^Only booleans are allowed in &&, array given on the left side\\.$#" - count: 1 - path: src/Controllers/Table/SearchController.php - - - - message: "#^Only booleans are allowed in &&, array\\|false given on the right side\\.$#" - count: 1 - path: src/Controllers/Table/SearchController.php - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" count: 1 @@ -5020,21 +5010,11 @@ parameters: count: 2 path: src/Controllers/Table/ZoomSearchController.php - - - message: "#^Only booleans are allowed in &&, array\\|false given on the left side\\.$#" - count: 1 - path: src/Controllers/Table/ZoomSearchController.php - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" count: 1 path: src/Controllers/Table/ZoomSearchController.php - - - message: "#^Only booleans are allowed in an if condition, array given\\.$#" - count: 1 - path: src/Controllers/Table/ZoomSearchController.php - - message: "#^Parameter \\#1 \\$dataLabel of method PhpMyAdmin\\\\Controllers\\\\Table\\\\ZoomSearchController\\:\\:displaySelectionFormAction\\(\\) expects string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2ddd49f11c..aa961ec666 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3813,7 +3813,6 @@ settings['MaxRows']]]> - collation)]]> @@ -4153,7 +4152,6 @@ - collation)]]> diff --git a/resources/templates/table/search/input_box.twig b/resources/templates/table/search/input_box.twig index e969be4582..6744fcbd75 100644 --- a/resources/templates/table/search/input_box.twig +++ b/resources/templates/table/search/input_box.twig @@ -1,5 +1,5 @@ {# Get inputbox based on different column types (Foreign key, geometrical, enum) #} -{% if foreigners and search_column_in_foreigners %} +{% if has_foreigner %} {% if foreign_data.dispRow is iterable %}