Skip to content

Commit

Permalink
Use single-line array for single value arrays
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 18, 2020
1 parent 509cc1d commit ffd1470
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 75 deletions.
4 changes: 1 addition & 3 deletions src/Components/AlterOperation.php
Expand Up @@ -128,9 +128,7 @@ class AlterOperation extends Component
*
* @var array
*/
public static $VIEW_OPTIONS = [
'AS' => 1,
];
public static $VIEW_OPTIONS = ['AS' => 1];

/**
* Options of this operation.
Expand Down
4 changes: 1 addition & 3 deletions src/Components/PartitionDefinition.php
Expand Up @@ -213,9 +213,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$ret->subpartitions = ArrayObj::parse(
$parser,
$list,
[
'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition',
]
['type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition']
);
++$list->idx;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Components/SetOperation.php
Expand Up @@ -115,9 +115,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$tmp = Expression::parse(
$parser,
$list,
[
'breakOnAlias' => true,
]
['breakOnAlias' => true]
);
if ($tmp === null) {
$parser->error('Missing expression.', $token);
Expand Down
4 changes: 1 addition & 3 deletions src/Statements/CreateStatement.php
Expand Up @@ -645,9 +645,7 @@ public function parse(Parser $parser, TokensList $list)
$this->partitions = ArrayObj::parse(
$parser,
$list,
[
'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition',
]
['type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition']
);
}

Expand Down
4 changes: 1 addition & 3 deletions src/Statements/TruncateStatement.php
Expand Up @@ -19,9 +19,7 @@ class TruncateStatement extends Statement
*
* @var array
*/
public static $OPTIONS = [
'TABLE' => 1,
];
public static $OPTIONS = ['TABLE' => 1];

/**
* The name of the truncated table.
Expand Down
4 changes: 1 addition & 3 deletions tests/Components/ArrayObjTest.php
Expand Up @@ -29,9 +29,7 @@ public function testParseType()
$this->getTokensList('(1 + 2, 3 + 4)'),
[
'type' => Expression::class,
'typeOptions' => [
'breakOnParentheses' => true,
],
'typeOptions' => ['breakOnParentheses' => true],
]
);
$this->assertInstanceOf(Expression::class, $components[0]);
Expand Down
8 changes: 2 additions & 6 deletions tests/Components/ExpressionArrayTest.php
Expand Up @@ -14,9 +14,7 @@ public function testParse()
$component = ExpressionArray::parse(
new Parser(),
$this->getTokensList('(expr)'),
[
'breakOnParentheses' => true,
]
['breakOnParentheses' => true]
);
$this->assertEquals([], $component);
}
Expand All @@ -26,9 +24,7 @@ public function testParse2()
$component = ExpressionArray::parse(
new Parser(),
$this->getTokensList('(expr) +'),
[
'parenthesesDelimited' => true,
]
['parenthesesDelimited' => true]
);
$this->assertCount(1, $component);
$this->assertEquals('(expr)', $component[0]->expr);
Expand Down
12 changes: 3 additions & 9 deletions tests/Utils/CLITest.php
Expand Up @@ -141,25 +141,19 @@ public function highlightParamsStdIn()
],
[
'SELECT /* comment */ 1 /* other */',
[
'f' => 'text',
],
['f' => 'text'],
"SELECT\n /* comment */ 1 /* other */\n",
0,
],
[
'SELECT 1',
[
'f' => 'foo',
],
['f' => 'foo'],
"ERROR: Invalid value for format!\n",
1,
],
[
'SELECT 1',
[
'f' => 'html',
],
['f' => 'html'],
'<span class="sql-reserved">SELECT</span><br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>' . "\n",
0,
Expand Down
4 changes: 1 addition & 3 deletions tests/Utils/FormatterTest.php
Expand Up @@ -398,9 +398,7 @@ public function formatQueries()
'&nbsp;&nbsp;&nbsp;&nbsp;tbl<br/>' .
'<span class="sql-reserved">WHERE</span><br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>',
'options' => [
'remove_comments' => true,
],
'options' => ['remove_comments' => true],
],
'keywords' => [
'query' => 'select hex("1")',
Expand Down
4 changes: 1 addition & 3 deletions tests/Utils/MiscTest.php
Expand Up @@ -58,9 +58,7 @@ public function getAliasesProvider()
'tables' => [
'film' => [
'alias' => null,
'columns' => [
'film_id' => 'id',
],
'columns' => ['film_id' => 'id'],
],
],
],
Expand Down
8 changes: 2 additions & 6 deletions tests/Utils/QueryTest.php
Expand Up @@ -267,9 +267,7 @@ public function getFlagsProvider()
],
[
'SET NAMES \'latin\'',
[
'querytype' => 'SET',
],
['querytype' => 'SET'],
],
];
}
Expand Down Expand Up @@ -386,9 +384,7 @@ public function testGetAll()
[
'parser' => $parser,
'statement' => $parser->statements[0],
'select_expr' => [
'CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END',
],
'select_expr' => ['CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END'],
'select_tables' => [],
]
),
Expand Down
40 changes: 10 additions & 30 deletions tests/Utils/RoutineTest.php
Expand Up @@ -231,48 +231,28 @@ public function getParametersProvider()
'CREATE DEFINER=`user\\`@`somehost``(` FUNCTION `foo```(`baz` INT) BEGIN SELECT NULL; END',
[
'num' => 1,
'dir' => [
0 => '',
],
'name' => [
0 => 'baz',
],
'type' => [
0 => 'INT',
],
'length' => [
0 => '',
],
'dir' => [0 => ''],
'name' => [0 => 'baz'],
'type' => [0 => 'INT'],
'length' => [0 => ''],
'length_arr' => [
0 => [],
],
'opts' => [
0 => '',
],
'opts' => [0 => ''],
],
],
[
'CREATE PROCEDURE `foo`(IN `baz\\)` INT(25) zerofill unsigned) BEGIN SELECT NULL; END',
[
'num' => 1,
'dir' => [
0 => 'IN',
],
'name' => [
0 => 'baz\\)',
],
'type' => [
0 => 'INT',
],
'length' => [
0 => '25',
],
'dir' => [0 => 'IN'],
'name' => [0 => 'baz\\)'],
'type' => [0 => 'INT'],
'length' => [0 => '25'],
'length_arr' => [
0 => ['25'],
],
'opts' => [
0 => 'UNSIGNED ZEROFILL',
],
'opts' => [0 => 'UNSIGNED ZEROFILL'],
],
],
[
Expand Down

0 comments on commit ffd1470

Please sign in to comment.