diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 591e52f3b..a5f50405d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -25,16 +25,6 @@ parameters: count: 3 path: src/Components/AlterOperation.php - - - message: "#^Cannot access property \\$values on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#" - count: 1 - path: src/Components/Array2d.php - - - - message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\:\\:parse\\(\\) should return array\\ but returns array\\, array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\>\\.$#" - count: 1 - path: src/Components/Array2d.php - - message: "#^Cannot access an offset on array\\, mixed\\>\\|static\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\)\\.$#" count: 1 @@ -580,11 +570,6 @@ parameters: count: 1 path: src/Statements/DeleteStatement.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ExpressionArray\\:\\:buildAll\\(\\) expects array\\, array\\ given\\.$#" - count: 1 - path: src/Statements/DeleteStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray, PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null given\\.$#" count: 1 @@ -675,16 +660,6 @@ parameters: count: 1 path: src/Statements/RenameStatement.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\:\\:buildAll\\(\\) expects array\\, array\\ given\\.$#" - count: 1 - path: src/Statements/ReplaceStatement.php - - - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ReplaceStatement\\:\\:\\$values \\(array\\\\|null\\) does not accept array\\\\.$#" - count: 1 - path: src/Statements/ReplaceStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray, PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null given\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 28aad033e..cafb75939 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -59,18 +59,9 @@ - - $ret - - - ArrayObj[] - $component - - values]]> - @@ -221,6 +212,9 @@ $expr $expr + + buildAll + @@ -988,9 +982,6 @@ - - order]]> - keyword]]> @@ -1098,12 +1089,6 @@ - - values]]> - - - Array2d::parse($parser, $list) - into]]> options]]> diff --git a/src/Components/Array2d.php b/src/Components/Array2d.php index 82c4b7e55..96605a02f 100644 --- a/src/Components/Array2d.php +++ b/src/Components/Array2d.php @@ -77,6 +77,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = break; } + /** @var ArrayObj $arr */ $arr = ArrayObj::parse($parser, $list, $options); $arrCount = count($arr->values); if ($count === -1) { @@ -120,14 +121,6 @@ public static function build($component): string throw new RuntimeException(Translator::gettext('Not implemented yet.')); } - /** - * @param ArrayObj[] $component the component to be built - */ - public static function buildAll(array $component): string - { - return ArrayObj::buildAll($component); - } - public function __toString(): string { return static::build($this); diff --git a/src/Components/IndexHint.php b/src/Components/IndexHint.php index 5245d4ca0..40d041fc6 100644 --- a/src/Components/IndexHint.php +++ b/src/Components/IndexHint.php @@ -186,7 +186,7 @@ public static function build($component): string $ret .= 'FOR ' . $component->for . ' '; } - return $ret . ExpressionArray::buildAll($component->indexes); + return $ret . Expression::buildAll($component->indexes); } /** diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php index becd48cfc..493a53e75 100644 --- a/src/Components/IntoKeyword.php +++ b/src/Components/IntoKeyword.php @@ -270,7 +270,7 @@ public static function build($component): string } if (isset($component->values)) { - return ExpressionArray::buildAll($component->values); + return Expression::buildAll($component->values); } $ret = 'OUTFILE "' . $component->dest . '"'; diff --git a/src/Statements/DeleteStatement.php b/src/Statements/DeleteStatement.php index 652524e07..6a6a105d2 100644 --- a/src/Statements/DeleteStatement.php +++ b/src/Statements/DeleteStatement.php @@ -165,11 +165,11 @@ public function build() $ret = 'DELETE ' . OptionsArray::build($this->options); if ($this->columns !== null && $this->columns !== []) { - $ret .= ' ' . ExpressionArray::buildAll($this->columns); + $ret .= ' ' . Expression::buildAll($this->columns); } if ($this->from !== null && $this->from !== []) { - $ret .= ' FROM ' . ExpressionArray::buildAll($this->from); + $ret .= ' FROM ' . Expression::buildAll($this->from); } if ($this->join !== null && $this->join !== []) { @@ -177,7 +177,7 @@ public function build() } if ($this->using !== null && $this->using !== []) { - $ret .= ' USING ' . ExpressionArray::buildAll($this->using); + $ret .= ' USING ' . Expression::buildAll($this->using); } if ($this->where !== null && $this->where !== []) { @@ -185,7 +185,7 @@ public function build() } if ($this->order !== null && $this->order !== []) { - $ret .= ' ORDER BY ' . ExpressionArray::buildAll($this->order); + $ret .= ' ORDER BY ' . OrderKeyword::buildAll($this->order); } if ($this->limit !== null && strlen((string) $this->limit) > 0) { diff --git a/src/Statements/LoadStatement.php b/src/Statements/LoadStatement.php index 99b6063dd..508bc0b07 100644 --- a/src/Statements/LoadStatement.php +++ b/src/Statements/LoadStatement.php @@ -214,7 +214,7 @@ public function build() } if ($this->columnNamesOrUserVariables !== null && $this->columnNamesOrUserVariables !== []) { - $ret .= ' ' . ExpressionArray::buildAll($this->columnNamesOrUserVariables); + $ret .= ' ' . Expression::buildAll($this->columnNamesOrUserVariables); } if ($this->set !== null && $this->set !== []) { diff --git a/src/Statements/ReplaceStatement.php b/src/Statements/ReplaceStatement.php index d6c8cb307..a3ca0e3b3 100644 --- a/src/Statements/ReplaceStatement.php +++ b/src/Statements/ReplaceStatement.php @@ -5,6 +5,7 @@ namespace PhpMyAdmin\SqlParser\Statements; use PhpMyAdmin\SqlParser\Components\Array2d; +use PhpMyAdmin\SqlParser\Components\ArrayObj; use PhpMyAdmin\SqlParser\Components\IntoKeyword; use PhpMyAdmin\SqlParser\Components\OptionsArray; use PhpMyAdmin\SqlParser\Components\SetOperation; @@ -60,7 +61,7 @@ class ReplaceStatement extends Statement /** * Values to be replaced. * - * @var Array2d[]|null + * @var ArrayObj[]|null */ public array|null $values = null; @@ -89,7 +90,7 @@ public function build() $ret = trim($ret) . ' INTO ' . $this->into; if ($this->values !== null && $this->values !== []) { - $ret .= ' VALUES ' . Array2d::buildAll($this->values); + $ret .= ' VALUES ' . ArrayObj::buildAll($this->values); } elseif ($this->set !== null && $this->set !== []) { $ret .= ' SET ' . SetOperation::buildAll($this->set); } elseif ($this->select !== null && strlen((string) $this->select) > 0) { diff --git a/tests/Components/Array2dTest.php b/tests/Components/Array2dTest.php index d4380f260..f37241095 100644 --- a/tests/Components/Array2dTest.php +++ b/tests/Components/Array2dTest.php @@ -5,6 +5,7 @@ namespace PhpMyAdmin\SqlParser\Tests\Components; use PhpMyAdmin\SqlParser\Components\Array2d; +use PhpMyAdmin\SqlParser\Components\ArrayObj; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; @@ -28,7 +29,7 @@ public function testBuildAll(): void $arrays = Array2d::parse(new Parser(), $this->getTokensList('(1, 2), (3, 4), (5, 6)')); $this->assertEquals( '(1, 2), (3, 4), (5, 6)', - Array2d::buildAll($arrays) + ArrayObj::buildAll($arrays) ); }