From b7db85bacb5c3b727df22ab9dc5506b3c5941a8b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 20:50:23 +0100 Subject: [PATCH 1/4] Update GisVisualization.php Signed-off-by: Kamil Tekiela --- libraries/classes/Gis/GisVisualization.php | 4 ++-- phpstan-baseline.neon | 2 +- psalm-baseline.xml | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/classes/Gis/GisVisualization.php b/libraries/classes/Gis/GisVisualization.php index b14562b8c8..30bdcef7ea 100644 --- a/libraries/classes/Gis/GisVisualization.php +++ b/libraries/classes/Gis/GisVisualization.php @@ -545,14 +545,14 @@ class GisVisualization * @param ImageWrapper|TCPDF|string $results Image object in the case of png * TCPDF object in the case of pdf * - * @return mixed the formatted array of data + * @return TCPDF|string|ImageWrapper the formatted array of data */ private function prepareDataSet( array $data, array $scaleData, string $format, ImageWrapper|TCPDF|string $results = '', - ): mixed { + ): TCPDF|string|ImageWrapper { $colorIndex = 0; // loop through the rows diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index cc9c7e11c1..2d5a1619d1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4471,7 +4471,7 @@ parameters: path: libraries/classes/Gis/GisPolygon.php - - message: "#^Cannot call method Output\\(\\) on mixed\\.$#" + message: "#^Cannot call method Output\\(\\) on PhpMyAdmin\\\\Image\\\\ImageWrapper\\|string\\|TCPDF\\.$#" count: 1 path: libraries/classes/Gis/GisVisualization.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 07dc380b56..90f259056c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -7259,19 +7259,19 @@ - - $pdf - - - Output - $results + + Output + $results $results + + Output + mb_strtolower($userExtension) !== $requiredExtension mb_strtolower($userExtension) !== $requiredExtension From 90f7a404170d19b8c03eb4f295b8287c5d5ed5a2 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 20:53:46 +0100 Subject: [PATCH 2/4] Update Message.php Signed-off-by: Kamil Tekiela --- libraries/classes/Message.php | 9 ++++++--- phpstan-baseline.neon | 27 ++++++--------------------- psalm-baseline.xml | 8 -------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/libraries/classes/Message.php b/libraries/classes/Message.php index 5dfdc53074..4042456db4 100644 --- a/libraries/classes/Message.php +++ b/libraries/classes/Message.php @@ -548,11 +548,14 @@ class Message implements Stringable /** * Sanitizes $message * - * @param mixed $message the message(s) + * @param T $message the message(s) * - * @return mixed the sanitized message(s) + * @return string|mixed[] the sanitized message(s) + * @psalm-return (T is array ? array : string) + * + * @template T of array|mixed */ - public static function sanitize(mixed $message): mixed + public static function sanitize(mixed $message): string|array { if (is_array($message)) { foreach ($message as $key => $val) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2d5a1619d1..ffa9b28409 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4937,7 +4937,7 @@ parameters: - message: "#^Cannot cast mixed to string\\.$#" - count: 2 + count: 1 path: libraries/classes/Message.php - @@ -4945,26 +4945,16 @@ parameters: count: 1 path: libraries/classes/Message.php + - + message: "#^Method PhpMyAdmin\\\\Message\\:\\:sanitize\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: libraries/classes/Message.php + - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" count: 1 path: libraries/classes/Message.php - - - message: "#^Property PhpMyAdmin\\\\Message\\:\\:\\$message \\(string\\) does not accept mixed\\.$#" - count: 1 - path: libraries/classes/Message.php - - - - message: "#^Property PhpMyAdmin\\\\Message\\:\\:\\$params \\(array\\) does not accept mixed\\.$#" - count: 1 - path: libraries/classes/Message.php - - - - message: "#^Property PhpMyAdmin\\\\Message\\:\\:\\$string \\(string\\) does not accept mixed\\.$#" - count: 1 - path: libraries/classes/Message.php - - message: "#^Access to an undefined property PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:\\$secondIcon\\.$#" count: 2 @@ -8145,11 +8135,6 @@ parameters: count: 1 path: libraries/classes/Sql.php - - - message: "#^Parameter \\#1 \\$string of static method PhpMyAdmin\\\\Message\\:\\:notice\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Sql.php - - message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Util\\:\\:formatNumber\\(\\) expects float\\|int\\|string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 90f259056c..8508c73029 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -8119,13 +8119,6 @@ $addMessage - $message - $message[$key] - $params - $string - message]]> - params]]> - string]]> $val @@ -12616,7 +12609,6 @@ $sortCol expr]]> - Message::sanitize($warning) $showTable From 1ef3777911bbfe01fc8d706365eb67d88d42361f Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 21:19:20 +0100 Subject: [PATCH 3/4] Update ImportMediawiki.php Signed-off-by: Kamil Tekiela --- libraries/classes/Plugins/Import/ImportMediawiki.php | 2 +- phpstan-baseline.neon | 5 ----- psalm-baseline.xml | 2 -- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/libraries/classes/Plugins/Import/ImportMediawiki.php b/libraries/classes/Plugins/Import/ImportMediawiki.php index dce895829e..b367dfb606 100644 --- a/libraries/classes/Plugins/Import/ImportMediawiki.php +++ b/libraries/classes/Plugins/Import/ImportMediawiki.php @@ -516,7 +516,7 @@ class ImportMediawiki extends ImportPlugin * * @param string $cell Cell */ - private function getCellData(string $cell): mixed + private function getCellData(string $cell): string { // A cell could contain both parameters and data $cellData = explode('|', $cell, 2); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ffa9b28409..e280d8a2c8 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6195,11 +6195,6 @@ parameters: count: 1 path: libraries/classes/Plugins/Import/ImportMediawiki.php - - - message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Plugins/Import/ImportMediawiki.php - - message: "#^Parameter \\#2 \\$tableRow of method PhpMyAdmin\\\\Plugins\\\\Import\\\\ImportMediawiki\\:\\:setTableHeaders\\(\\) expects array, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8508c73029..84056bd61a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -10307,7 +10307,6 @@ - $cell $cell $table[0] $table[1] @@ -10319,7 +10318,6 @@ $cell - $cell $cellData[1] From 066a3a0b734600f6991b9a5a72f70a869de71fc1 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 21:55:53 +0100 Subject: [PATCH 4/4] Update CBORDecoder.php Signed-off-by: Kamil Tekiela --- libraries/classes/WebAuthn/CBORDecoder.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/classes/WebAuthn/CBORDecoder.php b/libraries/classes/WebAuthn/CBORDecoder.php index ab75bdd053..016821b1a2 100644 --- a/libraries/classes/WebAuthn/CBORDecoder.php +++ b/libraries/classes/WebAuthn/CBORDecoder.php @@ -158,8 +158,11 @@ final class CBORDecoder } /** @throws WebAuthnException */ - private function getFloatNumberOrSimpleValue(DataStream $stream, int $value, int $additionalInformation): mixed - { + private function getFloatNumberOrSimpleValue( + DataStream $stream, + int $value, + int $additionalInformation, + ): int|bool|float|null { switch ($additionalInformation) { case 20: return true;