Skip to content

Commit b6e999a

Browse files
committed
Merge remote-tracking branch 'origin/motranslator' into motranslator
2 parents 7777fec + 5b1af70 commit b6e999a

135 files changed

Lines changed: 1896 additions & 2289 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.php_cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
// @see https://github.com/FriendsOfPHP/PHP-CS-Fixer
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in(array(__DIR__ . '/bin', __DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/tools'))
7+
;
8+
9+
return PhpCsFixer\Config::create()
10+
->setRules(array(
11+
'@PSR1' => true,
12+
'@PSR2' => true,
13+
'@Symfony' => true,
14+
'array_syntax' => array('syntax' => 'long'),
15+
'concat_space' => array('spacing' => true),
16+
'no_trailing_whitespace' => true,
17+
'phpdoc_order' => true,
18+
))
19+
->setFinder($finder)
20+
;

src/Component.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,29 @@
77
* There is a small difference between *Component and *Keyword classes: usually,
88
* *Component parsers can be reused in multiple situations and *Keyword parsers
99
* count on the *Component classes to do their job.
10-
*
11-
* @package SqlParser
1210
*/
11+
1312
namespace SqlParser;
1413

1514
/**
1615
* A component (of a statement) is a part of a statement that is common to
1716
* multiple query types.
1817
*
1918
* @category Components
20-
* @package SqlParser
19+
*
2120
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
2221
*/
2322
abstract class Component
2423
{
25-
2624
/**
2725
* Parses the tokens contained in the given list in the context of the given
2826
* parser.
2927
*
30-
* @param Parser $parser The parser that serves as context.
31-
* @param TokensList $list The list of tokens that are being parsed.
32-
* @param array $options Parameters for parsing.
28+
* @param Parser $parser the parser that serves as context
29+
* @param TokensList $list the list of tokens that are being parsed
30+
* @param array $options parameters for parsing
3331
*
34-
* @throws \Exception Not implemented yet.
32+
* @throws \Exception not implemented yet
3533
*
3634
* @return mixed
3735
*/
@@ -51,10 +49,10 @@ public static function parse(
5149
* In other words, this function represents the inverse function of
5250
* `static::parse`.
5351
*
54-
* @param mixed $component The component to be built.
55-
* @param array $options Parameters for building.
52+
* @param mixed $component the component to be built
53+
* @param array $options parameters for building
5654
*
57-
* @throws \Exception Not implemented yet.
55+
* @throws \Exception not implemented yet
5856
*
5957
* @return string
6058
*/

src/Components/AlterOperation.php

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
/**
44
* Parses an alter operation.
5-
*
6-
* @package SqlParser
7-
* @subpackage Components
85
*/
6+
97
namespace SqlParser\Components;
108

119
use SqlParser\Component;
@@ -17,86 +15,84 @@
1715
* Parses an alter operation.
1816
*
1917
* @category Components
20-
* @package SqlParser
21-
* @subpackage Components
18+
*
2219
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
2320
*/
2421
class AlterOperation extends Component
2522
{
26-
2723
/**
28-
* All database options
24+
* All database options.
2925
*
3026
* @var array
3127
*/
3228
public static $DB_OPTIONS = array(
33-
'CHARACTER SET' => array(1, 'var'),
34-
'CHARSET' => array(1, 'var'),
35-
'DEFAULT CHARACTER SET' => array(1, 'var'),
36-
'DEFAULT CHARSET' => array(1, 'var'),
37-
'UPGRADE' => array(1, 'var'),
38-
'COLLATE' => array(2, 'var'),
39-
'DEFAULT COLLATE' => array(2, 'var'),
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'),
4036
);
4137

4238
/**
43-
* All table options
39+
* All table options.
4440
*
4541
* @var array
4642
*/
4743
public static $TABLE_OPTIONS = array(
48-
'ENGINE' => array(1, 'var='),
49-
'AUTO_INCREMENT' => array(1, 'var='),
50-
'AVG_ROW_LENGTH' => array(1, 'var'),
51-
'MAX_ROWS' => array(1, 'var'),
52-
'ROW_FORMAT' => array(1, 'var'),
53-
'COMMENT' => array(1, 'var'),
54-
'ADD' => 1,
55-
'ALTER' => 1,
56-
'ANALYZE' => 1,
57-
'CHANGE' => 1,
58-
'CHECK' => 1,
59-
'COALESCE' => 1,
60-
'CONVERT' => 1,
61-
'DISABLE' => 1,
62-
'DISCARD' => 1,
63-
'DROP' => 1,
64-
'ENABLE' => 1,
65-
'IMPORT' => 1,
66-
'MODIFY' => 1,
67-
'OPTIMIZE' => 1,
68-
'ORDER' => 1,
69-
'PARTITION' => 1,
70-
'REBUILD' => 1,
71-
'REMOVE' => 1,
72-
'RENAME' => 1,
73-
'REORGANIZE' => 1,
74-
'REPAIR' => 1,
75-
'UPGRADE' => 1,
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'),
50+
'ADD' => 1,
51+
'ALTER' => 1,
52+
'ANALYZE' => 1,
53+
'CHANGE' => 1,
54+
'CHECK' => 1,
55+
'COALESCE' => 1,
56+
'CONVERT' => 1,
57+
'DISABLE' => 1,
58+
'DISCARD' => 1,
59+
'DROP' => 1,
60+
'ENABLE' => 1,
61+
'IMPORT' => 1,
62+
'MODIFY' => 1,
63+
'OPTIMIZE' => 1,
64+
'ORDER' => 1,
65+
'PARTITION' => 1,
66+
'REBUILD' => 1,
67+
'REMOVE' => 1,
68+
'RENAME' => 1,
69+
'REORGANIZE' => 1,
70+
'REPAIR' => 1,
71+
'UPGRADE' => 1,
7672

77-
'COLUMN' => 2,
78-
'CONSTRAINT' => 2,
79-
'DEFAULT' => 2,
80-
'TO' => 2,
81-
'BY' => 2,
82-
'FOREIGN' => 2,
83-
'FULLTEXT' => 2,
84-
'KEY' => 2,
85-
'KEYS' => 2,
86-
'PARTITIONING' => 2,
87-
'PRIMARY KEY' => 2,
88-
'SPATIAL' => 2,
89-
'TABLESPACE' => 2,
90-
'INDEX' => 2,
73+
'COLUMN' => 2,
74+
'CONSTRAINT' => 2,
75+
'DEFAULT' => 2,
76+
'TO' => 2,
77+
'BY' => 2,
78+
'FOREIGN' => 2,
79+
'FULLTEXT' => 2,
80+
'KEY' => 2,
81+
'KEYS' => 2,
82+
'PARTITIONING' => 2,
83+
'PRIMARY KEY' => 2,
84+
'SPATIAL' => 2,
85+
'TABLESPACE' => 2,
86+
'INDEX' => 2,
9187
);
9288

9389
/**
94-
* All view options
90+
* All view options.
9591
*
9692
* @var array
9793
*/
9894
public static $VIEW_OPTIONS = array(
99-
'AS' => 1,
95+
'AS' => 1,
10096
);
10197

10298
/**
@@ -121,20 +117,20 @@ class AlterOperation extends Component
121117
public $unknown = array();
122118

123119
/**
124-
* @param Parser $parser The parser that serves as context.
125-
* @param TokensList $list The list of tokens that are being parsed.
126-
* @param array $options Parameters for parsing.
120+
* @param Parser $parser the parser that serves as context
121+
* @param TokensList $list the list of tokens that are being parsed
122+
* @param array $options parameters for parsing
127123
*
128124
* @return AlterOperation
129125
*/
130126
public static function parse(Parser $parser, TokensList $list, array $options = array())
131127
{
132-
$ret = new AlterOperation();
128+
$ret = new self();
133129

134130
/**
135131
* Counts brackets.
136132
*
137-
* @var int $brackets
133+
* @var int
138134
*/
139135
$brackets = 0;
140136

@@ -149,15 +145,15 @@ public static function parse(Parser $parser, TokensList $list, array $options =
149145
*
150146
* 2 -------------------------[ , ]-----------------------> 0
151147
*
152-
* @var int $state
148+
* @var int
153149
*/
154150
$state = 0;
155151

156152
for (; $list->idx < $list->count; ++$list->idx) {
157153
/**
158154
* Token parsed at this moment.
159155
*
160-
* @var Token $token
156+
* @var Token
161157
*/
162158
$token = $list->tokens[$list->idx];
163159

@@ -223,7 +219,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
223219
// We have reached the end of ALTER operation and suddenly found
224220
// a start to new statement, but have not find a delimiter between them
225221

226-
if (! ($token->value == 'SET' && $list->tokens[$list->idx - 1]->value == 'CHARACTER')) {
222+
if (!($token->value == 'SET' && $list->tokens[$list->idx - 1]->value == 'CHARACTER')) {
227223
$parser->error(
228224
'A new statement was found, but no delimiter between it and the previous one.',
229225
$token
@@ -248,8 +244,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
248244
}
249245

250246
/**
251-
* @param AlterOperation $component The component to be built.
252-
* @param array $options Parameters for building.
247+
* @param AlterOperation $component the component to be built
248+
* @param array $options parameters for building
253249
*
254250
* @return string
255251
*/
@@ -260,6 +256,7 @@ public static function build($component, array $options = array())
260256
$ret .= $component->field . ' ';
261257
}
262258
$ret .= TokensList::build($component->unknown);
259+
263260
return $ret;
264261
}
265262
}

src/Components/Array2d.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
/**
44
* `VALUES` keyword parser.
5-
*
6-
* @package SqlParser
7-
* @subpackage Components
85
*/
6+
97
namespace SqlParser\Components;
108

119
use SqlParser\Component;
@@ -18,17 +16,15 @@
1816
* `VALUES` keyword parser.
1917
*
2018
* @category Keywords
21-
* @package SqlParser
22-
* @subpackage Components
19+
*
2320
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
2421
*/
2522
class Array2d extends Component
2623
{
27-
2824
/**
29-
* @param Parser $parser The parser that serves as context.
30-
* @param TokensList $list The list of tokens that are being parsed.
31-
* @param array $options Parameters for parsing.
25+
* @param Parser $parser the parser that serves as context
26+
* @param TokensList $list the list of tokens that are being parsed
27+
* @param array $options parameters for parsing
3228
*
3329
* @return ArrayObj[]
3430
*/
@@ -39,7 +35,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
3935
/**
4036
* The number of values in each set.
4137
*
42-
* @var int $count
38+
* @var int
4339
*/
4440
$count = -1;
4541

@@ -53,15 +49,15 @@ public static function parse(Parser $parser, TokensList $list, array $options =
5349
* 1 ------------------------[ , ]------------------------> 0
5450
* 1 -----------------------[ else ]----------------------> (END)
5551
*
56-
* @var int $state
52+
* @var int
5753
*/
5854
$state = 0;
5955

6056
for (; $list->idx < $list->count; ++$list->idx) {
6157
/**
6258
* Token parsed at this moment.
6359
*
64-
* @var Token $token
60+
* @var Token
6561
*/
6662
$token = $list->tokens[$list->idx];
6763

@@ -118,12 +114,13 @@ public static function parse(Parser $parser, TokensList $list, array $options =
118114
}
119115

120116
--$list->idx;
117+
121118
return $ret;
122119
}
123120

124121
/**
125-
* @param ArrayObj[] $component The component to be built.
126-
* @param array $options Parameters for building.
122+
* @param ArrayObj[] $component the component to be built
123+
* @param array $options parameters for building
127124
*
128125
* @return string
129126
*/

0 commit comments

Comments
 (0)