Skip to content

Commit 4270681

Browse files
committed
Add type declarations to some class properties
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 091f86d commit 4270681

26 files changed

+82
-248
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -900,11 +900,6 @@ parameters:
900900
count: 1
901901
path: src/Lexer.php
902902

903-
-
904-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Lexer\\:\\:\\$PARSER_METHODS type has no value type specified in iterable type array\\.$#"
905-
count: 1
906-
path: src/Lexer.php
907-
908903
-
909904
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Lexer\\:\\:\\$delimiter \\(string\\) does not accept null\\.$#"
910905
count: 1
@@ -960,31 +955,11 @@ parameters:
960955
count: 1
961956
path: src/Statement.php
962957

963-
-
964-
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:getClauses\\(\\) return type has no value type specified in iterable type array\\.$#"
965-
count: 1
966-
path: src/Statement.php
967-
968958
-
969959
message: "#^PHPDoc tag @var has no value type specified in iterable type array\\.$#"
970960
count: 3
971961
path: src/Statement.php
972962

973-
-
974-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$CLAUSES type has no value type specified in iterable type array\\.$#"
975-
count: 1
976-
path: src/Statement.php
977-
978-
-
979-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$END_OPTIONS type has no value type specified in iterable type array\\.$#"
980-
count: 1
981-
path: src/Statement.php
982-
983-
-
984-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
985-
count: 1
986-
path: src/Statement.php
987-
988963
-
989964
message: "#^Strict comparison using \\=\\=\\= between int\\<1, max\\> and 0 will always evaluate to false\\.$#"
990965
count: 1
@@ -1005,21 +980,6 @@ parameters:
1005980
count: 1
1006981
path: src/Statements/AlterStatement.php
1007982

1008-
-
1009-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\AlterStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1010-
count: 1
1011-
path: src/Statements/AlterStatement.php
1012-
1013-
-
1014-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\AnalyzeStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1015-
count: 1
1016-
path: src/Statements/AnalyzeStatement.php
1017-
1018-
-
1019-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\BackupStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1020-
count: 1
1021-
path: src/Statements/BackupStatement.php
1022-
1023983
-
1024984
message: "#^Cannot access property \\$name on PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\|null\\.$#"
1025985
count: 1
@@ -1030,16 +990,6 @@ parameters:
1030990
count: 2
1031991
path: src/Statements/CallStatement.php
1032992

1033-
-
1034-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CheckStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1035-
count: 1
1036-
path: src/Statements/CheckStatement.php
1037-
1038-
-
1039-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ChecksumStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1040-
count: 1
1041-
path: src/Statements/ChecksumStatement.php
1042-
1043993
-
1044994
message: "#^Cannot access property \\$value on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
1045995
count: 2
@@ -1085,11 +1035,6 @@ parameters:
10851035
count: 1
10861036
path: src/Statements/CreateStatement.php
10871037

1088-
-
1089-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1090-
count: 1
1091-
path: src/Statements/CreateStatement.php
1092-
10931038
-
10941039
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$TABLE_OPTIONS type has no value type specified in iterable type array\\.$#"
10951040
count: 1
@@ -1150,31 +1095,6 @@ parameters:
11501095
count: 1
11511096
path: src/Statements/DeleteStatement.php
11521097

1153-
-
1154-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\DeleteStatement\\:\\:\\$CLAUSES type has no value type specified in iterable type array\\.$#"
1155-
count: 1
1156-
path: src/Statements/DeleteStatement.php
1157-
1158-
-
1159-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\DeleteStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1160-
count: 1
1161-
path: src/Statements/DeleteStatement.php
1162-
1163-
-
1164-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\DropStatement\\:\\:\\$CLAUSES type has no value type specified in iterable type array\\.$#"
1165-
count: 1
1166-
path: src/Statements/DropStatement.php
1167-
1168-
-
1169-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\DropStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1170-
count: 1
1171-
path: src/Statements/DropStatement.php
1172-
1173-
-
1174-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\InsertStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1175-
count: 1
1176-
path: src/Statements/InsertStatement.php
1177-
11781098
-
11791099
message: "#^Cannot access property \\$keyword on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
11801100
count: 2
@@ -1205,11 +1125,6 @@ parameters:
12051125
count: 1
12061126
path: src/Statements/LoadStatement.php
12071127

1208-
-
1209-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\LoadStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1210-
count: 1
1211-
path: src/Statements/LoadStatement.php
1212-
12131128
-
12141129
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\LoadStatement\\:\\:\\$partition \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
12151130
count: 1
@@ -1220,11 +1135,6 @@ parameters:
12201135
count: 1
12211136
path: src/Statements/MaintenanceStatement.php
12221137

