@@ -115,19 +115,19 @@ |
||
115 | 115 | */ |
116 | 116 | public function build() |
117 | 117 | { |
118 | - $ret = 'INSERT ' . $this->options |
|
119 | - . ' INTO ' . $this->into; |
|
118 | + $ret = 'INSERT '.$this->options |
|
119 | + . ' INTO '.$this->into; |
|
120 | 120 | |
121 | 121 | if ($this->values != NULL && count($this->values) > 0) { |
122 | - $ret .= ' VALUES ' . Array2d::build($this->values); |
|
122 | + $ret .= ' VALUES '.Array2d::build($this->values); |
|
123 | 123 | } elseif ($this->set != NULL && count($this->set) > 0) { |
124 | - $ret .= ' SET ' . SetOperation::build($this->set); |
|
124 | + $ret .= ' SET '.SetOperation::build($this->set); |
|
125 | 125 | } elseif ($this->select != NULL && count($this->select) > 0) { |
126 | - $ret .= ' ' . $this->select->build(); |
|
126 | + $ret .= ' '.$this->select->build(); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | if ($this->onDuplicateSet != NULL && count($this->onDuplicateSet) > 0) { |
130 | - $ret .= ' ON DUPLICATE KEY UPDATE ' . SetOperation::build($this->onDuplicateSet); |
|
130 | + $ret .= ' ON DUPLICATE KEY UPDATE '.SetOperation::build($this->onDuplicateSet); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $ret; |
@@ -93,15 +93,15 @@ |
||
93 | 93 | */ |
94 | 94 | public function build() |
95 | 95 | { |
96 | - $ret = 'REPLACE ' . $this->options |
|
97 | - . ' INTO ' . $this->into; |
|
96 | + $ret = 'REPLACE '.$this->options |
|
97 | + . ' INTO '.$this->into; |
|
98 | 98 | |
99 | 99 | if ($this->values != NULL && count($this->values) > 0) { |
100 | - $ret .= ' VALUES ' . Array2d::build($this->values); |
|
100 | + $ret .= ' VALUES '.Array2d::build($this->values); |
|
101 | 101 | } elseif ($this->set != NULL && count($this->set) > 0) { |
102 | - $ret .= ' SET ' . SetOperation::build($this->set); |
|
102 | + $ret .= ' SET '.SetOperation::build($this->set); |
|
103 | 103 | } elseif ($this->select != NULL && count($this->select) > 0) { |
104 | - $ret .= ' ' . $this->select->build(); |
|
104 | + $ret .= ' '.$this->select->build(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $ret; |
@@ -183,7 +183,7 @@ |
||
183 | 183 | 'value' => '', |
184 | 184 | ); |
185 | 185 | $state = 1; |
186 | - } elseif ($lastOption[1] === 'expr' || $lastOption[1] === 'expr=') { |
|
186 | + } elseif ($lastOption[1] === 'expr' || $lastOption[1] === 'expr=') { |
|
187 | 187 | // This is a keyword that is followed by an expression. |
188 | 188 | // The expression is used by the specialized parser. |
189 | 189 |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | // pieces only if the clause is not inlined or this fragment |
351 | 351 | // is between brackets that are on new line. |
352 | 352 | if (((empty(self::$INLINE_CLAUSES[$lastClause])) |
353 | - && ! $shortGroup |
|
353 | + && !$shortGroup |
|
354 | 354 | && ($this->options['parts_newline'])) |
355 | 355 | || (end($blocksLineEndings) === true) |
356 | 356 | ) { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | } |
425 | 425 | |
426 | 426 | if ($this->options['type'] === 'cli') { |
427 | - return $ret . "\x1b[0m"; |
|
427 | + return $ret."\x1b[0m"; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | return $ret; |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | array( |
437 | 437 | "\x00", "\x01", "\x02", "\x03", "\x04", |
438 | 438 | "\x05", "\x06", "\x07", "\x08", "\x09", "\x0A", |
439 | - "\x0B","\x0C","\x0D", "\x0E", "\x0F", "\x10", "\x11", |
|
440 | - "\x12","\x13","\x14","\x15", "\x16", "\x17", "\x18", |
|
441 | - "\x19","\x1A","\x1B","\x1C","\x1D", "\x1E", "\x1F" |
|
439 | + "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", |
|
440 | + "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", |
|
441 | + "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F" |
|
442 | 442 | ), |
443 | 443 | array( |
444 | 444 | '\x00', '\x01', '\x02', '\x03', '\x04', |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | |
475 | 475 | // Formatting HTML. |
476 | 476 | if ($this->options['type'] === 'html') { |
477 | - return '<span ' . $format['html'] . '>' . htmlspecialchars($text, ENT_NOQUOTES) . '</span>'; |
|
477 | + return '<span '.$format['html'].'>'.htmlspecialchars($text, ENT_NOQUOTES).'</span>'; |
|
478 | 478 | } elseif ($this->options['type'] === 'cli') { |
479 | - return $format['cli'] . $this->escapeConsole($text); |
|
479 | + return $format['cli'].$this->escapeConsole($text); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | break; |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | } |
485 | 485 | |
486 | 486 | if ($this->options['type'] === 'cli') { |
487 | - return "\x1b[39m" . $this->escapeConsole($text); |
|
487 | + return "\x1b[39m".$this->escapeConsole($text); |
|
488 | 488 | } elseif ($this->options['type'] === 'html') { |
489 | 489 | return htmlspecialchars($text, ENT_NOQUOTES); |
490 | 490 | } |
@@ -302,7 +302,7 @@ |
||
302 | 302 | ++$list->idx; // Skip 'ORDER BY' |
303 | 303 | $this->order = OrderKeyword::parse($parser, $list); |
304 | 304 | $state = 5; |
305 | - } elseif ($token->type === Token::TYPE_KEYWORD |
|
305 | + } elseif ($token->type === Token::TYPE_KEYWORD |
|
306 | 306 | && $token->value === 'LIMIT' |
307 | 307 | ) { |
308 | 308 | ++$list->idx; // Skip 'LIMIT' |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * @var array |
72 | 72 | */ |
73 | 73 | public static $CLAUSES = array( |
74 | - 'DELETE' => array('DELETE', 2), |
|
74 | + 'DELETE' => array('DELETE', 2), |
|
75 | 75 | // Used for options. |
76 | - '_OPTIONS' => array('_OPTIONS', 1), |
|
77 | - 'FROM' => array('FROM', 3), |
|
78 | - 'PARTITION' => array('PARTITION', 3), |
|
79 | - 'USING' => array('USING', 3), |
|
80 | - 'WHERE' => array('WHERE', 3), |
|
81 | - 'ORDER BY' => array('ORDER BY', 3), |
|
82 | - 'LIMIT' => array('LIMIT', 3), |
|
76 | + '_OPTIONS' => array('_OPTIONS', 1), |
|
77 | + 'FROM' => array('FROM', 3), |
|
78 | + 'PARTITION' => array('PARTITION', 3), |
|
79 | + 'USING' => array('USING', 3), |
|
80 | + 'WHERE' => array('WHERE', 3), |
|
81 | + 'ORDER BY' => array('ORDER BY', 3), |
|
82 | + 'LIMIT' => array('LIMIT', 3), |
|
83 | 83 | ); |
84 | 84 | |
85 | 85 | /** |
@@ -137,25 +137,25 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function build() |
139 | 139 | { |
140 | - $ret = 'DELETE ' . OptionsArray::build($this->options); |
|
140 | + $ret = 'DELETE '.OptionsArray::build($this->options); |
|
141 | 141 | |
142 | 142 | if ($this->columns != NULL && count($this->columns) > 0) { |
143 | - $ret .= ' ' . ExpressionArray::build($this->columns); |
|
143 | + $ret .= ' '.ExpressionArray::build($this->columns); |
|
144 | 144 | } |
145 | 145 | if ($this->from != NULL && count($this->from) > 0) { |
146 | - $ret .= ' FROM ' . ExpressionArray::build($this->from); |
|
146 | + $ret .= ' FROM '.ExpressionArray::build($this->from); |
|
147 | 147 | } |
148 | 148 | if ($this->using != NULL && count($this->using) > 0) { |
149 | - $ret .= ' USING ' . ExpressionArray::build($this->using); |
|
149 | + $ret .= ' USING '.ExpressionArray::build($this->using); |
|
150 | 150 | } |
151 | 151 | if ($this->where != NULL && count($this->where) > 0) { |
152 | - $ret .= ' WHERE ' . Condition::build($this->where); |
|
152 | + $ret .= ' WHERE '.Condition::build($this->where); |
|
153 | 153 | } |
154 | 154 | if ($this->order != NULL && count($this->order) > 0) { |
155 | - $ret .= ' ORDER BY ' . ExpressionArray::build($this->order); |
|
155 | + $ret .= ' ORDER BY '.ExpressionArray::build($this->order); |
|
156 | 156 | } |
157 | 157 | if ($this->limit != NULL && count($this->limit) > 0) { |
158 | - $ret .= ' LIMIT ' . Limit::build($this->limit); |
|
158 | + $ret .= ' LIMIT '.Limit::build($this->limit); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $ret; |
@@ -127,6 +127,6 @@ |
||
127 | 127 | */ |
128 | 128 | public static function build($component, array $options = array()) |
129 | 129 | { |
130 | - return $component->offset . ', ' . $component->rowCount; |
|
130 | + return $component->offset.', '.$component->rowCount; |
|
131 | 131 | } |
132 | 132 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | * @param Parser $parser The parser that serves as context. |
78 | 78 | * @param TokensList $list The list of tokens that are being parsed. |
79 | 79 | * |
80 | - * @return Expression |
|
80 | + * @return CaseExpression |
|
81 | 81 | */ |
82 | 82 | public static function parse(Parser $parser, TokensList $list) |
83 | 83 | { |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | $ret = 'CASE '; |
255 | 255 | if (isset($component->value)) { |
256 | 256 | // Syntax type 0 |
257 | - $ret .= $component->value . ' '; |
|
257 | + $ret .= $component->value.' '; |
|
258 | 258 | for ( |
259 | 259 | $i = 0; |
260 | 260 | $i < count($component->compare_values) && $i < count($component->results); |
261 | 261 | $i++ |
262 | 262 | ) { |
263 | - $ret .= 'WHEN ' . $component->compare_values[$i] . ' '; |
|
264 | - $ret .= 'THEN ' . $component->results[$i] . ' '; |
|
263 | + $ret .= 'WHEN '.$component->compare_values[$i].' '; |
|
264 | + $ret .= 'THEN '.$component->results[$i].' '; |
|
265 | 265 | } |
266 | 266 | } else { |
267 | 267 | // Syntax type 1 |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | $i < count($component->conditions) && $i < count($component->results); |
271 | 271 | $i++ |
272 | 272 | ) { |
273 | - $ret .= 'WHEN ' . Condition::build($component->conditions[$i]) . ' '; |
|
274 | - $ret .= 'THEN ' . $component->results[$i] . ' '; |
|
273 | + $ret .= 'WHEN '.Condition::build($component->conditions[$i]).' '; |
|
274 | + $ret .= 'THEN '.$component->results[$i].' '; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | if (isset($component->else_result)) { |
278 | - $ret .= 'ELSE ' . $component->else_result . ' '; |
|
278 | + $ret .= 'ELSE '.$component->else_result.' '; |
|
279 | 279 | } |
280 | 280 | $ret .= 'END'; |
281 | 281 |
@@ -52,46 +52,46 @@ discard block |
||
52 | 52 | * @var string |
53 | 53 | */ |
54 | 54 | const TEMPLATE = |
55 | - '<?php' . "\n" . |
|
56 | - '' . "\n" . |
|
57 | - '/**' . "\n" . |
|
58 | - ' * Context for %1$s.' . "\n" . |
|
59 | - ' *' . "\n" . |
|
60 | - ' * This file was auto-generated.' . "\n" . |
|
61 | - ' *' . "\n" . |
|
62 | - ' * @package SqlParser' . "\n" . |
|
63 | - ' * @subpackage Contexts' . "\n" . |
|
64 | - ' * @link %3$s' . "\n" . |
|
65 | - ' */' . "\n" . |
|
66 | - 'namespace SqlParser\\Contexts;' . "\n" . |
|
67 | - '' . "\n" . |
|
68 | - 'use SqlParser\\Context;' . "\n" . |
|
69 | - '' . "\n" . |
|
70 | - '/**' . "\n" . |
|
71 | - ' * Context for %1$s.' . "\n" . |
|
72 | - ' *' . "\n" . |
|
73 | - ' * @category Contexts' . "\n" . |
|
74 | - ' * @package SqlParser' . "\n" . |
|
75 | - ' * @subpackage Contexts' . "\n" . |
|
76 | - ' * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+' . "\n" . |
|
77 | - ' */' . "\n" . |
|
78 | - 'class %2$s extends Context' . "\n" . |
|
79 | - '{' . "\n" . |
|
80 | - '' . "\n" . |
|
81 | - ' /**' . "\n" . |
|
82 | - ' * List of keywords.' . "\n" . |
|
83 | - ' *' . "\n" . |
|
84 | - ' * The value associated to each keyword represents its flags.' . "\n" . |
|
85 | - ' *' . "\n" . |
|
86 | - ' * @see Token::FLAG_KEYWORD_*' . "\n" . |
|
87 | - ' *' . "\n" . |
|
88 | - ' * @var array' . "\n" . |
|
89 | - ' */' . "\n" . |
|
90 | - ' public static $KEYWORDS = array(' . "\n" . |
|
91 | - '' . "\n" . |
|
92 | - '%4$s' . |
|
93 | - ' );' . "\n" . |
|
94 | - '}' . "\n"; |
|
55 | + '<?php'."\n". |
|
56 | + ''."\n". |
|
57 | + '/**'."\n". |
|
58 | + ' * Context for %1$s.'."\n". |
|
59 | + ' *'."\n". |
|
60 | + ' * This file was auto-generated.'."\n". |
|
61 | + ' *'."\n". |
|
62 | + ' * @package SqlParser'."\n". |
|
63 | + ' * @subpackage Contexts'."\n". |
|
64 | + ' * @link %3$s'."\n". |
|
65 | + ' */'."\n". |
|
66 | + 'namespace SqlParser\\Contexts;'."\n". |
|
67 | + ''."\n". |
|
68 | + 'use SqlParser\\Context;'."\n". |
|
69 | + ''."\n". |
|
70 | + '/**'."\n". |
|
71 | + ' * Context for %1$s.'."\n". |
|
72 | + ' *'."\n". |
|
73 | + ' * @category Contexts'."\n". |
|
74 | + ' * @package SqlParser'."\n". |
|
75 | + ' * @subpackage Contexts'."\n". |
|
76 | + ' * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+'."\n". |
|
77 | + ' */'."\n". |
|
78 | + 'class %2$s extends Context'."\n". |
|
79 | + '{'."\n". |
|
80 | + ''."\n". |
|
81 | + ' /**'."\n". |
|
82 | + ' * List of keywords.'."\n". |
|
83 | + ' *'."\n". |
|
84 | + ' * The value associated to each keyword represents its flags.'."\n". |
|
85 | + ' *'."\n". |
|
86 | + ' * @see Token::FLAG_KEYWORD_*'."\n". |
|
87 | + ' *'."\n". |
|
88 | + ' * @var array'."\n". |
|
89 | + ' */'."\n". |
|
90 | + ' public static $KEYWORDS = array('."\n". |
|
91 | + ''."\n". |
|
92 | + '%4$s'. |
|
93 | + ' );'."\n". |
|
94 | + '}'."\n"; |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Sorts an array of words. |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | if ($i == 0) { |
197 | 197 | $ret .= str_repeat(' ', $spaces); |
198 | 198 | } |
199 | - $ret .= "'" . $word . "' => " . $type . ', '; |
|
199 | + $ret .= "'".$word."' => ".$type.', '; |
|
200 | 200 | if (++$i == $count) { |
201 | 201 | $ret .= "\n"; |
202 | 202 | $i = 0; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @var string |
259 | 259 | */ |
260 | - $directory = dirname($input) . '/'; |
|
260 | + $directory = dirname($input).'/'; |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * The name of the file that contains the context. |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @var string |
280 | 280 | */ |
281 | - $class = 'Context' . $name; |
|
281 | + $class = 'Context'.$name; |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * The formatted name of this context. |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | * @var string |
287 | 287 | */ |
288 | 288 | $formattedName = str_replace( |
289 | - array('Context', 'MySql', '00', '0'), |
|
290 | - array('', 'MySQL ', '', '.'), |
|
289 | + array('Context', 'MySql', '00', '0'), |
|
290 | + array('', 'MySQL ', '', '.'), |
|
291 | 291 | $class |
292 | 292 | ); |
293 | 293 | |
294 | 294 | file_put_contents( |
295 | - $output . '/' . $class . '.php', |
|
295 | + $output.'/'.$class.'.php', |
|
296 | 296 | static::generate( |
297 | 297 | array( |
298 | 298 | 'name' => $formattedName, |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | 'link' => static::$LINKS[$name], |
301 | 301 | 'keywords' => static::readWords( |
302 | 302 | array( |
303 | - $directory . '_common.txt', |
|
304 | - $directory . '_functions' . $file, |
|
305 | - $directory . $file |
|
303 | + $directory.'_common.txt', |
|
304 | + $directory.'_functions'.$file, |
|
305 | + $directory.$file |
|
306 | 306 | ) |
307 | 307 | ), |
308 | 308 | ) |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | // Building the context. |
332 | 332 | sprintf("Building context for %s...\n", $file); |
333 | - static::build($input . '/' . $file, $output); |
|
333 | + static::build($input.'/'.$file, $output); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
@@ -82,30 +82,30 @@ |
||
82 | 82 | * @var array |
83 | 83 | */ |
84 | 84 | public static $CLAUSES = array( |
85 | - 'SELECT' => array('SELECT', 2), |
|
85 | + 'SELECT' => array('SELECT', 2), |
|
86 | 86 | // Used for options. |
87 | - '_OPTIONS' => array('_OPTIONS', 1), |
|
87 | + '_OPTIONS' => array('_OPTIONS', 1), |
|
88 | 88 | // Used for selected expressions. |
89 | - '_SELECT' => array('SELECT', 1), |
|
90 | - 'INTO' => array('INTO', 3), |
|
91 | - 'FROM' => array('FROM', 3), |
|
92 | - 'PARTITION' => array('PARTITION', 3), |
|
93 | - |
|
94 | - 'JOIN' => array('JOIN', 1), |
|
95 | - 'FULL JOIN' => array('FULL JOIN', 1), |
|
96 | - 'INNER JOIN' => array('INNER JOIN', 1), |
|
97 | - 'LEFT JOIN' => array('LEFT JOIN', 1), |
|
98 | - 'LEFT OUTER JOIN' => array('LEFT OUTER JOIN', 1), |
|
99 | - 'RIGHT JOIN' => array('RIGHT JOIN', 1), |
|
100 | - 'RIGHT OUTER JOIN' => array('RIGHT OUTER JOIN', 1), |
|
101 | - |
|
102 | - 'WHERE' => array('WHERE', 3), |
|
103 | - 'GROUP BY' => array('GROUP BY', 3), |
|
104 | - 'HAVING' => array('HAVING', 3), |
|
105 | - 'ORDER BY' => array('ORDER BY', 3), |
|
106 | - 'LIMIT' => array('LIMIT', 3), |
|
107 | - 'PROCEDURE' => array('PROCEDURE', 3), |
|
108 | - 'UNION' => array('UNION', 1), |
|
89 | + '_SELECT' => array('SELECT', 1), |
|
90 | + 'INTO' => array('INTO', 3), |
|
91 | + 'FROM' => array('FROM', 3), |
|
92 | + 'PARTITION' => array('PARTITION', 3), |
|
93 | + |
|
94 | + 'JOIN' => array('JOIN', 1), |
|
95 | + 'FULL JOIN' => array('FULL JOIN', 1), |
|
96 | + 'INNER JOIN' => array('INNER JOIN', 1), |
|
97 | + 'LEFT JOIN' => array('LEFT JOIN', 1), |
|
98 | + 'LEFT OUTER JOIN' => array('LEFT OUTER JOIN', 1), |
|
99 | + 'RIGHT JOIN' => array('RIGHT JOIN', 1), |
|
100 | + 'RIGHT OUTER JOIN' => array('RIGHT OUTER JOIN', 1), |
|
101 | + |
|
102 | + 'WHERE' => array('WHERE', 3), |
|
103 | + 'GROUP BY' => array('GROUP BY', 3), |
|
104 | + 'HAVING' => array('HAVING', 3), |
|
105 | + 'ORDER BY' => array('ORDER BY', 3), |
|
106 | + 'LIMIT' => array('LIMIT', 3), |
|
107 | + 'PROCEDURE' => array('PROCEDURE', 3), |
|
108 | + 'UNION' => array('UNION', 1), |
|
109 | 109 | // These are available only when `UNION` is present. |
110 | 110 | // 'ORDER BY' => array('ORDER BY', 3), |
111 | 111 | // 'LIMIT' => array('LIMIT', 3), |