Skip to content

Commit ac1004c

Browse files
Merge pull request #545 from MauricioFauth/token-value-type
Make Token::$value and Token::$keyword types more strict
2 parents d70677e + 43a6200 commit ac1004c

File tree

4 files changed

+106
-176
lines changed

4 files changed

+106
-176
lines changed

phpstan-baseline.neon

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ parameters:
8585
count: 3
8686
path: src/Lexer.php
8787

88+
-
89+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Token\\:\\:\\$keyword \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
90+
count: 1
91+
path: src/Lexer.php
92+
8893
-
8994
message: "#^Strict comparison using \\=\\=\\= between non\\-empty\\-array\\<non\\-empty\\-string, int\\> and array\\{\\} will always evaluate to false\\.$#"
9095
count: 1
@@ -156,7 +161,7 @@ parameters:
156161
path: src/Parsers/ArrayObjs.php
157162

158163
-
159-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\:\\:\\$alias \\(string\\|null\\) does not accept mixed\\.$#"
164+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\:\\:\\$alias \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
160165
count: 1
161166
path: src/Parsers/CaseExpressions.php
162167

@@ -171,7 +176,7 @@ parameters:
171176
path: src/Parsers/CaseExpressions.php
172177

173178
-
174-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CreateDefinition\\:\\:\\$name \\(string\\|null\\) does not accept mixed\\.$#"
179+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CreateDefinition\\:\\:\\$name \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
175180
count: 2
176181
path: src/Parsers/CreateDefinitions.php
177182

@@ -185,11 +190,6 @@ parameters:
185190
count: 1
186191
path: src/Parsers/DataTypes.php
187192

188-
-
189-
message: "#^Cannot cast mixed to string\\.$#"
190-
count: 1
191-
path: src/Parsers/DataTypes.php
192-
193193
-
194194
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Parsers\\\\ExpressionArray\\:\\:parse\\(\\) should return array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\> but returns array\\<int\\<0, max\\>, PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\>\\.$#"
195195
count: 1
@@ -216,15 +216,10 @@ parameters:
216216
path: src/Parsers/Expressions.php
217217

218218
-
219-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$alias \\(string\\|null\\) does not accept mixed\\.$#"
219+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$alias \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
220220
count: 3
221221
path: src/Parsers/Expressions.php
222222

223-
-
224-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$subquery \\(string\\|null\\) does not accept mixed\\.$#"
225-
count: 1
226-
path: src/Parsers/Expressions.php
227-
228223
-
229224
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\:\\:\\$parameters \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
230225
count: 1
@@ -251,12 +246,12 @@ parameters:
251246
path: src/Parsers/IntoKeywords.php
252247

253248
-
254-
message: "#^Parameter \\#3 \\$keyword of method PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\:\\:parseFileOptions\\(\\) expects string, mixed given\\.$#"
249+
message: "#^Parameter \\#3 \\$keyword of method PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\:\\:parseFileOptions\\(\\) expects string, string\\|null given\\.$#"
255250
count: 2
256251
path: src/Parsers/IntoKeywords.php
257252

258253
-
259-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\:\\:\\$dest \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|string\\|null\\) does not accept mixed\\.$#"
254+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\:\\:\\$dest \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
260255
count: 1
261256
path: src/Parsers/IntoKeywords.php
262257

@@ -266,27 +261,27 @@ parameters:
266261
path: src/Parsers/JoinKeywords.php
267262

268263
-
269-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$columns \\(array\\<array\\{name\\?\\: string, length\\?\\: int, order\\?\\: string\\}\\>\\) does not accept non\\-empty\\-array\\<array\\<'length'\\|'name'\\|'order', mixed\\>\\>\\.$#"
264+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$columns \\(array\\<array\\{name\\?\\: string, length\\?\\: int, order\\?\\: string\\}\\>\\) does not accept non\\-empty\\-array\\<array\\<'length'\\|'name'\\|'order', bool\\|float\\|int\\|string\\>\\>\\.$#"
270265
count: 1
271266
path: src/Parsers/Keys.php
272267

273268
-
274-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$name \\(string\\|null\\) does not accept mixed\\.$#"
269+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$name \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
275270
count: 1
276271
path: src/Parsers/Keys.php
277272

278273
-
279-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$type \\(string\\|null\\) does not accept mixed\\.$#"
274+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$type \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
280275
count: 1
281276
path: src/Parsers/Keys.php
282277

283278
-
284-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$offset \\(int\\|string\\) does not accept mixed\\.$#"
279+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$offset \\(int\\|string\\) does not accept bool\\|float\\|int\\|string\\.$#"
285280
count: 1
286281
path: src/Parsers/Limits.php
287282

288283
-
289-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$rowCount \\(int\\|string\\) does not accept mixed\\.$#"
284+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$rowCount \\(int\\|string\\) does not accept bool\\|float\\|int\\|string\\.$#"
290285
count: 1
291286
path: src/Parsers/Limits.php
292287

@@ -351,7 +346,7 @@ parameters:
351346
path: src/Parsers/OrderKeywords.php
352347

353348
-
354-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$name \\(string\\) does not accept mixed\\.$#"
349+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$name \\(string\\) does not accept bool\\|float\\|int\\|string\\.$#"
355350
count: 1
356351
path: src/Parsers/ParameterDefinitions.php
357352

