Skip to content

Commit

Permalink
Fix incorrect return type
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed May 31, 2023
1 parent 64090cb commit 22b2cb8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 42 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,6 @@ parameters:
count: 12
path: src/Utils/CLI.php

-
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\CLI\\:\\:readStdin\\(\\) should return string\\|false but returns string\\|false\\|null\\.$#"
count: 1
path: src/Utils/CLI.php

-
message: "#^Parameter \\#1 \\$context of static method PhpMyAdmin\\\\SqlParser\\\\Context\\:\\:load\\(\\) expects string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -1035,11 +1030,6 @@ parameters:
count: 1
path: src/Utils/Tokens.php

-
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Tokens\\:\\:replaceTokens\\(\\) should return PhpMyAdmin\\\\SqlParser\\\\TokensList but returns PhpMyAdmin\\\\SqlParser\\\\TokensList\\|string\\.$#"
count: 1
path: src/Utils/Tokens.php

-
message: "#^Parameter \\#1 \\$string1 of function strcasecmp expects string, int\\|string given\\.$#"
count: 1
Expand Down
31 changes: 10 additions & 21 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.11.0@c9b192ab8400fdaf04b2b13d110575adc879aa90">
<files psalm-version="5.12.0@f90118cdeacd0088e7215e64c0c99ceca819e176">
<file src="src/Components/AlterOperation.php">
<ArgumentTypeCoercion>
<code><![CDATA[$component->partitions]]></code>
Expand Down Expand Up @@ -191,9 +191,6 @@
<InvalidArgument>
<code><![CDATA[$options['breakOnParentheses']]]></code>
</InvalidArgument>
<InvalidAttribute>
<code>\AllowDynamicProperties</code>
</InvalidAttribute>
<MixedArrayOffset>
<code><![CDATA[Parser::$statementParsers[$token->keyword]]]></code>
<code><![CDATA[self::$allowedKeywords[$token->keyword]]]></code>
Expand Down Expand Up @@ -236,6 +233,9 @@
<TypeDoesNotContainType>
<code><![CDATA[empty($options['field'])]]></code>
</TypeDoesNotContainType>
<UndefinedAttributeClass>
<code>\AllowDynamicProperties</code>
</UndefinedAttributeClass>
</file>
<file src="src/Components/ExpressionArray.php">
<InvalidArgument>
Expand Down Expand Up @@ -4905,6 +4905,9 @@
<code>getNextOfType</code>
<code>getNextOfType</code>
</PossiblyNullReference>
<UnsupportedPropertyReferenceUsage>
<code><![CDATA[$list = &$this->list]]></code>
</UnsupportedPropertyReferenceUsage>
</file>
<file src="src/Statement.php">
<DocblockTypeContradiction>
Expand All @@ -4914,9 +4917,6 @@
<code>$built[$field]</code>
<code><![CDATA[$parsedClauses[$token->value]]]></code>
</InvalidArgument>
<InvalidAttribute>
<code>\AllowDynamicProperties</code>
</InvalidAttribute>
<MethodSignatureMustProvideReturnType>
<code>__toString</code>
</MethodSignatureMustProvideReturnType>
Expand Down Expand Up @@ -4952,6 +4952,9 @@
<TypeDoesNotContainType>
<code>count($clauses) === 0</code>
</TypeDoesNotContainType>
<UndefinedAttributeClass>
<code>\AllowDynamicProperties</code>
</UndefinedAttributeClass>
<UnusedForeachValue>
<code>$index</code>
</UnusedForeachValue>
Expand Down Expand Up @@ -5296,9 +5299,6 @@
</PossiblyNullOperand>
</file>
<file src="src/Utils/CLI.php">
<InvalidNullableReturnType>
<code>string|false</code>
</InvalidNullableReturnType>
<InvalidReturnStatement>
<code>getopt($opt, $long)</code>
</InvalidReturnStatement>
Expand Down Expand Up @@ -5332,9 +5332,6 @@
<code>$params</code>
<code>$params</code>
</MixedAssignment>
<NullableReturnStatement>
<code>$stdin</code>
</NullableReturnStatement>
<PossiblyFalseArgument>
<code>$params</code>
<code>$params</code>
Expand Down Expand Up @@ -5539,12 +5536,6 @@
<InvalidArgument>
<code>$find[$k]</code>
</InvalidArgument>
<InvalidReturnStatement>
<code>$isList ? new TokensList($newList) : TokensList::build($newList)</code>
</InvalidReturnStatement>
<InvalidReturnType>
<code>TokensList</code>
</InvalidReturnType>
<MixedArgument>
<code><![CDATA[$list->tokens[$j]]]></code>
</MixedArgument>
Expand All @@ -5553,8 +5544,6 @@
<code>$newList</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$list->tokens[$i]]]></code>
<code><![CDATA[$list->tokens[$i]]]></code>
<code><![CDATA[$list->tokens[$i]]]></code>
<code><![CDATA[$list->tokens[$j]]]></code>
<code><![CDATA[$list->tokens[$j]]]></code>
Expand Down
5 changes: 1 addition & 4 deletions src/Utils/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ public function runTokenize()
return 1;
}

/**
* @return string|false
*/
public function readStdin()
public function readStdin(): string|false|null
{
$read = [STDIN];
$write = [];
Expand Down
14 changes: 7 additions & 7 deletions src/Utils/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public static function match(Token $token, array $pattern)
}

/**
* @param TokensList|string|UtfString $list
* @param Token[] $find
* @param Token[] $replace
*
* @return TokensList
* @param Token[] $find
* @param Token[] $replace
*/
public static function replaceTokens($list, array $find, array $replace)
{
public static function replaceTokens(
TokensList|string|UtfString $list,
array $find,
array $replace
): TokensList|string {
/**
* Whether the first parameter is a list.
*/
Expand Down

0 comments on commit 22b2cb8

Please sign in to comment.