@@ -25,28 +25,67 @@ class AlterOperation extends Component
2525 *
2626 * @var array
2727 */
28- public static $ DB_OPTIONS = array (
29- 'CHARACTER SET ' => array (1 , 'var ' ),
30- 'CHARSET ' => array (1 , 'var ' ),
31- 'DEFAULT CHARACTER SET ' => array (1 , 'var ' ),
32- 'DEFAULT CHARSET ' => array (1 , 'var ' ),
33- 'UPGRADE ' => array (1 , 'var ' ),
34- 'COLLATE ' => array (2 , 'var ' ),
35- 'DEFAULT COLLATE ' => array (2 , 'var ' ),
36- );
28+ public static $ DB_OPTIONS = [
29+ 'CHARACTER SET ' => [
30+ 1 ,
31+ 'var ' ,
32+ ],
33+ 'CHARSET ' => [
34+ 1 ,
35+ 'var ' ,
36+ ],
37+ 'DEFAULT CHARACTER SET ' => [
38+ 1 ,
39+ 'var ' ,
40+ ],
41+ 'DEFAULT CHARSET ' => [
42+ 1 ,
43+ 'var ' ,
44+ ],
45+ 'UPGRADE ' => [
46+ 1 ,
47+ 'var ' ,
48+ ],
49+ 'COLLATE ' => [
50+ 2 ,
51+ 'var ' ,
52+ ],
53+ 'DEFAULT COLLATE ' => [
54+ 2 ,
55+ 'var ' ,
56+ ],
57+ ];
3758
3859 /**
3960 * All table options.
4061 *
4162 * @var array
4263 */
43- public static $ TABLE_OPTIONS = array (
44- 'ENGINE ' => array (1 , 'var= ' ),
45- 'AUTO_INCREMENT ' => array (1 , 'var= ' ),
46- 'AVG_ROW_LENGTH ' => array (1 , 'var ' ),
47- 'MAX_ROWS ' => array (1 , 'var ' ),
48- 'ROW_FORMAT ' => array (1 , 'var ' ),
49- 'COMMENT ' => array (1 , 'var ' ),
64+ public static $ TABLE_OPTIONS = [
65+ 'ENGINE ' => [
66+ 1 ,
67+ 'var= ' ,
68+ ],
69+ 'AUTO_INCREMENT ' => [
70+ 1 ,
71+ 'var= ' ,
72+ ],
73+ 'AVG_ROW_LENGTH ' => [
74+ 1 ,
75+ 'var ' ,
76+ ],
77+ 'MAX_ROWS ' => [
78+ 1 ,
79+ 'var ' ,
80+ ],
81+ 'ROW_FORMAT ' => [
82+ 1 ,
83+ 'var ' ,
84+ ],
85+ 'COMMENT ' => [
86+ 1 ,
87+ 'var ' ,
88+ ],
5089 'ADD ' => 1 ,
5190 'ALTER ' => 1 ,
5291 'ANALYZE ' => 1 ,
@@ -84,16 +123,16 @@ class AlterOperation extends Component
84123 'SPATIAL ' => 2 ,
85124 'TABLESPACE ' => 2 ,
86125 'INDEX ' => 2 ,
87- ) ;
126+ ] ;
88127
89128 /**
90129 * All view options.
91130 *
92131 * @var array
93132 */
94- public static $ VIEW_OPTIONS = array (
133+ public static $ VIEW_OPTIONS = [
95134 'AS ' => 1 ,
96- ) ;
135+ ] ;
97136
98137 /**
99138 * Options of this operation.
@@ -114,7 +153,7 @@ class AlterOperation extends Component
114153 *
115154 * @var Token[]|string
116155 */
117- public $ unknown = array () ;
156+ public $ unknown = [] ;
118157
119158 /**
120159 * Constructor.
@@ -126,7 +165,7 @@ class AlterOperation extends Component
126165 public function __construct (
127166 $ options = null ,
128167 $ field = null ,
129- $ unknown = array ()
168+ $ unknown = []
130169 ) {
131170 $ this ->options = $ options ;
132171 $ this ->field = $ field ;
@@ -140,7 +179,7 @@ public function __construct(
140179 *
141180 * @return AlterOperation
142181 */
143- public static function parse (Parser $ parser , TokensList $ list , array $ options = array () )
182+ public static function parse (Parser $ parser , TokensList $ list , array $ options = [] )
144183 {
145184 $ ret = new self ();
146185
@@ -212,10 +251,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
212251 $ ret ->field = Expression::parse (
213252 $ parser ,
214253 $ list ,
215- array (
254+ [
216255 'breakOnAlias ' => true ,
217256 'parseField ' => 'column ' ,
218- )
257+ ]
219258 );
220259 if ($ ret ->field === null ) {
221260 // No field was read. We go back one token so the next
@@ -232,11 +271,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
232271 } elseif (($ token ->value === ', ' ) && ($ brackets === 0 )) {
233272 break ;
234273 }
235- } elseif (!empty (Parser::$ STATEMENT_PARSERS [$ token ->value ])) {
274+ } elseif (! empty (Parser::$ STATEMENT_PARSERS [$ token ->value ])) {
236275 // We have reached the end of ALTER operation and suddenly found
237276 // a start to new statement, but have not find a delimiter between them
238277
239- if (!($ token ->value === 'SET ' && $ list ->tokens [$ list ->idx - 1 ]->value === 'CHARACTER ' )) {
278+ if (! ($ token ->value === 'SET ' && $ list ->tokens [$ list ->idx - 1 ]->value === 'CHARACTER ' )) {
240279 $ parser ->error (
241280 'A new statement was found, but no delimiter between it and the previous one. ' ,
242281 $ token
@@ -245,7 +284,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
245284 }
246285 } elseif (array_key_exists ($ token ->value , self ::$ DB_OPTIONS )
247286 || (array_key_exists ($ token ->value , self ::$ TABLE_OPTIONS )
248- && !self ::checkIfColumnDefinitionKeyword ($ token ->value ))
287+ && ! self ::checkIfColumnDefinitionKeyword ($ token ->value ))
249288 ) {
250289 // This alter operation has finished, which means a comma was missing before start of new alter operation
251290 $ parser ->error (
@@ -276,7 +315,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
276315 *
277316 * @return string
278317 */
279- public static function build ($ component , array $ options = array () )
318+ public static function build ($ component , array $ options = [] )
280319 {
281320 $ ret = $ component ->options . ' ' ;
282321 if ((isset ($ component ->field )) && ($ component ->field !== '' )) {
@@ -293,8 +332,13 @@ public static function build($component, array $options = array())
293332 *
294333 * @param string $tokenValue Value of current token
295334 */
296- private static function checkIfColumnDefinitionKeyword ($ tokenValue ) {
297- $ common_options = array ('AUTO_INCREMENT ' , 'COMMENT ' , 'DEFAULT ' );
335+ private static function checkIfColumnDefinitionKeyword ($ tokenValue )
336+ {
337+ $ common_options = [
338+ 'AUTO_INCREMENT ' ,
339+ 'COMMENT ' ,
340+ 'DEFAULT ' ,
341+ ];
298342 // Since AUTO_INCREMENT and COMMENT can be used for
299343 // both table as well as a specific column in the table
300344 return in_array ($ tokenValue , $ common_options );
0 commit comments