Skip to content

Commit d25cf7e

Browse files
committed
Narrow down return types
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 8f524d7 commit d25cf7e

3 files changed

Lines changed: 18 additions & 68 deletions

File tree

phpstan-baseline.neon

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -886,50 +886,20 @@ parameters:
886886
path: src/Tools/TestGenerator.php
887887

888888
-
889-
message: "#^Cannot access offset 'a' on mixed\\.$#"
890-
count: 3
891-
path: src/Utils/CLI.php
892-
893-
-
894-
message: "#^Cannot access offset 'c' on mixed\\.$#"
895-
count: 2
896-
path: src/Utils/CLI.php
897-
898-
-
899-
message: "#^Cannot access offset 'f' on mixed\\.$#"
900-
count: 1
901-
path: src/Utils/CLI.php
902-
903-
-
904-
message: "#^Cannot access offset 'h' on mixed\\.$#"
905-
count: 3
906-
path: src/Utils/CLI.php
907-
908-
-
909-
message: "#^Cannot access offset 'q' on mixed\\.$#"
910-
count: 12
911-
path: src/Utils/CLI.php
912-
913-
-
914-
message: "#^Parameter \\#1 \\$context of static method PhpMyAdmin\\\\SqlParser\\\\Context\\:\\:load\\(\\) expects string, mixed given\\.$#"
889+
message: "#^Parameter \\#1 \\$context of static method PhpMyAdmin\\\\SqlParser\\\\Context\\:\\:load\\(\\) expects string, string\\|false given\\.$#"
915890
count: 1
916891
path: src/Utils/CLI.php
917892

918893
-
919-
message: "#^Parameter \\#1 \\$query of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Formatter\\:\\:format\\(\\) expects string, mixed given\\.$#"
894+
message: "#^Parameter \\#1 \\$query of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Formatter\\:\\:format\\(\\) expects string, string\\|false given\\.$#"
920895
count: 1
921896
path: src/Utils/CLI.php
922897

923898
-
924-
message: "#^Parameter \\#1 \\$str of class PhpMyAdmin\\\\SqlParser\\\\Lexer constructor expects PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string, mixed given\\.$#"
899+
message: "#^Parameter \\#1 \\$str of class PhpMyAdmin\\\\SqlParser\\\\Lexer constructor expects PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string, string\\|false given\\.$#"
925900
count: 2
926901
path: src/Utils/CLI.php
927902

928-
-
929-
message: "#^Parameter \\#2 \\$options of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Formatter\\:\\:format\\(\\) expects array\\<string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string\\>, array\\<string, mixed\\> given\\.$#"
930-
count: 1
931-
path: src/Utils/CLI.php
932-
933903
-
934904
message: "#^Argument of an invalid type array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string supplied for foreach, only iterables are supported\\.$#"
935905
count: 1

psalm-baseline.xml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@
191191
<InvalidArgument>
192192
<code><![CDATA[$options['breakOnParentheses']]]></code>
193193
</InvalidArgument>
194-
<InvalidAttribute>
195-
<code>\AllowDynamicProperties</code>
196-
</InvalidAttribute>
197194
<MixedArrayOffset>
198195
<code><![CDATA[Parser::$statementParsers[$token->keyword]]]></code>
199196
<code><![CDATA[self::$allowedKeywords[$token->keyword]]]></code>
@@ -236,6 +233,9 @@
236233
<TypeDoesNotContainType>
237234
<code><![CDATA[empty($options['field'])]]></code>
238235
</TypeDoesNotContainType>
236+
<UndefinedAttributeClass>
237+
<code>\AllowDynamicProperties</code>
238+
</UndefinedAttributeClass>
239239
</file>
240240
<file src="src/Components/ExpressionArray.php">
241241
<InvalidArgument>
@@ -4914,9 +4914,6 @@
49144914
<code>$built[$field]</code>
49154915
<code><![CDATA[$parsedClauses[$token->value]]]></code>
49164916
</InvalidArgument>
4917-
<InvalidAttribute>
4918-
<code>\AllowDynamicProperties</code>
4919-
</InvalidAttribute>
49204917
<MethodSignatureMustProvideReturnType>
49214918
<code>__toString</code>
49224919
</MethodSignatureMustProvideReturnType>
@@ -4952,6 +4949,9 @@
49524949
<TypeDoesNotContainType>
49534950
<code>count($clauses) === 0</code>
49544951
</TypeDoesNotContainType>
4952+
<UndefinedAttributeClass>
4953+
<code>\AllowDynamicProperties</code>
4954+
</UndefinedAttributeClass>
49554955
<UnusedForeachValue>
49564956
<code>$index</code>
49574957
</UnusedForeachValue>
@@ -5304,36 +5304,16 @@
53045304
<InvalidReturnType>
53055305
<code>string[]|false[]|false</code>
53065306
</InvalidReturnType>
5307-
<MixedArgument>
5308-
<code><![CDATA[$params['c']]]></code>
5309-
<code><![CDATA[$params['q']]]></code>
5310-
<code><![CDATA[$params['q']]]></code>
5311-
<code><![CDATA[$params['q']]]></code>
5312-
</MixedArgument>
53135307
<MixedArgumentTypeCoercion>
53145308
<code>$idx</code>
5315-
<code><![CDATA[['type' => $params['f']]]]></code>
53165309
</MixedArgumentTypeCoercion>
5317-
<MixedArrayAccess>
5310+
<PossiblyFalseArgument>
5311+
<code>$params</code>
5312+
<code>$params</code>
53185313
<code><![CDATA[$params['c']]]></code>
5319-
<code><![CDATA[$params['f']]]></code>
53205314
<code><![CDATA[$params['q']]]></code>
53215315
<code><![CDATA[$params['q']]]></code>
53225316
<code><![CDATA[$params['q']]]></code>
5323-
</MixedArrayAccess>
5324-
<MixedArrayAssignment>
5325-
<code><![CDATA[$params['q']]]></code>
5326-
<code><![CDATA[$params['q']]]></code>
5327-
<code><![CDATA[$params['q']]]></code>
5328-
</MixedArrayAssignment>
5329-
<MixedAssignment>
5330-
<code>$params</code>
5331-
<code>$params</code>
5332-
<code>$params</code>
5333-
</MixedAssignment>
5334-
<PossiblyFalseArgument>
5335-
<code>$params</code>
5336-
<code>$params</code>
53375317
</PossiblyFalseArgument>
53385318
</file>
53395319
<file src="src/Utils/Error.php">

src/Utils/CLI.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function getopt($opt, $long): array|false
6868
}
6969

7070
/**
71-
* @return mixed|false
71+
* @return string[]|false[]|false
7272
*/
73-
public function parseHighlight()
73+
public function parseHighlight(): array|false
7474
{
7575
$longopts = [
7676
'help',
@@ -151,9 +151,9 @@ public function usageLint()
151151
}
152152

153153
/**
154-
* @return mixed
154+
* @return string[]|false[]|false
155155
*/
156-
public function parseLint()
156+
public function parseLint(): array|false
157157
{
158158
$longopts = [
159159
'help',
@@ -230,9 +230,9 @@ public function usageTokenize()
230230
}
231231

232232
/**
233-
* @return mixed
233+
* @return string[]|false[]|false
234234
*/
235-
public function parseTokenize()
235+
public function parseTokenize(): array|false
236236
{
237237
$longopts = [
238238
'help',

0 commit comments

Comments
 (0)