Merge pull request #18422 from kamil-tekiela/narrow-types

Narrow some mixed return types
This commit is contained in:
Maurício Meneghini Fauth 2023-05-17 14:50:43 -03:00 committed by GitHub
commit 1039557d83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 51 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -4466,7 +4466,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
@ -4932,7 +4932,7 @@ parameters:
-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
count: 1
path: libraries/classes/Message.php
-
@ -4940,26 +4940,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
@ -6200,11 +6190,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
@ -8140,11 +8125,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

View File

@ -7255,19 +7255,19 @@
</RedundantPropertyInitializationCheck>
</file>
<file src="libraries/classes/Gis/GisVisualization.php">
<MixedAssignment>
<code>$pdf</code>
</MixedAssignment>
<MixedMethodCall>
<code>Output</code>
</MixedMethodCall>
<PossiblyInvalidArgument>
<code>$results</code>
</PossiblyInvalidArgument>
<PossiblyInvalidMethodCall>
<code>Output</code>
</PossiblyInvalidMethodCall>
<PossiblyInvalidOperand>
<code>$results</code>
<code>$results</code>
</PossiblyInvalidOperand>
<PossiblyUndefinedMethod>
<code>Output</code>
</PossiblyUndefinedMethod>
<RedundantCondition>
<code>mb_strtolower($userExtension) !== $requiredExtension</code>
<code>mb_strtolower($userExtension) !== $requiredExtension</code>
@ -8115,13 +8115,6 @@
</MixedArgument>
<MixedAssignment>
<code>$addMessage</code>
<code>$message</code>
<code>$message[$key]</code>
<code>$params</code>
<code>$string</code>
<code><![CDATA[$this->message]]></code>
<code><![CDATA[$this->params]]></code>
<code><![CDATA[$this->string]]></code>
<code>$val</code>
</MixedAssignment>
<MixedInferredReturnType>
@ -10310,7 +10303,6 @@
<code><![CDATA[$GLOBALS['timeout_passed']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code>$cell</code>
<code>$cell</code>
<code>$table[0]</code>
<code>$table[1]</code>
@ -10322,7 +10314,6 @@
<MixedAssignment>
<code><![CDATA[$GLOBALS['timeout_passed']]]></code>
<code>$cell</code>
<code>$cell</code>
</MixedAssignment>
<PossiblyUndefinedArrayOffset>
<code>$cellData[1]</code>
@ -12612,7 +12603,6 @@
<code><![CDATA[$oneResult['Status']]]></code>
<code>$sortCol</code>
<code><![CDATA[$statement->expr]]></code>
<code>Message::sanitize($warning)</code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code>$showTable</code>