1223-
-
1224-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\OptimizeStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1225-
count: 1
1226-
path: src/Statements/OptimizeStatement.php
1227-
12281138
-
12291139
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:parseExpectedKeyword\\(\\) has parameter \\$expectedKeywords with no value type specified in iterable type array\\.$#"
12301140
count: 1
@@ -1250,11 +1160,6 @@ parameters:
12501160
count: 1
12511161
path: src/Statements/RenameStatement.php
12521162

1253-
-
1254-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\RepairStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1255-
count: 1
1256-
path: src/Statements/RepairStatement.php
1257-
12581163
-
12591164
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\:\\:build\\(\\) expects array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\>, PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d given\\.$#"
12601165
count: 1
@@ -1265,36 +1170,11 @@ parameters:
12651170
count: 1
12661171
path: src/Statements/ReplaceStatement.php
12671172

1268-
-
1269-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ReplaceStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1270-
count: 1
1271-
path: src/Statements/ReplaceStatement.php
1272-
12731173
-
12741174
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ReplaceStatement\\:\\:\\$values \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\>\\.$#"
12751175
count: 1
12761176
path: src/Statements/ReplaceStatement.php
12771177

1278-
-
1279-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\RestoreStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1280-
count: 1
1281-
path: src/Statements/RestoreStatement.php
1282-
1283-
-
1284-
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\:\\:getClauses\\(\\) return type has no value type specified in iterable type array\\.$#"
1285-
count: 1
1286-
path: src/Statements/SelectStatement.php
1287-
1288-
-
1289-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\:\\:\\$CLAUSES type has no value type specified in iterable type array\\.$#"
1290-
count: 1
1291-
path: src/Statements/SelectStatement.php
1292-
1293-
-
1294-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1295-
count: 1
1296-
path: src/Statements/SelectStatement.php
1297-
12981178
-
12991179
message: "#^PHPDoc type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\>\\|null of property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SetStatement\\:\\:\\$options is not covariant with PHPDoc type PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null of overridden property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$options\\.$#"
13001180
count: 1
@@ -1315,26 +1195,6 @@ parameters:
13151195
count: 1
13161196
path: src/Statements/SetStatement.php
13171197

1318-
-
1319-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SetStatement\\:\\:\\$CLAUSES type has no value type specified in iterable type array\\.$#"
1320-
count: 1
1321-
path: src/Statements/SetStatement.php
1322-
1323-
-
1324-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SetStatement\\:\\:\\$END_OPTIONS type has no value type specified in iterable type array\\.$#"
1325-
count: 1
1326-
path: src/Statements/SetStatement.php
1327-
1328-
-
1329-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SetStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1330-
count: 1
1331-
path: src/Statements/SetStatement.php
1332-
1333-
-
1334-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ShowStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1335-
count: 1
1336-
path: src/Statements/ShowStatement.php
1337-
13381198
-
13391199
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Statement\\>\\|null supplied for foreach, only iterables are supported\\.$#"
13401200
count: 1
@@ -1355,26 +1215,6 @@ parameters:
13551215
count: 1
13561216
path: src/Statements/TransactionStatement.php
13571217

1358-
-
1359-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\TransactionStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1360-
count: 1
1361-
path: src/Statements/TransactionStatement.php
1362-
1363-
-
1364-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\TruncateStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1365-
count: 1
1366-
path: src/Statements/TruncateStatement.php
1367-
1368-
-
1369-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\UpdateStatement\\:\\:\\$CLAUSES type has no value type specified in iterable type array\\.$#"
1370-
count: 1
1371-
path: src/Statements/UpdateStatement.php
1372-
1373-
-
1374-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\UpdateStatement\\:\\:\\$OPTIONS type has no value type specified in iterable type array\\.$#"
1375-
count: 1
1376-
path: src/Statements/UpdateStatement.php
1377-
13781218
-
13791219
message: "#^Parameter \\#1 \\$name of class PhpMyAdmin\\\\SqlParser\\\\Components\\\\WithKeyword constructor expects string, mixed given\\.$#"
13801220
count: 1
@@ -1415,16 +1255,6 @@ parameters:
14151255
count: 1
14161256
path: src/Tools/ContextGenerator.php
14171257

1418-
-
1419-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Tools\\\\ContextGenerator\\:\\:\\$LABELS_FLAGS type has no value type specified in iterable type array\\.$#"
1420-
count: 1
1421-
path: src/Tools/ContextGenerator.php
1422-
1423-
-
1424-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Tools\\\\ContextGenerator\\:\\:\\$LINKS type has no value type specified in iterable type array\\.$#"
1425-
count: 1
1426-
path: src/Tools/ContextGenerator.php
1427-
14281258
-
14291259
message: "#^Argument of an invalid type array\\<int, string\\>\\|false supplied for foreach, only iterables are supported\\.$#"
14301260
count: 1

