From 7b253b3dfd454940fa9b48eec76aca38b3203dc2 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sun, 11 Jun 2023 00:34:29 +0100 Subject: [PATCH] Split build into buildAll Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 94 ++++------------------- psalm-baseline.xml | 92 +++++----------------- src/Components/AlterOperation.php | 12 +-- src/Components/Array2d.php | 13 +++- src/Components/ArrayObj.php | 15 ++-- src/Components/CaseExpression.php | 2 +- src/Components/Condition.php | 15 ++-- src/Components/CreateDefinition.php | 15 ++-- src/Components/Expression.php | 15 ++-- src/Components/ExpressionArray.php | 12 ++- src/Components/GroupKeyword.php | 15 ++-- src/Components/IndexHint.php | 17 ++-- src/Components/IntoKeyword.php | 2 +- src/Components/JoinKeyword.php | 14 +++- src/Components/LockExpression.php | 15 ++-- src/Components/OrderKeyword.php | 15 ++-- src/Components/ParameterDefinition.php | 15 ++-- src/Components/PartitionDefinition.php | 17 ++-- src/Components/RenameOperation.php | 13 ++-- src/Components/SetOperation.php | 15 ++-- src/Components/UnionKeyword.php | 10 ++- src/Components/WithKeyword.php | 2 +- src/Statement.php | 7 +- src/Statements/CreateStatement.php | 6 +- src/Statements/DeleteStatement.php | 12 +-- src/Statements/InsertStatement.php | 6 +- src/Statements/LoadStatement.php | 4 +- src/Statements/LockStatement.php | 2 +- src/Statements/RenameStatement.php | 2 +- src/Statements/ReplaceStatement.php | 4 +- src/Statements/SetStatement.php | 2 +- tests/Builder/CreateStatementTest.php | 12 ++- tests/Components/Array2dTest.php | 4 +- tests/Components/CreateDefinitionTest.php | 4 + tests/Components/ExpressionTest.php | 4 +- tests/Components/GroupKeywordTest.php | 7 +- tests/Components/JoinKeywordTest.php | 4 +- tests/Components/LockExpressionTest.php | 4 +- tests/Components/OrderKeywordTest.php | 4 +- tests/Components/RenameOperationTest.php | 4 +- 40 files changed, 251 insertions(+), 276 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 90f728970..591e52f3b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5,11 +5,6 @@ parameters: count: 3 path: src/Components/AlterOperation.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition, array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj given\\.$#" - count: 1 - path: src/Components/AlterOperation.php - - message: "#^Parameter \\#1 \\$key of function array_key_exists expects int\\|string, float\\|int\\|string given\\.$#" count: 2 @@ -20,6 +15,11 @@ parameters: count: 1 path: src/Components/AlterOperation.php + - + message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\:\\:\\$partitions \\(array\\\\|null\\) does not accept array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#" + count: 1 + path: src/Components/AlterOperation.php + - message: "#^array\\\\|string does not accept PhpMyAdmin\\\\SqlParser\\\\Token\\.$#" count: 3 @@ -35,11 +35,6 @@ parameters: count: 1 path: src/Components/Array2d.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\:\\:build\\(\\) expects array\\, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\) given\\.$#" - count: 1 - path: src/Components/Array2d.php - - message: "#^Cannot access an offset on array\\, mixed\\>\\|static\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\)\\.$#" count: 1 @@ -125,11 +120,6 @@ parameters: count: 1 path: src/Components/ExpressionArray.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ExpressionArray\\:\\:build\\(\\) expects array\\, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ExpressionArray\\) given\\.$#" - count: 1 - path: src/Components/ExpressionArray.php - - message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|null given\\.$#" count: 1 @@ -185,11 +175,6 @@ parameters: count: 1 path: src/Components/IntoKeyword.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\JoinKeyword\\:\\:build\\(\\) expects array\\, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\JoinKeyword\\) given\\.$#" - count: 1 - path: src/Components/JoinKeyword.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\JoinKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#" count: 2 @@ -385,11 +370,6 @@ parameters: count: 2 path: src/Components/Reference.php - - - message: "#^Call to function is_array\\(\\) with PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation will always evaluate to false\\.$#" - count: 1 - path: src/Components/RenameOperation.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$new \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#" count: 2 @@ -415,11 +395,6 @@ parameters: count: 1 path: src/Components/SetOperation.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\UnionKeyword\\:\\:build\\(\\) expects array\\\\>, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\UnionKeyword\\) given\\.$#" - count: 1 - path: src/Components/UnionKeyword.php - - message: "#^Static property PhpMyAdmin\\\\SqlParser\\\\Context\\:\\:\\$keywords \\(non\\-empty\\-array\\\\) does not accept default value of type array\\{\\}\\.$#" count: 1 @@ -500,6 +475,11 @@ parameters: count: 1 path: src/Parser.php + - + message: "#^Call to an undefined static method PhpMyAdmin\\\\SqlParser\\\\Component\\:\\:buildAll\\(\\)\\.$#" + count: 1 + path: src/Statement.php + - message: "#^Offset 'class' does not exist on array\\{class\\?\\: class\\-string\\, field\\?\\: non\\-empty\\-string, options\\?\\: array\\\\}\\.$#" count: 1 @@ -516,7 +496,7 @@ parameters: path: src/Statements/AlterStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null given\\.$#" count: 1 path: src/Statements/AlterStatement.php @@ -556,7 +536,7 @@ parameters: path: src/Statements/CreateStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null given\\.$#" count: 10 path: src/Statements/CreateStatement.php @@ -566,7 +546,7 @@ parameters: path: src/Statements/CreateStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition, array\\\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:buildAll\\(\\) expects array\\, array\\\\|null given\\.$#" count: 1 path: src/Statements/CreateStatement.php @@ -601,7 +581,7 @@ parameters: path: src/Statements/DeleteStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ExpressionArray\\:\\:build\\(\\) expects array\\, array\\ given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\ExpressionArray\\:\\:buildAll\\(\\) expects array\\, array\\ given\\.$#" count: 1 path: src/Statements/DeleteStatement.php @@ -691,12 +671,12 @@ parameters: path: src/Statements/PurgeStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation, array\\\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:buildAll\\(\\) expects array\\, array\\\\|null given\\.$#" count: 1 path: src/Statements/RenameStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\:\\:build\\(\\) expects array\\, array\\ given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Array2d\\:\\:buildAll\\(\\) expects array\\, array\\ given\\.$#" count: 1 path: src/Statements/ReplaceStatement.php @@ -711,7 +691,7 @@ parameters: path: src/Statements/SetStatement.php - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\SetOperation\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\SetOperation, array\\\\|null given\\.$#" + message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\SetOperation\\:\\:buildAll\\(\\) expects array\\, array\\\\|null given\\.$#" count: 1 path: src/Statements/SetStatement.php @@ -920,46 +900,11 @@ parameters: count: 4 path: tests/Builder/CreateStatementTest.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\CreateDefinition\\:\\:build\\(\\) expects array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\CreateDefinition, array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null given\\.$#" - count: 2 - path: tests/Builder/CreateStatementTest.php - - - - 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 - - message: "#^Cannot access offset 0 on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#" count: 1 path: tests/Components/ArrayObjTest.php - - - message: "#^Cannot access offset 0 on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\.$#" - count: 1 - path: tests/Components/CreateDefinitionTest.php - - - - message: "#^Cannot access offset 1 on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\.$#" - count: 1 - path: tests/Components/CreateDefinitionTest.php - - - - message: "#^Cannot access offset 2 on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\.$#" - count: 2 - path: tests/Components/CreateDefinitionTest.php - - - - message: "#^Cannot access offset 5 on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\.$#" - count: 1 - path: tests/Components/CreateDefinitionTest.php - - - - message: "#^Cannot access offset 6 on array\\\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\.$#" - count: 1 - path: tests/Components/CreateDefinitionTest.php - - message: "#^Cannot access property \\$name on PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\|null\\.$#" count: 1 @@ -1005,11 +950,6 @@ parameters: count: 2 path: tests/Components/PartitionDefinitionTest.php - - - message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation, array\\ given\\.$#" - count: 1 - path: tests/Components/RenameOperationTest.php - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 2 and PhpMyAdmin\\\\SqlParser\\\\TokensList will always evaluate to false\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 34fd1648c..28aad033e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,9 +1,6 @@ - - partitions]]> - 1, @@ -53,11 +50,15 @@ $options + + PartitionDefinition::class] + )]]> + - - $this - $ret @@ -206,9 +207,6 @@ - - $this - $ret @@ -262,6 +260,9 @@ indexOrKey]]> type]]> + + buildAll + @@ -291,9 +292,6 @@ - - $this - keyword]]]> keyword]]]> @@ -541,12 +539,6 @@ - - is_array($component) - - - $component - $component @@ -583,12 +575,12 @@ - - $this - $component + + buildAll + @@ -900,6 +892,9 @@ bool + + $field)]]> + $index @@ -1098,9 +1093,9 @@ - + renames]]> - + @@ -1482,14 +1477,6 @@ - - fields]]> - fields]]> - - - parameters]]> - parameters]]> - __toString __toString @@ -1506,52 +1493,14 @@ - - statements[0]->fields[0]]]> - statements[0]->fields[1]]]> - statements[0]->fields[2]]]> - statements[1]->fields[2]]]> - statements[1]->fields[5]]]> - statements[1]->fields[6]]]> - - - statements[0]->fields[0]]]> - statements[0]->fields[1]]]> - statements[0]->fields[2]]]> - statements[1]->fields[2]]]> - statements[1]->fields[5]]]> - statements[1]->fields[6]]]> - - - statements[0]->fields[0]]]> - statements[0]->fields[1]]]> - statements[0]->fields[2]]]> - statements[1]->fields[2]]]> - statements[1]->fields[5]]]> - statements[1]->fields[6]]]> - type->name]]> key->name]]> key->type]]> - statements[0]->fields]]> - statements[0]->fields]]> - statements[0]->fields]]> - statements[1]->fields]]> - statements[1]->fields]]> - statements[1]->fields]]> has - - statements[0]->fields]]> - statements[0]->fields]]> - statements[0]->fields]]> - statements[1]->fields]]> - statements[1]->fields]]> - statements[1]->fields]]> - @@ -1590,11 +1539,6 @@ expr->expr]]> - - - $component - - has diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index 8bcc0405c..569704960 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -267,7 +267,7 @@ final class AlterOperation implements Component /** * The partitions. * - * @var Component[]|ArrayObj|null + * @var PartitionDefinition[]|null */ public $partitions; @@ -279,10 +279,10 @@ final class AlterOperation implements Component public $unknown = []; /** - * @param OptionsArray $options options of alter operation - * @param Expression|string|null $field altered field - * @param Component[]|ArrayObj|null $partitions partitions definition found in the operation - * @param Token[] $unknown unparsed tokens found at the end of operation + * @param OptionsArray $options options of alter operation + * @param Expression|string|null $field altered field + * @param PartitionDefinition[]|null $partitions partitions definition found in the operation + * @param Token[] $unknown unparsed tokens found at the end of operation */ public function __construct( $options = null, @@ -548,7 +548,7 @@ public static function build($component): string $ret .= $afterFieldsOptions . TokensList::build($component->unknown); if (isset($component->partitions)) { - $ret .= PartitionDefinition::build($component->partitions); + $ret .= PartitionDefinition::buildAll($component->partitions); } return trim($ret); diff --git a/src/Components/Array2d.php b/src/Components/Array2d.php index 4a833d0ee..82c4b7e55 100644 --- a/src/Components/Array2d.php +++ b/src/Components/Array2d.php @@ -9,6 +9,7 @@ use PhpMyAdmin\SqlParser\Token; use PhpMyAdmin\SqlParser\TokensList; use PhpMyAdmin\SqlParser\Translator; +use RuntimeException; use function count; use function sprintf; @@ -112,11 +113,19 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param ArrayObj[] $component the component to be built + * @param Array2d $component */ public static function build($component): string { - return ArrayObj::build($component); + 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 diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php index fa3488695..679a60055 100644 --- a/src/Components/ArrayObj.php +++ b/src/Components/ArrayObj.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; use function strlen; use function trim; @@ -159,14 +158,10 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param ArrayObj|ArrayObj[] $component the component to be built + * @param ArrayObj $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - if ($component->raw !== []) { return '(' . implode(', ', $component->raw) . ')'; } @@ -174,6 +169,14 @@ public static function build($component): string return '(' . implode(', ', $component->values) . ')'; } + /** + * @param ArrayObj[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/CaseExpression.php b/src/Components/CaseExpression.php index 68337801d..0ff0ab0a4 100644 --- a/src/Components/CaseExpression.php +++ b/src/Components/CaseExpression.php @@ -272,7 +272,7 @@ public static function build($component): string $valuesCount = count($component->conditions); $resultsCount = count($component->results); for ($i = 0; $i < $valuesCount && $i < $resultsCount; ++$i) { - $ret .= 'WHEN ' . Condition::build($component->conditions[$i]) . ' '; + $ret .= 'WHEN ' . Condition::buildAll($component->conditions[$i]) . ' '; $ret .= 'THEN ' . $component->results[$i] . ' '; } } diff --git a/src/Components/Condition.php b/src/Components/Condition.php index 462c6d70f..1f5442d65 100644 --- a/src/Components/Condition.php +++ b/src/Components/Condition.php @@ -11,7 +11,6 @@ use function implode; use function in_array; -use function is_array; use function trim; /** @@ -221,17 +220,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param Condition[]|Condition $component the component to be built + * @param Condition $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(' ', $component); - } - return $component->expr; } + /** + * @param Condition[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(' ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php index adb634844..a263abb6c 100644 --- a/src/Components/CreateDefinition.php +++ b/src/Components/CreateDefinition.php @@ -11,7 +11,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; use function trim; /** @@ -318,14 +317,10 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param CreateDefinition|CreateDefinition[] $component the component to be built + * @param CreateDefinition $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return "(\n " . implode(",\n ", $component) . "\n)"; - } - $tmp = ''; if ($component->isConstraint) { @@ -354,6 +349,14 @@ public static function build($component): string return trim($tmp); } + /** + * @param CreateDefinition[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return "(\n " . implode(",\n ", $component) . "\n)"; + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/Expression.php b/src/Components/Expression.php index efd1eba43..51485639e 100644 --- a/src/Components/Expression.php +++ b/src/Components/Expression.php @@ -12,7 +12,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; use function rtrim; use function strlen; use function trim; @@ -446,14 +445,10 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param Expression|Expression[] $component the component to be built + * @param Expression $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - if ($component->expr !== '' && $component->expr !== null) { $ret = $component->expr; } else { @@ -480,6 +475,14 @@ public static function build($component): string return $ret; } + /** + * @param Expression[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/ExpressionArray.php b/src/Components/ExpressionArray.php index 43c91a27e..2236c77b5 100644 --- a/src/Components/ExpressionArray.php +++ b/src/Components/ExpressionArray.php @@ -9,6 +9,8 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Token; use PhpMyAdmin\SqlParser\TokensList; +use PhpMyAdmin\SqlParser\Translator; +use RuntimeException; use function count; use function implode; @@ -117,9 +119,17 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param Expression[] $component the component to be built + * @param ExpressionArray $component */ public static function build($component): string + { + throw new RuntimeException(Translator::gettext('Not implemented yet.')); + } + + /** + * @param Expression[] $component the component to be built + */ + public static function buildAll(array $component): string { $ret = []; foreach ($component as $frag) { diff --git a/src/Components/GroupKeyword.php b/src/Components/GroupKeyword.php index 357cdf557..8c0c2420b 100644 --- a/src/Components/GroupKeyword.php +++ b/src/Components/GroupKeyword.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; use function trim; /** @@ -112,17 +111,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param GroupKeyword|GroupKeyword[] $component the component to be built + * @param GroupKeyword $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - return trim((string) $component->expr); } + /** + * @param GroupKeyword[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/IndexHint.php b/src/Components/IndexHint.php index ce4ce41db..5245d4ca0 100644 --- a/src/Components/IndexHint.php +++ b/src/Components/IndexHint.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; /** * Parses an Index hint. @@ -178,20 +177,24 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param IndexHint|IndexHint[] $component the component to be built + * @param IndexHint $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(' ', $component); - } - $ret = $component->type . ' ' . $component->indexOrKey . ' '; if ($component->for !== null) { $ret .= 'FOR ' . $component->for . ' '; } - return $ret . ExpressionArray::build($component->indexes); + return $ret . ExpressionArray::buildAll($component->indexes); + } + + /** + * @param IndexHint[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(' ', $component); } public function __toString(): string diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php index c499fb8cf..becd48cfc 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::build($component->values); + return ExpressionArray::buildAll($component->values); } $ret = 'OUTFILE "' . $component->dest . '"'; diff --git a/src/Components/JoinKeyword.php b/src/Components/JoinKeyword.php index 146284c37..1cdc75d7e 100644 --- a/src/Components/JoinKeyword.php +++ b/src/Components/JoinKeyword.php @@ -8,6 +8,8 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Token; use PhpMyAdmin\SqlParser\TokensList; +use PhpMyAdmin\SqlParser\Translator; +use RuntimeException; use function array_search; use function implode; @@ -198,15 +200,23 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param JoinKeyword[] $component the component to be built + * @param JoinKeyword $component */ public static function build($component): string + { + throw new RuntimeException(Translator::gettext('Not implemented yet.')); + } + + /** + * @param JoinKeyword[] $component the component to be built + */ + public static function buildAll(array $component): string { $ret = []; foreach ($component as $c) { $ret[] = array_search($c->type, static::$joins) . ' ' . $c->expr . (! empty($c->on) - ? ' ON ' . Condition::build($c->on) : '') + ? ' ON ' . Condition::buildAll($c->on) : '') . (! empty($c->using) ? ' USING ' . ArrayObj::build($c->using) : ''); } diff --git a/src/Components/LockExpression.php b/src/Components/LockExpression.php index 7e9dd1148..af54d4b17 100644 --- a/src/Components/LockExpression.php +++ b/src/Components/LockExpression.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; /** * Parses a reference to a LOCK expression. @@ -95,17 +94,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param LockExpression|LockExpression[] $component the component to be built + * @param LockExpression $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - return $component->table . ' ' . $component->type; } + /** + * @param LockExpression[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + /** * @return string */ diff --git a/src/Components/OrderKeyword.php b/src/Components/OrderKeyword.php index ebbab39ff..46328acba 100644 --- a/src/Components/OrderKeyword.php +++ b/src/Components/OrderKeyword.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; /** * `ORDER BY` keyword parser. @@ -117,17 +116,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param OrderKeyword|OrderKeyword[] $component the component to be built + * @param OrderKeyword $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - return $component->expr . ' ' . $component->type; } + /** + * @param OrderKeyword[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/ParameterDefinition.php b/src/Components/ParameterDefinition.php index 495d10822..87e00404a 100644 --- a/src/Components/ParameterDefinition.php +++ b/src/Components/ParameterDefinition.php @@ -11,7 +11,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; use function trim; /** @@ -141,14 +140,10 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param ParameterDefinition[]|ParameterDefinition $component the component to be built + * @param ParameterDefinition $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return '(' . implode(', ', $component) . ')'; - } - $tmp = ''; if (! empty($component->inOut)) { $tmp .= $component->inOut . ' '; @@ -159,6 +154,14 @@ public static function build($component): string ); } + /** + * @param ParameterDefinition[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return '(' . implode(', ', $component) . ')'; + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/PartitionDefinition.php b/src/Components/PartitionDefinition.php index a0d2034da..8f312765c 100644 --- a/src/Components/PartitionDefinition.php +++ b/src/Components/PartitionDefinition.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; use function trim; /** @@ -224,19 +223,15 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param PartitionDefinition|PartitionDefinition[] $component the component to be built + * @param PartitionDefinition $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return "(\n" . implode(",\n", $component) . "\n)"; - } - if ($component->isSubpartition) { return trim('SUBPARTITION ' . $component->name . ' ' . $component->options); } - $subpartitions = empty($component->subpartitions) ? '' : ' ' . self::build($component->subpartitions); + $subpartitions = empty($component->subpartitions) ? '' : ' ' . self::buildAll($component->subpartitions); return trim( 'PARTITION ' . $component->name @@ -246,6 +241,14 @@ public static function build($component): string ); } + /** + * @param PartitionDefinition[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return "(\n" . implode(",\n", $component) . "\n)"; + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/RenameOperation.php b/src/Components/RenameOperation.php index 599dd3248..16b70f502 100644 --- a/src/Components/RenameOperation.php +++ b/src/Components/RenameOperation.php @@ -10,7 +10,6 @@ use PhpMyAdmin\SqlParser\TokensList; use function implode; -use function is_array; /** * `RENAME TABLE` keyword parser. @@ -153,13 +152,17 @@ public static function parse(Parser $parser, TokensList $list, array $options = */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - return $component->old . ' TO ' . $component->new; } + /** + * @param RenameOperation[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/SetOperation.php b/src/Components/SetOperation.php index 47396fc7a..65e552f99 100644 --- a/src/Components/SetOperation.php +++ b/src/Components/SetOperation.php @@ -11,7 +11,6 @@ use function implode; use function in_array; -use function is_array; use function trim; /** @@ -141,17 +140,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param SetOperation|SetOperation[] $component the component to be built + * @param SetOperation $component the component to be built */ public static function build($component): string { - if (is_array($component)) { - return implode(', ', $component); - } - return $component->column . ' = ' . $component->value; } + /** + * @param SetOperation[] $component the component to be built + */ + public static function buildAll(array $component): string + { + return implode(', ', $component); + } + public function __toString(): string { return static::build($this); diff --git a/src/Components/UnionKeyword.php b/src/Components/UnionKeyword.php index be317e26a..c13f7852e 100644 --- a/src/Components/UnionKeyword.php +++ b/src/Components/UnionKeyword.php @@ -34,9 +34,17 @@ public static function parse(Parser $parser, TokensList $list, array $options = } /** - * @param array $component the component to be built + * @param UnionKeyword $component */ public static function build($component): string + { + throw new RuntimeException(Translator::gettext('Not implemented yet.')); + } + + /** + * @param UnionKeyword[][] $component the component to be built + */ + public static function buildAll(array $component): string { $tmp = []; foreach ($component as $componentPart) { diff --git a/src/Components/WithKeyword.php b/src/Components/WithKeyword.php index 4b92d53e2..ca644a122 100644 --- a/src/Components/WithKeyword.php +++ b/src/Components/WithKeyword.php @@ -57,7 +57,7 @@ public static function build($component): string $str = $component->name; if ($component->columns) { - $str .= ArrayObj::build($component->columns); + $str .= ArrayObj::buildAll($component->columns); } $str .= ' AS ('; diff --git a/src/Statement.php b/src/Statement.php index b53a31c40..4d40db6f1 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -10,6 +10,7 @@ use function array_flip; use function array_keys; use function in_array; +use function is_array; use function stripos; use function trim; @@ -197,7 +198,11 @@ public function build() continue; } - $query = trim($query) . ' ' . $class::build($this->$field); + if (is_array($this->$field)) { + $query = trim($query) . ' ' . $class::buildAll($this->$field); + } else { + $query = trim($query) . ' ' . $class::build($this->$field); + } } return $query; diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index b9d4b5a63..c43b48d13 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -411,7 +411,7 @@ public function build(): string $fields = ''; if (! empty($this->fields)) { if (is_array($this->fields)) { - $fields = CreateDefinition::build($this->fields) . ' '; + $fields = CreateDefinition::buildAll($this->fields) . ' '; } elseif ($this->fields instanceof ArrayObj) { $fields = ArrayObj::build($this->fields); } @@ -465,7 +465,7 @@ public function build(): string } if (! empty($this->partitions)) { - $partition .= "\n" . PartitionDefinition::build($this->partitions); + $partition .= "\n" . PartitionDefinition::buildAll($this->partitions); } return 'CREATE ' @@ -510,7 +510,7 @@ public function build(): string return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' - . ParameterDefinition::build($this->parameters) . ' ' + . ParameterDefinition::buildAll($this->parameters) . ' ' . $tmp . ' ' . OptionsArray::build($this->entityOptions) . ' ' . TokensList::build($this->body); } diff --git a/src/Statements/DeleteStatement.php b/src/Statements/DeleteStatement.php index 06312cdee..652524e07 100644 --- a/src/Statements/DeleteStatement.php +++ b/src/Statements/DeleteStatement.php @@ -165,27 +165,27 @@ public function build() $ret = 'DELETE ' . OptionsArray::build($this->options); if ($this->columns !== null && $this->columns !== []) { - $ret .= ' ' . ExpressionArray::build($this->columns); + $ret .= ' ' . ExpressionArray::buildAll($this->columns); } if ($this->from !== null && $this->from !== []) { - $ret .= ' FROM ' . ExpressionArray::build($this->from); + $ret .= ' FROM ' . ExpressionArray::buildAll($this->from); } if ($this->join !== null && $this->join !== []) { - $ret .= ' ' . JoinKeyword::build($this->join); + $ret .= ' ' . JoinKeyword::buildAll($this->join); } if ($this->using !== null && $this->using !== []) { - $ret .= ' USING ' . ExpressionArray::build($this->using); + $ret .= ' USING ' . ExpressionArray::buildAll($this->using); } if ($this->where !== null && $this->where !== []) { - $ret .= ' WHERE ' . Condition::build($this->where); + $ret .= ' WHERE ' . Condition::buildAll($this->where); } if ($this->order !== null && $this->order !== []) { - $ret .= ' ORDER BY ' . ExpressionArray::build($this->order); + $ret .= ' ORDER BY ' . ExpressionArray::buildAll($this->order); } if ($this->limit !== null && strlen((string) $this->limit) > 0) { diff --git a/src/Statements/InsertStatement.php b/src/Statements/InsertStatement.php index 29b5b598b..87b667208 100644 --- a/src/Statements/InsertStatement.php +++ b/src/Statements/InsertStatement.php @@ -120,15 +120,15 @@ public function build() $ret = trim($ret) . ' INTO ' . $this->into; if ($this->values !== null && $this->values !== []) { - $ret .= ' VALUES ' . Array2d::build($this->values); + $ret .= ' VALUES ' . ArrayObj::buildAll($this->values); } elseif ($this->set !== null && $this->set !== []) { - $ret .= ' SET ' . SetOperation::build($this->set); + $ret .= ' SET ' . SetOperation::buildAll($this->set); } elseif ($this->select !== null && strlen((string) $this->select) > 0) { $ret .= ' ' . $this->select->build(); } if ($this->onDuplicateSet !== null && $this->onDuplicateSet !== []) { - $ret .= ' ON DUPLICATE KEY UPDATE ' . SetOperation::build($this->onDuplicateSet); + $ret .= ' ON DUPLICATE KEY UPDATE ' . SetOperation::buildAll($this->onDuplicateSet); } return $ret; diff --git a/src/Statements/LoadStatement.php b/src/Statements/LoadStatement.php index e22915a97..99b6063dd 100644 --- a/src/Statements/LoadStatement.php +++ b/src/Statements/LoadStatement.php @@ -214,11 +214,11 @@ public function build() } if ($this->columnNamesOrUserVariables !== null && $this->columnNamesOrUserVariables !== []) { - $ret .= ' ' . ExpressionArray::build($this->columnNamesOrUserVariables); + $ret .= ' ' . ExpressionArray::buildAll($this->columnNamesOrUserVariables); } if ($this->set !== null && $this->set !== []) { - $ret .= ' SET ' . SetOperation::build($this->set); + $ret .= ' SET ' . SetOperation::buildAll($this->set); } return $ret; diff --git a/src/Statements/LockStatement.php b/src/Statements/LockStatement.php index 3fba01f56..1b4743d9c 100644 --- a/src/Statements/LockStatement.php +++ b/src/Statements/LockStatement.php @@ -123,6 +123,6 @@ public function parse(Parser $parser, TokensList $list): void public function build(): string { return trim(($this->isLock ? 'LOCK' : 'UNLOCK') - . ' TABLES ' . LockExpression::build($this->locked)); + . ' TABLES ' . LockExpression::buildAll($this->locked)); } } diff --git a/src/Statements/RenameStatement.php b/src/Statements/RenameStatement.php index eccde7b32..794b6c161 100644 --- a/src/Statements/RenameStatement.php +++ b/src/Statements/RenameStatement.php @@ -46,6 +46,6 @@ public function before(Parser $parser, TokensList $list, Token $token): void public function build(): string { - return 'RENAME TABLE ' . RenameOperation::build($this->renames); + return 'RENAME TABLE ' . RenameOperation::buildAll($this->renames); } } diff --git a/src/Statements/ReplaceStatement.php b/src/Statements/ReplaceStatement.php index ca3917216..d6c8cb307 100644 --- a/src/Statements/ReplaceStatement.php +++ b/src/Statements/ReplaceStatement.php @@ -89,9 +89,9 @@ public function build() $ret = trim($ret) . ' INTO ' . $this->into; if ($this->values !== null && $this->values !== []) { - $ret .= ' VALUES ' . Array2d::build($this->values); + $ret .= ' VALUES ' . Array2d::buildAll($this->values); } elseif ($this->set !== null && $this->set !== []) { - $ret .= ' SET ' . SetOperation::build($this->set); + $ret .= ' SET ' . SetOperation::buildAll($this->set); } elseif ($this->select !== null && strlen((string) $this->select) > 0) { $ret .= ' ' . $this->select->build(); } diff --git a/src/Statements/SetStatement.php b/src/Statements/SetStatement.php index 965dd6574..cae25e76b 100644 --- a/src/Statements/SetStatement.php +++ b/src/Statements/SetStatement.php @@ -105,7 +105,7 @@ class SetStatement extends Statement public function build(): string { $ret = 'SET ' . OptionsArray::build($this->options) - . ' ' . SetOperation::build($this->set) + . ' ' . SetOperation::buildAll($this->set) . ' ' . OptionsArray::build($this->endOptions); return trim($ret); diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 95f24d751..12b3e6e38 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -512,9 +512,10 @@ public function testBuilderCreateProcedure(): void $stmt->name->__toString() ); + $this->assertNotNull($stmt->parameters); $this->assertSame( '(IN `_var` INT)', - ParameterDefinition::build($stmt->parameters) + ParameterDefinition::buildAll($stmt->parameters) ); $this->assertSame( @@ -614,9 +615,10 @@ public function testBuilderCreateFunction(): void $stmt->name->__toString() ); + $this->assertNotNull($stmt->parameters); $this->assertSame( '(`p_inventory_id` INT)', - ParameterDefinition::build($stmt->parameters) + ParameterDefinition::buildAll($stmt->parameters) ); $this->assertSame( @@ -736,9 +738,10 @@ public function testBuildCreateTableSortedIndex(): void ) SQL; + $this->assertIsArray($stmt->fields); $this->assertEquals( $tableBody, - CreateDefinition::build($stmt->fields) + CreateDefinition::buildAll($stmt->fields) ); $this->assertEquals( @@ -835,9 +838,10 @@ public function testBuildCreateTableComplexIndexes(): void SQL; // phpcs:enable + $this->assertIsArray($stmt->fields); $this->assertEquals( $tableBody, - CreateDefinition::build($stmt->fields) + CreateDefinition::buildAll($stmt->fields) ); $this->assertEquals( diff --git a/tests/Components/Array2dTest.php b/tests/Components/Array2dTest.php index 3b284eba1..d4380f260 100644 --- a/tests/Components/Array2dTest.php +++ b/tests/Components/Array2dTest.php @@ -23,12 +23,12 @@ public function testParse(): void ); } - public function testBuild(): void + 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::build($arrays) + Array2d::buildAll($arrays) ); } diff --git a/tests/Components/CreateDefinitionTest.php b/tests/Components/CreateDefinitionTest.php index 3f28f4ba7..0425826bb 100644 --- a/tests/Components/CreateDefinitionTest.php +++ b/tests/Components/CreateDefinitionTest.php @@ -75,6 +75,7 @@ public function testBuild(): void ') ENGINE=InnoDB"' ); $this->assertInstanceOf(CreateStatement::class, $parser->statements[0]); + $this->assertIsArray($parser->statements[0]->fields); $this->assertEquals( 'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) ' . 'REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE', @@ -94,6 +95,7 @@ public function testBuild2(): void ') ENGINE=InnoDB"' ); $this->assertInstanceOf(CreateStatement::class, $parser->statements[0]); + $this->assertIsArray($parser->statements[0]->fields); $this->assertEquals( 'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) ' . 'REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE', @@ -120,6 +122,7 @@ public function testBuild3(): void . 'ALTER TABLE `searches` ADD `admins_only` BOOLEAN NOT NULL DEFAULT FALSE AFTER `show_separators`;' ); $this->assertInstanceOf(CreateStatement::class, $parser->statements[1]); + $this->assertIsArray($parser->statements[1]->fields); $this->assertEquals( '`public_name` varchar(120) COLLATE utf8_unicode_ci NOT NULL', CreateDefinition::build($parser->statements[1]->fields[2]) @@ -146,6 +149,7 @@ public function testBuildWithInvisibleKeyword(): void ') ENGINE=InnoDB"' ); $this->assertInstanceOf(CreateStatement::class, $parser->statements[0]); + $this->assertIsArray($parser->statements[0]->fields); $this->assertEquals( '`customer_id` smallint(5) UNSIGNED NOT NULL INVISIBLE', CreateDefinition::build($parser->statements[0]->fields[0]) diff --git a/tests/Components/ExpressionTest.php b/tests/Components/ExpressionTest.php index 73dfe7cd2..f4936b4ba 100644 --- a/tests/Components/ExpressionTest.php +++ b/tests/Components/ExpressionTest.php @@ -81,14 +81,14 @@ public static function parseErrProvider(): array ]; } - public function testBuild(): void + public function testBuildAll(): void { $component = [ new Expression('1 + 2', 'three'), new Expression('1 + 3', 'four'), ]; $this->assertEquals( - Expression::build($component), + Expression::buildAll($component), '1 + 2 AS `three`, 1 + 3 AS `four`' ); } diff --git a/tests/Components/GroupKeywordTest.php b/tests/Components/GroupKeywordTest.php index 4ddba7789..0ec151795 100644 --- a/tests/Components/GroupKeywordTest.php +++ b/tests/Components/GroupKeywordTest.php @@ -10,6 +10,7 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use function array_map; +use function is_array; class GroupKeywordTest extends TestCase { @@ -58,7 +59,11 @@ public static function provideExpressions(): Generator */ public function testBuild($component, string $expected): void { - $this->assertSame($expected, GroupKeyword::build($component)); + if (is_array($component)) { + $this->assertSame($expected, GroupKeyword::buildAll($component)); + } else { + $this->assertSame($expected, GroupKeyword::build($component)); + } } private static function makeComponentFrom(string $string): GroupKeyword diff --git a/tests/Components/JoinKeywordTest.php b/tests/Components/JoinKeywordTest.php index a99b09331..dbb43f7f0 100644 --- a/tests/Components/JoinKeywordTest.php +++ b/tests/Components/JoinKeywordTest.php @@ -28,7 +28,7 @@ public function testParseIncompleteUsing(): void $this->assertEquals(['id'], $component[0]->using->values); } - public function testBuild(): void + public function testBuildAll(): void { $component = JoinKeyword::parse( new Parser(), @@ -40,7 +40,7 @@ public function testBuild(): void $this->assertEquals( 'LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) ' . 'ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)', - JoinKeyword::build($component) + JoinKeyword::buildAll($component) ); } } diff --git a/tests/Components/LockExpressionTest.php b/tests/Components/LockExpressionTest.php index e1cb4919e..c01d95fe2 100644 --- a/tests/Components/LockExpressionTest.php +++ b/tests/Components/LockExpressionTest.php @@ -59,14 +59,14 @@ public static function parseErrProvider(): array ]; } - public function testBuild(): void + public function testBuildAll(): void { $component = [ LockExpression::parse(new Parser(), $this->getTokensList('table1 AS t1 READ LOCAL')), LockExpression::parse(new Parser(), $this->getTokensList('table2 LOW_PRIORITY WRITE')), ]; $this->assertEquals( - LockExpression::build($component), + LockExpression::buildAll($component), 'table1 AS `t1` READ LOCAL, table2 LOW_PRIORITY WRITE' ); } diff --git a/tests/Components/OrderKeywordTest.php b/tests/Components/OrderKeywordTest.php index 415d8ddbd..2a59d64e7 100644 --- a/tests/Components/OrderKeywordTest.php +++ b/tests/Components/OrderKeywordTest.php @@ -10,10 +10,10 @@ class OrderKeywordTest extends TestCase { - public function testBuild(): void + public function testBuildAll(): void { $this->assertEquals( - OrderKeyword::build( + OrderKeyword::buildAll( [ new OrderKeyword(new Expression('a'), 'ASC'), new OrderKeyword(new Expression('b'), 'DESC'), diff --git a/tests/Components/RenameOperationTest.php b/tests/Components/RenameOperationTest.php index e4d83a031..9298f35d5 100644 --- a/tests/Components/RenameOperationTest.php +++ b/tests/Components/RenameOperationTest.php @@ -10,9 +10,9 @@ class RenameOperationTest extends TestCase { - public function testBuild(): void + public function testBuildAll(): void { $component = RenameOperation::parse(new Parser(), $this->getTokensList('a TO b, c TO d')); - $this->assertEquals(RenameOperation::build($component), 'a TO b, c TO d'); + $this->assertEquals(RenameOperation::buildAll($component), 'a TO b, c TO d'); } }