summaryrefslogtreecommitdiffstats
path: root/src/Components/CreateDefinition.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Components/CreateDefinition.php')
-rw-r--r--src/Components/CreateDefinition.php56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php
index 0f44e09..03f8225 100644
--- a/src/Components/CreateDefinition.php
+++ b/src/Components/CreateDefinition.php
@@ -1,10 +1,10 @@
<?php
-
/**
* Parses the create definition of a column or a key.
*
* Used for parsing `CREATE TABLE` statement.
*/
+declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Components;
@@ -30,61 +30,61 @@ class CreateDefinition extends Component
*
* @var array
*/
- public static $FIELD_OPTIONS = array(
+ public static $FIELD_OPTIONS = [
// Tells the `OptionsArray` to not sort the options.
// See the note below.
'_UNSORTED' => true,
'NOT NULL' => 1,
'NULL' => 1,
- 'DEFAULT' => array(
+ 'DEFAULT' => [
2,
'expr',
- array('breakOnAlias' => true)
- ),
+ ['breakOnAlias' => true],
+ ],
/* Following are not according to grammar, but MySQL happily accepts
* these at any location */
- 'CHARSET' => array(
+ 'CHARSET' => [
2,
'var',
- ),
- 'COLLATE' => array(
+ ],
+ 'COLLATE' => [
3,
'var',
- ),
+ ],
'AUTO_INCREMENT' => 3,
'PRIMARY' => 4,
'PRIMARY KEY' => 4,
'UNIQUE' => 4,
'UNIQUE KEY' => 4,
- 'COMMENT' => array(
+ 'COMMENT' => [
5,
'var',
- ),
- 'COLUMN_FORMAT' => array(
+ ],
+ 'COLUMN_FORMAT' => [
6,
'var',
- ),
- 'ON UPDATE' => array(
+ ],
+ 'ON UPDATE' => [
7,
'expr',
- ),
+ ],
// Generated columns options.
'GENERATED ALWAYS' => 8,
- 'AS' => array(
+ 'AS' => [
9,
'expr',
- array('parenthesesDelimited' => true)
- ),
+ ['parenthesesDelimited' => true],
+ ],
'VIRTUAL' => 10,
'PERSISTENT' => 11,
'STORED' => 11,
- 'CHECK' => array(
+ 'CHECK' => [
12,
'expr',
- array('parenthesesDelimited' => true),
- )
+ ['parenthesesDelimited' => true],
+ ]
// Common entries.
//
// NOTE: Some of the common options are not in the same order which
@@ -99,7 +99,7 @@ class CreateDefinition extends Component
// 'NULL' => 1,
// 'PRIMARY' => 4,
// 'PRIMARY KEY' => 4,
- );
+ ];
/**
* The name of the new column.
@@ -177,11 +177,11 @@ class CreateDefinition extends Component
*
* @return CreateDefinition[]
*/
- public static function parse(Parser $parser, TokensList $list, array $options = array())
+ public static function parse(Parser $parser, TokensList $list, array $options = [])
{
- $ret = array();
+ $ret = [];
- $expr = new self();
+ $expr = new static();
/**
* The state of the parser.
@@ -290,7 +290,7 @@ class CreateDefinition extends Component
if (! empty($expr->type) || ! empty($expr->key)) {
$ret[] = $expr;
}
- $expr = new self();
+ $expr = new static();
if ($token->value === ',') {
$state = 1;
} elseif ($token->value === ')') {
@@ -331,7 +331,7 @@ class CreateDefinition extends Component
*
* @return string
*/
- public static function build($component, array $options = array())
+ public static function build($component, array $options = [])
{
if (is_array($component)) {
return "(\n " . implode(",\n ", $component) . "\n)";
@@ -350,7 +350,7 @@ class CreateDefinition extends Component
if (! empty($component->type)) {
$tmp .= DataType::build(
$component->type,
- array('lowercase' => true)
+ ['lowercase' => true]
) . ' ';
}