Skip to content

Commit ffd1470

Browse files
committed
Use single-line array for single value arrays
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 509cc1d commit ffd1470

12 files changed

+25
-75
lines changed

src/Components/AlterOperation.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ class AlterOperation extends Component
128128
*
129129
* @var array
130130
*/
131-
public static $VIEW_OPTIONS = [
132-
'AS' => 1,
133-
];
131+
public static $VIEW_OPTIONS = ['AS' => 1];
134132

135133
/**
136134
* Options of this operation.

src/Components/PartitionDefinition.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
213213
$ret->subpartitions = ArrayObj::parse(
214214
$parser,
215215
$list,
216-
[
217-
'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition',
218-
]
216+
['type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition']
219217
);
220218
++$list->idx;
221219
}

src/Components/SetOperation.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
115115
$tmp = Expression::parse(
116116
$parser,
117117
$list,
118-
[
119-
'breakOnAlias' => true,
120-
]
118+
['breakOnAlias' => true]
121119
);
122120
if ($tmp === null) {
123121
$parser->error('Missing expression.', $token);

src/Statements/CreateStatement.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,7 @@ public function parse(Parser $parser, TokensList $list)
645645
$this->partitions = ArrayObj::parse(
646646
$parser,
647647
$list,
648-
[
649-
'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition',
650-
]
648+
['type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition']
651649
);
652650
}
653651

src/Statements/TruncateStatement.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ class TruncateStatement extends Statement
1919
*
2020
* @var array
2121
*/
22-
public static $OPTIONS = [
23-
'TABLE' => 1,
24-
];
22+
public static $OPTIONS = ['TABLE' => 1];
2523

2624
/**
2725
* The name of the truncated table.

tests/Components/ArrayObjTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public function testParseType()
2929
$this->getTokensList('(1 + 2, 3 + 4)'),
3030
[
3131
'type' => Expression::class,
32-
'typeOptions' => [
33-
'breakOnParentheses' => true,
34-
],
32+
'typeOptions' => ['breakOnParentheses' => true],
3533
]
3634
);
3735
$this->assertInstanceOf(Expression::class, $components[0]);

tests/Components/ExpressionArrayTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public function testParse()
1414
$component = ExpressionArray::parse(
1515
new Parser(),
1616
$this->getTokensList('(expr)'),
17-
[
18-
'breakOnParentheses' => true,
19-
]
17+
['breakOnParentheses' => true]
2018
);
2119
$this->assertEquals([], $component);
2220
}
@@ -26,9 +24,7 @@ public function testParse2()
2624
$component = ExpressionArray::parse(
2725
new Parser(),
2826
$this->getTokensList('(expr) +'),
29-
[
30-
'parenthesesDelimited' => true,
31-
]
27+
['parenthesesDelimited' => true]
3228
);
3329
$this->assertCount(1, $component);
3430
$this->assertEquals('(expr)', $component[0]->expr);

tests/Utils/CLITest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,19 @@ public function highlightParamsStdIn()
141141
],
142142
[
143143
'SELECT /* comment */ 1 /* other */',
144-
[
145-
'f' => 'text',
146-
],
144+
['f' => 'text'],
147145
"SELECT\n /* comment */ 1 /* other */\n",
148146
0,
149147
],
150148
[
151149
'SELECT 1',
152-
[
153-
'f' => 'foo',
154-
],
150+
['f' => 'foo'],
155151
"ERROR: Invalid value for format!\n",
156152
1,
157153
],
158154
[
159155
'SELECT 1',
160-
[
161-
'f' => 'html',
162-
],
156+
['f' => 'html'],
163157
'<span class="sql-reserved">SELECT</span><br/>' .
164158
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>' . "\n",
165159
0,

tests/Utils/FormatterTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,7 @@ public function formatQueries()
398398
'&nbsp;&nbsp;&nbsp;&nbsp;tbl<br/>' .
399399
'<span class="sql-reserved">WHERE</span><br/>' .
400400
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>',
401-
'options' => [
402-
'remove_comments' => true,
403-
],
401+
'options' => ['remove_comments' => true],
404402
],
405403
'keywords' => [
406404
'query' => 'select hex("1")',

tests/Utils/MiscTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ public function getAliasesProvider()
5858
'tables' => [
5959
'film' => [
6060
'alias' => null,
61-
'columns' => [
62-
'film_id' => 'id',
63-
],
61+
'columns' => ['film_id' => 'id'],
6462
],
6563
],
6664
],

tests/Utils/QueryTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ public function getFlagsProvider()
267267
],
268268
[
269269
'SET NAMES \'latin\'',
270-
[
271-
'querytype' => 'SET',
272-
],
270+
['querytype' => 'SET'],
273271
],
274272
];
275273
}
@@ -386,9 +384,7 @@ public function testGetAll()
386384
[
387385
'parser' => $parser,
388386
'statement' => $parser->statements[0],
389-
'select_expr' => [
390-
'CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END',
391-
],
387+
'select_expr' => ['CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END'],
392388
'select_tables' => [],
393389
]
394390
),

tests/Utils/RoutineTest.php

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -231,48 +231,28 @@ public function getParametersProvider()
231231
'CREATE DEFINER=`user\\`@`somehost``(` FUNCTION `foo```(`baz` INT) BEGIN SELECT NULL; END',
232232
[
233233
'num' => 1,
234-
'dir' => [
235-
0 => '',
236-
],
237-
'name' => [
238-
0 => 'baz',
239-
],
240-
'type' => [
241-
0 => 'INT',
242-
],
243-
'length' => [
244-
0 => '',
245-
],
234+
'dir' => [0 => ''],
235+
'name' => [0 => 'baz'],
236+
'type' => [0 => 'INT'],
237+
'length' => [0 => ''],
246238
'length_arr' => [
247239
0 => [],
248240
],
249-
'opts' => [
250-
0 => '',
251-
],
241+
'opts' => [0 => ''],
252242
],
253243
],
254244
[
255245
'CREATE PROCEDURE `foo`(IN `baz\\)` INT(25) zerofill unsigned) BEGIN SELECT NULL; END',
256246
[
257247
'num' => 1,
258-
'dir' => [
259-
0 => 'IN',
260-
],
261-
'name' => [
262-
0 => 'baz\\)',
263-
],
264-
'type' => [
265-
0 => 'INT',
266-
],
267-
'length' => [
268-
0 => '25',
269-
],
248+
'dir' => [0 => 'IN'],
249+
'name' => [0 => 'baz\\)'],
250+
'type' => [0 => 'INT'],
251+
'length' => [0 => '25'],
270252
'length_arr' => [
271253
0 => ['25'],
272254
],
273-
'opts' => [
274-
0 => 'UNSIGNED ZEROFILL',
275-
],
255+
'opts' => [0 => 'UNSIGNED ZEROFILL'],
276256
],
277257
],
278258
[

0 commit comments

Comments
 (0)