@@ -371,7 +366,7 @@ parameters:
371366
path: src/Parsers/PartitionDefinitions.php
372367

373368
-
374-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$name \\(string\\) does not accept mixed\\.$#"
369+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$name \\(string\\) does not accept bool\\|float\\|int\\|string\\.$#"
375370
count: 1
376371
path: src/Parsers/PartitionDefinitions.php
377372

@@ -381,7 +376,7 @@ parameters:
381376
path: src/Parsers/PartitionDefinitions.php
382377

383378
-
384-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$type \\(string\\) does not accept mixed\\.$#"
379+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$type \\(string\\) does not accept bool\\|float\\|int\\|string\\.$#"
385380
count: 1
386381
path: src/Parsers/PartitionDefinitions.php
387382

@@ -530,11 +525,6 @@ parameters:
530525
count: 1
531526
path: src/Statement.php
532527

533-
-
534-
message: "#^Cannot cast mixed to string\\.$#"
535-
count: 1
536-
path: src/Statement.php
537-
538528
-
539529
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
540530
count: 1
@@ -606,12 +596,12 @@ parameters:
606596
path: src/Statements/CreateStatement.php
607597

608598
-
609-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$partitionsNum \\(int\\|null\\) does not accept mixed\\.$#"
599+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$partitionsNum \\(int\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
610600
count: 1
611601
path: src/Statements/CreateStatement.php
612602

613603
-
614-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$subpartitionsNum \\(int\\|null\\) does not accept mixed\\.$#"
604+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$subpartitionsNum \\(int\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
615605
count: 1
616606
path: src/Statements/CreateStatement.php
617607

@@ -626,7 +616,7 @@ parameters:
626616
path: src/Statements/DeleteStatement.php
627617

628618
-
629-
message: "#^Parameter \\#1 \\$haystack of function stripos expects string, mixed given\\.$#"
619+
message: "#^Parameter \\#1 \\$haystack of function stripos expects string, string\\|null given\\.$#"
630620
count: 1
631621
path: src/Statements/DeleteStatement.php
632622

@@ -641,22 +631,17 @@ parameters:
641631
path: src/Statements/ExplainStatement.php
642632

643633
-
644-
message: "#^Cannot cast mixed to string\\.$#"
645-
count: 1
646-
path: src/Statements/ExplainStatement.php
647-
648-
-
649-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$connectionId \\(int\\|null\\) does not accept mixed\\.$#"
634+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$connectionId \\(int\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
650635
count: 1
651636
path: src/Statements/ExplainStatement.php
652637

653638
-
654-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$explainedDatabase \\(string\\|null\\) does not accept mixed\\.$#"
639+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$explainedDatabase \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
655640
count: 1
656641
path: src/Statements/ExplainStatement.php
657642

658643
-
659-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$explainedTable \\(string\\|null\\) does not accept mixed\\.$#"
644+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$explainedTable \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
660645
count: 1
661646
path: src/Statements/ExplainStatement.php
662647

@@ -681,7 +666,7 @@ parameters:
681666
path: src/Statements/LoadStatement.php
682667

683668
-
684-
message: "#^Parameter \\#3 \\$keyword of method PhpMyAdmin\\\\SqlParser\\\\Statements\\\\LoadStatement\\:\\:parseFileOptions\\(\\) expects string, mixed given\\.$#"
669+
message: "#^Parameter \\#3 \\$keyword of method PhpMyAdmin\\\\SqlParser\\\\Statements\\\\LoadStatement\\:\\:parseFileOptions\\(\\) expects string, bool\\|float\\|int\\|string given\\.$#"
685670
count: 1
686671
path: src/Statements/LoadStatement.php
687672

@@ -695,16 +680,6 @@ parameters:
695680
count: 1
696681
path: src/Statements/MaintenanceStatement.php
697682

698-
-
699-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:\\$endOption \\(string\\|null\\) does not accept mixed\\.$#"
700-
count: 1
701-
path: src/Statements/PurgeStatement.php
702-
703-
-
704-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:\\$logType \\(string\\|null\\) does not accept mixed\\.$#"
705-
count: 1
706-
path: src/Statements/PurgeStatement.php
707-
708683
-
709684
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Parsers\\\\RenameOperations\\:\\:buildAll\\(\\) expects array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\>, array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\>\\|null given\\.$#"
710685
count: 1
@@ -736,7 +711,7 @@ parameters:
736711
path: src/Statements/TransactionStatement.php
737712

738713
-
739-
message: "#^Parameter \\#1 \\$name of class PhpMyAdmin\\\\SqlParser\\\\Components\\\\WithKeyword constructor expects string, mixed given\\.$#"
714+
message: "#^Parameter \\#1 \\$name of class PhpMyAdmin\\\\SqlParser\\\\Components\\\\WithKeyword constructor expects string, bool\\|float\\|int\\|string given\\.$#"
740715
count: 1
741716
path: src/Statements/WithStatement.php
742717

@@ -815,11 +790,6 @@ parameters:
815790
count: 1
816791
path: src/Utils/Formatter.php
817792

818-
-
819-
message: "#^Cannot cast mixed to string\\.$#"
820-
count: 2
821-
path: src/Utils/Formatter.php
822-
823793
-
824794
message: "#^Parameter \\#1 \\$string of function str_repeat expects string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string given\\.$#"
825795
count: 1

0 commit comments

Comments
 (0)