Skip to content

Commit d368724

Browse files
committed
Merge remote-tracking branch 'origin/pull/138'
2 parents 6e4dc05 + 28be60a commit d368724

15 files changed

Lines changed: 108 additions & 112 deletions

.php_cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ return PhpCsFixer\Config::create()
1616
'ordered_imports' => true,
1717
'no_trailing_whitespace' => true,
1818
'no_useless_return' => true,
19+
'no_useless_else' => true,
1920
'phpdoc_order' => true,
2021
))
2122
->setFinder($finder)

src/Components/ArrayObj.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ public static function build($component, array $options = array())
182182
return implode(', ', $component);
183183
} elseif (!empty($component->raw)) {
184184
return '(' . implode(', ', $component->raw) . ')';
185-
} else {
186-
return '(' . implode(', ', $component->values) . ')';
187185
}
186+
187+
return '(' . implode(', ', $component->values) . ')';
188188
}
189189
}

src/Components/Condition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ public static function build($component, array $options = array())
220220
{
221221
if (is_array($component)) {
222222
return implode(' ', $component);
223-
} else {
224-
return $component->expr;
225223
}
224+
225+
return $component->expr;
226226
}
227227
}

src/Components/CreateDefinition.php

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
201201
'An opening bracket was expected.',
202202
$token
203203
);
204+
204205
break;
205206
}
206207
} elseif ($state === 1) {
@@ -226,11 +227,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
226227
);
227228

228229
return $ret;
229-
} else {
230-
// Non-reserved keywords are allowed without backquotes
231-
$expr->name = $token->value;
232-
$state = 2;
233230
}
231+
232+
// Non-reserved keywords are allowed without backquotes
233+
$expr->name = $token->value;
234+
$state = 2;
234235
} else {
235236
$parser->error(
236237
'A symbol name was expected!',
@@ -302,35 +303,35 @@ public static function build($component, array $options = array())
302303
{
303304
if (is_array($component)) {
304305
return "(\n " . implode(",\n ", $component) . "\n)";
305-
} else {
306-
$tmp = '';
307-
308-
if ($component->isConstraint) {
309-
$tmp .= 'CONSTRAINT ';
310-
}
306+
}
311307

312-
if ((isset($component->name)) && ($component->name !== '')) {
313-
$tmp .= Context::escape($component->name) . ' ';
314-
}
308+
$tmp = '';
315309

316-
if (!empty($component->type)) {
317-
$tmp .= DataType::build(
318-
$component->type,
319-
array('lowercase' => true)
320-
) . ' ';
321-
}
310+
if ($component->isConstraint) {
311+
$tmp .= 'CONSTRAINT ';
312+
}
322313

323-
if (!empty($component->key)) {
324-
$tmp .= $component->key . ' ';
325-
}
314+
if ((isset($component->name)) && ($component->name !== '')) {
315+
$tmp .= Context::escape($component->name) . ' ';
316+
}
326317

327-
if (!empty($component->references)) {
328-
$tmp .= 'REFERENCES ' . $component->references . ' ';
329-
}
318+
if (!empty($component->type)) {
319+
$tmp .= DataType::build(
320+
$component->type,
321+
array('lowercase' => true)
322+
) . ' ';
323+
}
330324

331-
$tmp .= $component->options;
325+
if (!empty($component->key)) {
326+
$tmp .= $component->key . ' ';
327+
}
332328

333-
return trim($tmp);
329+
if (!empty($component->references)) {
330+
$tmp .= 'REFERENCES ' . $component->references . ' ';
334331
}
332+
333+
$tmp .= $component->options;
334+
335+
return trim($tmp);
335336
}
336337
}

src/Components/Expression.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -418,28 +418,28 @@ public static function build($component, array $options = array())
418418
{
419419
if (is_array($component)) {
420420
return implode($component, ', ');
421+
}
422+
423+
if ($component->expr !== '' && !is_null($component->expr)) {
424+
$ret = $component->expr;
421425
} else {
422-
if ($component->expr !== '' && !is_null($component->expr)) {
423-
$ret = $component->expr;
424-
} else {
425-
$fields = array();
426-
if ((isset($component->database)) && ($component->database !== '')) {
427-
$fields[] = $component->database;
428-
}
429-
if ((isset($component->table)) && ($component->table !== '')) {
430-
$fields[] = $component->table;
431-
}
432-
if ((isset($component->column)) && ($component->column !== '')) {
433-
$fields[] = $component->column;
434-
}
435-
$ret = implode('.', Context::escape($fields));
426+
$fields = array();
427+
if ((isset($component->database)) && ($component->database !== '')) {
428+
$fields[] = $component->database;
436429
}
437-
438-
if (!empty($component->alias)) {
439-
$ret .= ' AS ' . Context::escape($component->alias);
430+
if ((isset($component->table)) && ($component->table !== '')) {
431+
$fields[] = $component->table;
432+
}
433+
if ((isset($component->column)) && ($component->column !== '')) {
434+
$fields[] = $component->column;
440435
}
436+
$ret = implode('.', Context::escape($fields));
437+
}
441438

442-
return $ret;
439+
if (!empty($component->alias)) {
440+
$ret .= ' AS ' . Context::escape($component->alias);
443441
}
442+
443+
return $ret;
444444
}
445445
}

src/Components/IntoKeyword.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,27 +235,26 @@ public function parseFileOptions(Parser $parser, TokensList $list, $keyword = 'F
235235
public static function build($component, array $options = array())
236236
{
237237
if ($component->dest instanceof Expression) {
238-
$columns = !empty($component->columns) ?
239-
'(`' . implode('`, `', $component->columns) . '`)' : '';
238+
$columns = !empty($component->columns) ? '(`' . implode('`, `', $component->columns) . '`)' : '';
240239

241240
return $component->dest . $columns;
242241
} elseif (isset($component->values)) {
243242
return ExpressionArray::build($component->values);
244-
} else {
245-
$ret = 'OUTFILE "' . $component->dest . '"';
243+
}
246244

247-
$fields_options_str = OptionsArray::build($component->fields_options);
248-
if (trim($fields_options_str) !== '') {
249-
$ret .= ($component->fields_keyword) ? ' FIELDS' : ' COLUMNS';
250-
$ret .= ' ' . $fields_options_str;
251-
}
245+
$ret = 'OUTFILE "' . $component->dest . '"';
252246

253-
$lines_options_str = OptionsArray::build($component->lines_options, array('expr' => true));
254-
if (trim($lines_options_str) !== '') {
255-
$ret .= ' LINES ' . $lines_options_str;
256-
}
247+
$fields_options_str = OptionsArray::build($component->fields_options);
248+
if (trim($fields_options_str) !== '') {
249+
$ret .= ($component->fields_keyword) ? ' FIELDS' : ' COLUMNS';
250+
$ret .= ' ' . $fields_options_str;
251+
}
257252

258-
return $ret;
253+
$lines_options_str = OptionsArray::build($component->lines_options, array('expr' => true));
254+
if (trim($lines_options_str) !== '') {
255+
$ret .= ' LINES ' . $lines_options_str;
259256
}
257+
258+
return $ret;
260259
}
261260
}

src/Components/OrderKeyword.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public static function build($component, array $options = array())
133133
{
134134
if (is_array($component)) {
135135
return implode(', ', $component);
136-
} else {
137-
return $component->expr . ' ' . $component->type;
138136
}
137+
138+
return $component->expr . ' ' . $component->type;
139139
}
140140
}

src/Components/ParameterDefinition.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ public static function build($component, array $options = array())
143143
{
144144
if (is_array($component)) {
145145
return '(' . implode(', ', $component) . ')';
146-
} else {
147-
$tmp = '';
148-
if (!empty($component->inOut)) {
149-
$tmp .= $component->inOut . ' ';
150-
}
146+
}
151147

152-
return trim(
153-
$tmp . Context::escape($component->name) . ' ' . $component->type
154-
);
148+
$tmp = '';
149+
if (!empty($component->inOut)) {
150+
$tmp .= $component->inOut . ' ';
155151
}
152+
153+
return trim(
154+
$tmp . Context::escape($component->name) . ' ' . $component->type
155+
);
156156
}
157157
}