psalm-baseline.xml

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,8 @@
752752
<code>$this-&gt;str[$this-&gt;last]</code>
753753
<code>$this-&gt;str[$this-&gt;last]</code>
754754
</MixedArrayAccess>
755-
<MixedAssignment occurrences="3">
755+
<MixedAssignment occurrences="2">
756756
<code>$lastToken</code>
757-
<code>$method</code>
758757
<code>$token</code>
759758
</MixedAssignment>
760759
<MixedOperand occurrences="7">
@@ -910,15 +909,7 @@
910909
<MixedArgument occurrences="1">
911910
<code>$options</code>
912911
</MixedArgument>
913-
<MixedArgumentTypeCoercion occurrences="4">
914-
<code>$clauseType</code>
915-
<code>$clauseType</code>
916-
<code>$clauseType</code>
917-
<code>$clauseType</code>
918-
</MixedArgumentTypeCoercion>
919-
<MixedArrayAccess occurrences="7">
920-
<code>$clause[0]</code>
921-
<code>$clause[1]</code>
912+
<MixedArrayAccess occurrences="5">
922913
<code>Parser::$KEYWORD_PARSERS[$name]['class']</code>
923914
<code>Parser::$KEYWORD_PARSERS[$name]['field']</code>
924915
<code>Parser::$KEYWORD_PARSERS[$tokenValue]['class']</code>
@@ -939,9 +930,8 @@
939930
<code>Parser::$KEYWORD_PARSERS[$tokenValue]</code>
940931
<code>Parser::$STATEMENT_PARSERS[$token-&gt;keyword]</code>
941932
</MixedArrayTypeCoercion>
942-
<MixedAssignment occurrences="5">
933+
<MixedAssignment occurrences="4">
943934
<code>$class</code>
944-
<code>$clause</code>
945935
<code>$field</code>
946936
<code>$options</code>
947937
<code>$tokenValue</code>
@@ -1135,11 +1125,6 @@
11351125
<code>$this-&gt;options</code>
11361126
</PossiblyNullOperand>
11371127
</file>
1138-
<file src="src/Statements/SelectStatement.php">
1139-
<NonInvariantDocblockPropertyType occurrences="1">
1140-
<code>$END_OPTIONS</code>
1141-
</NonInvariantDocblockPropertyType>
1142-
</file>
11431128
<file src="src/Statements/SetStatement.php">
11441129
<InvalidArgument occurrences="1">
11451130
<code>$this-&gt;options</code>
@@ -1207,37 +1192,16 @@
12071192
<code>$wordsByLen</code>
12081193
<code>($line - $spaces) / ($len + 9)</code>
12091194
</MixedArgument>
1210-
<MixedArgumentTypeCoercion occurrences="2">
1211-
<code>$label</code>
1212-
<code>$label</code>
1213-
</MixedArgumentTypeCoercion>
1214-
<MixedArrayOffset occurrences="4">
1215-
<code>$ret[$type]</code>
1216-
<code>$ret[$type]</code>
1217-
<code>$ret[$type]</code>
1218-
<code>$ret[$type]</code>
1219-
</MixedArrayOffset>
1220-
<MixedAssignment occurrences="13">
1221-
<code>$flags</code>
1195+
<MixedAssignment occurrences="6">
12221196
<code>$len</code>
1223-
<code>$type</code>
1224-
<code>$type</code>
1225-
<code>$type</code>
1226-
<code>$type</code>
1227-
<code>$types[$value]</code>
1228-
<code>$types[$value]</code>
12291197
<code>$word</code>
12301198
<code>$words</code>
12311199
<code>$wordsByLen</code>
12321200
<code>$wordsByLen</code>
12331201
<code>$wordsByType</code>
12341202
</MixedAssignment>
1235-
<MixedOperand occurrences="5">
1236-
<code>$flags</code>
1203+
<MixedOperand occurrences="1">
12371204
<code>$len</code>
1238-
<code>$type</code>
1239-
<code>$type</code>
1240-
<code>$types[$value]</code>
12411205
</MixedOperand>
12421206
<RedundantCondition occurrences="2">
12431207
<code>++$i !== $count</code>

src/Lexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Lexer extends Core
5050
/**
5151
* A list of methods that are used in lexing the SQL query.
5252
*
53-
* @var array
53+
* @var string[]
5454
*/
5555
public static $PARSER_METHODS = [
5656
// It is best to put the parsers in order of their complexity

0 commit comments

Comments
 (0)