Skip to content

Commit da08ab2

Browse files
Merge pull request #482 from kamil-tekiela/Drop-$options
Drop $options param from Component::build
2 parents 875ce2b + 1ae45d6 commit da08ab2

27 files changed

+50
-78
lines changed

src/Component.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
3232
*
3333
* In other words, this function represents the inverse function of {@see Component::parse()}.
3434
*
35-
* @param mixed $component the component to be built
36-
* @param array<string, mixed> $options parameters for building
35+
* @param mixed $component the component to be built
3736
*/
38-
public static function build($component, array $options = []): string;
37+
public static function build($component): string;
3938
}

src/Components/AlterOperation.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
520520
}
521521

522522
/**
523-
* @param AlterOperation $component the component to be built
524-
* @param array<string, mixed> $options parameters for building
523+
* @param AlterOperation $component the component to be built
525524
*/
526-
public static function build($component, array $options = []): string
525+
public static function build($component): string
527526
{
528527
// Specific case of RENAME COLUMN that insert the field between 2 options.
529528
$afterFieldsOptions = new OptionsArray();

src/Components/Array2d.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
112112
}
113113

114114
/**
115-
* @param ArrayObj[] $component the component to be built
116-
* @param array<string, mixed> $options parameters for building
115+
* @param ArrayObj[] $component the component to be built
117116
*/
118-
public static function build($component, array $options = []): string
117+
public static function build($component): string
119118
{
120119
return ArrayObj::build($component);
121120
}

src/Components/ArrayObj.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
159159
}
160160

161161
/**
162-
* @param ArrayObj|ArrayObj[] $component the component to be built
163-
* @param array<string, mixed> $options parameters for building
162+
* @param ArrayObj|ArrayObj[] $component the component to be built
164163
*/
165-
public static function build($component, array $options = []): string
164+
public static function build($component): string
166165
{
167166
if (is_array($component)) {
168167
return implode(', ', $component);

src/Components/CaseExpression.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
253253
}
254254

255255
/**
256-
* @param CaseExpression $component the component to be built
257-
* @param array<string, mixed> $options parameters for building
256+
* @param CaseExpression $component the component to be built
258257
*/
259-
public static function build($component, array $options = []): string
258+
public static function build($component): string
260259
{
261260
$ret = 'CASE ';
262261
if (isset($component->value)) {

src/Components/Condition.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
221221
}
222222

223223
/**
224-
* @param Condition[] $component the component to be built
225-
* @param array<string, mixed> $options parameters for building
224+
* @param Condition[] $component the component to be built
226225
*/
227-
public static function build($component, array $options = []): string
226+
public static function build($component): string
228227
{
229228
if (is_array($component)) {
230229
return implode(' ', $component);

src/Components/CreateDefinition.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
319319

320320
/**
321321
* @param CreateDefinition|CreateDefinition[] $component the component to be built
322-
* @param array<string, mixed> $options parameters for building
323322
*/
324-
public static function build($component, array $options = []): string
323+
public static function build($component): string
325324
{
326325
if (is_array($component)) {
327326
return "(\n " . implode(",\n ", $component) . "\n)";
@@ -338,10 +337,8 @@ public static function build($component, array $options = []): string
338337
}
339338

340339
if (! empty($component->type)) {
341-
$tmp .= DataType::build(
342-
$component->type,
343-
['lowercase' => true]
344-
) . ' ';
340+
$component->type->lowercase = true;
341+
$tmp .= DataType::build($component->type) . ' ';
345342
}
346343

347344
if (! empty($component->key)) {

src/Components/DataType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ final class DataType implements Component
7272
*/
7373
public $options;
7474

75+
public bool $lowercase = false;
76+
7577
/**
7678
* @param string $name the name of this data type
7779
* @param int[]|string[] $parameters the parameters (size or possible values)
@@ -153,13 +155,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
153155
}
154156

155157
/**
156-
* @param DataType $component the component to be built
157-
* @param array<string, mixed> $options parameters for building
158+
* @param DataType $component the component to be built
158159
*/
159-
public static function build($component, array $options = []): string
160+
public static function build($component): string
160161
{
161-
$name = empty($options['lowercase']) ?
162-
$component->name : strtolower($component->name);
162+
$name = $component->lowercase ? strtolower($component->name) : $component->name;
163163

164164
$parameters = '';
165165
if ($component->parameters !== []) {

src/Components/Expression.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
448448

449449
/**
450450
* @param Expression|Expression[] $component the component to be built
451-
* @param array<string, mixed> $options parameters for building
452451
*/
453-
public static function build($component, array $options = []): string
452+
public static function build($component): string
454453
{
455454
if (is_array($component)) {
456455
return implode(', ', $component);

src/Components/ExpressionArray.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
117117
}
118118

119119
/**
120-
* @param Expression[] $component the component to be built
121-
* @param array<string, mixed> $options parameters for building
120+
* @param Expression[] $component the component to be built
122121
*/
123-
public static function build($component, array $options = []): string
122+
public static function build($component): string
124123
{
125124
$ret = [];
126125
foreach ($component as $frag) {

0 commit comments

Comments
 (0)