diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a49f1b368..2e1f82a82 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -75,16 +75,6 @@ parameters: count: 2 path: src/Components/CaseExpression.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Condition\\:\\:build\\(\\) expects array\\, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Condition\\) given\\.$#" - count: 1 - path: src/Components/Condition.php - - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: src/Components/Condition.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CreateDefinition\\:\\:\\$name \\(string\\|null\\) does not accept mixed\\.$#" count: 2 @@ -335,11 +325,6 @@ parameters: count: 2 path: src/Components/OrderKeyword.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:build\\(\\) expects array\\, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\) given\\.$#" - count: 1 - path: src/Components/ParameterDefinition.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$inOut \\(string\\) does not accept string\\|null\\.$#" count: 1 @@ -365,11 +350,6 @@ parameters: count: 2 path: src/Components/ParameterDefinition.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: src/Components/ParameterDefinition.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|string\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#" count: 1 @@ -596,7 +576,7 @@ parameters: path: src/Statements/CreateStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:build\\(\\) expects array\\, array\\\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition, array\\\\|null given\\.$#" count: 1 path: src/Statements/CreateStatement.php @@ -825,6 +805,11 @@ parameters: count: 1 path: src/Utils/Formatter.php + - + message: "#^Binary operation \"&\" between int and int\\|string results in an error\\.$#" + count: 1 + path: src/Utils/Formatter.php + - message: "#^Binary operation \"&\\=\" between array\\\\>\\|bool\\|string\\|null and array\\\\>\\|bool\\|string\\|null results in an error\\.$#" count: 1 @@ -851,12 +836,12 @@ parameters: path: src/Utils/Formatter.php - - message: "#^Access to an undefined property object\\:\\:\\$alias\\.$#" + message: "#^Trying to invoke int\\\\|int\\<1, max\\>\\|non\\-falsy\\-string but it might not be a callable\\.$#" count: 1 - path: src/Utils/Query.php + path: src/Utils/Formatter.php - - message: "#^Access to an undefined property object\\:\\:\\$expr\\.$#" + message: "#^Argument of an invalid type array\\\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 path: src/Utils/Query.php @@ -865,11 +850,6 @@ parameters: count: 1 path: src/Utils/Query.php - - - message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: src/Utils/Query.php - - message: "#^Cannot access property \\$dest on PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\|null\\.$#" count: 1 @@ -890,11 +870,6 @@ parameters: count: 1 path: src/Utils/Query.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, object given\\.$#" - count: 1 - path: src/Utils/Query.php - - message: "#^Cannot access offset 'value' on mixed\\.$#" count: 3 @@ -961,7 +936,7 @@ parameters: path: tests/Builder/CreateStatementTest.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:build\\(\\) expects array\\, array\\\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition, array\\\\|null given\\.$#" count: 2 path: tests/Builder/CreateStatementTest.php @@ -1070,11 +1045,6 @@ parameters: count: 1 path: tests/Parser/SelectStatementTest.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\WithKeyword\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\WithKeyword, stdClass given\\.$#" - count: 1 - path: tests/Parser/WithStatementTest.php - - message: "#^Parameter \\#2 \\$list of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Query\\:\\:getClause\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\TokensList, PhpMyAdmin\\\\SqlParser\\\\TokensList\\|null given\\.$#" count: 9 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 303b23a37..1fb72626a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -128,30 +128,15 @@ - - $this - value]]]> - - string - - - expr]]> - - - expr]]> - $component $isOperator - - is_array($component) - @@ -485,24 +470,9 @@ - - $this - - - name]]> - name]]> - - inOut]]> - type]]> - - - inOut]]> - name]]> - type]]> - $component @@ -513,7 +483,6 @@ DataType::parse($parser, $list) - is_array($component) name)]]> @@ -1659,11 +1628,6 @@ has - - - new stdClass() - - $data diff --git a/src/Components/Condition.php b/src/Components/Condition.php index cbb5a7371..462c6d70f 100644 --- a/src/Components/Condition.php +++ b/src/Components/Condition.php @@ -221,7 +221,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param Condition[] $component the component to be built + * @param Condition[]|Condition $component the component to be built */ public static function build($component): string { diff --git a/src/Components/ParameterDefinition.php b/src/Components/ParameterDefinition.php index b94ee11fb..495d10822 100644 --- a/src/Components/ParameterDefinition.php +++ b/src/Components/ParameterDefinition.php @@ -141,7 +141,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param ParameterDefinition[] $component the component to be built + * @param ParameterDefinition[]|ParameterDefinition $component the component to be built */ public static function build($component): string { diff --git a/src/Components/WithKeyword.php b/src/Components/WithKeyword.php index 03df14795..4b92d53e2 100644 --- a/src/Components/WithKeyword.php +++ b/src/Components/WithKeyword.php @@ -50,10 +50,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = */ public static function build($component): string { - if (! $component instanceof WithKeyword) { - throw new RuntimeException('Can not build a component that is not a WithKeyword'); - } - if (! isset($component->statement)) { throw new RuntimeException('No statement inside WITH'); } diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index 6e2ac18bf..7356be37e 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\SqlParser\Lexer; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; -use stdClass; class WithStatementTest extends TestCase { @@ -134,12 +133,6 @@ public function testWithHasUnclosedParenthesis(): void $this->assertEquals($parserErrors[0][0], 'A closing bracket was expected.'); } - public function testBuildWrongWithKeyword(): void - { - $this->expectExceptionMessage('Can not build a component that is not a WithKeyword'); - WithKeyword::build(new stdClass()); - } - public function testBuildBadWithKeyword(): void { $this->expectExceptionMessage('No statement inside WITH');