Skip to content

Commit

Permalink
Merge pull request #545 from MauricioFauth/token-value-type
Browse files Browse the repository at this point in the history
Make Token::$value and Token::$keyword types more strict
  • Loading branch information
MauricioFauth committed Jan 24, 2024
2 parents d70677e + 43a6200 commit ac1004c
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 176 deletions.
82 changes: 26 additions & 56 deletions phpstan-baseline.neon
Expand Up @@ -85,6 +85,11 @@ parameters:
count: 3
path: src/Lexer.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Token\\:\\:\\$keyword \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
count: 1
path: src/Lexer.php

-
message: "#^Strict comparison using \\=\\=\\= between non\\-empty\\-array\\<non\\-empty\\-string, int\\> and array\\{\\} will always evaluate to false\\.$#"
count: 1
Expand Down Expand Up @@ -156,7 +161,7 @@ parameters:
path: src/Parsers/ArrayObjs.php

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

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

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

Expand All @@ -185,11 +190,6 @@ parameters:
count: 1
path: src/Parsers/DataTypes.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/Parsers/DataTypes.php

-
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\\>\\.$#"
count: 1
Expand All @@ -216,15 +216,10 @@ parameters:
path: src/Parsers/Expressions.php

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

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$subquery \\(string\\|null\\) does not accept mixed\\.$#"
count: 1
path: src/Parsers/Expressions.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\:\\:\\$parameters \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
count: 1
Expand All @@ -251,12 +246,12 @@ parameters:
path: src/Parsers/IntoKeywords.php

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

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

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

-
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\\>\\>\\.$#"
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\\>\\>\\.$#"
count: 1
path: src/Parsers/Keys.php

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

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

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

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

Expand Down Expand Up @@ -351,7 +346,7 @@ parameters:
path: src/Parsers/OrderKeywords.php

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

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

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

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

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

Expand Down Expand Up @@ -530,11 +525,6 @@ parameters:
count: 1
path: src/Statement.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/Statement.php

-
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\\.$#"
count: 1
Expand Down Expand Up @@ -606,12 +596,12 @@ parameters:
path: src/Statements/CreateStatement.php

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

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

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

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

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

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/Statements/ExplainStatement.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$connectionId \\(int\\|null\\) does not accept mixed\\.$#"
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$connectionId \\(int\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
count: 1
path: src/Statements/ExplainStatement.php

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

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

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

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

Expand All @@ -695,16 +680,6 @@ parameters:
count: 1
path: src/Statements/MaintenanceStatement.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:\\$endOption \\(string\\|null\\) does not accept mixed\\.$#"
count: 1
path: src/Statements/PurgeStatement.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:\\$logType \\(string\\|null\\) does not accept mixed\\.$#"
count: 1
path: src/Statements/PurgeStatement.php

-
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\\.$#"
count: 1
Expand Down Expand Up @@ -736,7 +711,7 @@ parameters:
path: src/Statements/TransactionStatement.php

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

Expand Down Expand Up @@ -815,11 +790,6 @@ parameters:
count: 1
path: src/Utils/Formatter.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
path: src/Utils/Formatter.php

-
message: "#^Parameter \\#1 \\$string of function str_repeat expects string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string given\\.$#"
count: 1
Expand Down

0 comments on commit ac1004c

Please sign in to comment.