src/Components/PartitionDefinition.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,18 @@ public static function build($component, array $options = array())
203203
{
204204
if (is_array($component)) {
205205
return "(\n" . implode(",\n", $component) . "\n)";
206-
} else {
207-
if ($component->isSubpartition) {
208-
return trim('SUBPARTITION ' . $component->name . ' ' . $component->options);
209-
} else {
210-
$subpartitions = empty($component->subpartitions)
211-
? '' : ' ' . self::build($component->subpartitions);
212-
213-
return trim(
214-
'PARTITION ' . $component->name
215-
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ')
216-
. $component->options . $subpartitions
217-
);
218-
}
219206
}
207+
208+
if ($component->isSubpartition) {
209+
return trim('SUBPARTITION ' . $component->name . ' ' . $component->options);
210+
}
211+
212+
$subpartitions = empty($component->subpartitions) ? '' : ' ' . self::build($component->subpartitions);
213+
214+
return trim(
215+
'PARTITION ' . $component->name
216+
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ')
217+
. $component->options . $subpartitions
218+
);
220219
}
221220
}

src/Components/RenameOperation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ public static function build($component, array $options = array())
163163
{
164164
if (is_array($component)) {
165165
return implode(', ', $component);
166-
} else {
167-
return $component->old . ' TO ' . $component->new;
168166
}
167+
168+
return $component->old . ' TO ' . $component->new;
169169
}
170170
}

0 commit comments

Comments
 (0)