Skip to content

Commit fc328a2

Browse files
committed
Fix #156
1 parent d3d9364 commit fc328a2

File tree

4 files changed

+1
-83
lines changed

4 files changed

+1
-83
lines changed

src/Components/Expression.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ public function __construct($database = null, $table = null, $column = null, $al
152152
*/
153153
public static function parse(Parser $parser, TokensList $list, array $options = [])
154154
{
155-
// TODO #156 to be removed
156-
echo __METHOD__ . '@' . __LINE__ . ' parsing token list: ' . json_encode($list) . ' with options: ' . json_encode($options) . PHP_EOL;
157-
158155
$ret = new static();
159156

160157
/**
@@ -201,9 +198,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
201198
$options['field'] = $options['parseField'];
202199
}
203200

204-
// TODO #156 to be removed
205-
echo __METHOD__ . '@' . __LINE__ . ' before inside for ret: ' . json_encode($ret) . PHP_EOL;
206-
207201
for (; $list->idx < $list->count; ++$list->idx) {
208202
/**
209203
* Token parsed at this moment.
@@ -212,9 +206,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
212206
*/
213207
$token = $list->tokens[$list->idx];
214208

215-
// TODO #156 to be removed
216-
echo __METHOD__ . '@' . __LINE__ . ' token: ' . json_encode($token) . ' isExpr: ' . json_encode($isExpr) . PHP_EOL;
217-
218209
// End of statement.
219210
if ($token->type === Token::TYPE_DELIMITER) {
220211
break;
@@ -409,9 +400,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
409400
}
410401
}
411402

412-
// TODO #156 to be removed
413-
echo __METHOD__ . '@' . __LINE__ . ' after inside for ret: ' . json_encode($ret) . PHP_EOL;
414-
415403
if ($alias) {
416404
$parser->error(
417405
'An alias was expected.',
@@ -428,9 +416,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
428416

429417
--$list->idx;
430418

431-
// TODO #156 to be removed
432-
echo __METHOD__ . '@' . __LINE__ . ' ret: ' . json_encode($ret) . PHP_EOL;
433-
434419
return $ret;
435420
}
436421

src/Components/ExpressionArray.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
4242
*/
4343
$state = 0;
4444

45-
// TODO #156 to be removed
46-
echo __METHOD__ . '@' . __LINE__ . ' for start' . PHP_EOL;
47-
4845
for (; $list->idx < $list->count; ++$list->idx) {
4946
/**
5047
* Token parsed at this moment.
@@ -53,14 +50,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
5350
*/
5451
$token = $list->tokens[$list->idx];
5552

56-
// TODO #156 to be removed
57-
echo __METHOD__ . '@' . __LINE__ . ' for token: ' . json_encode($token) . PHP_EOL;
58-
// the evidences:
59-
// PhpMyAdmin\SqlParser\Components\ExpressionArray::parse@57 for token:
60-
// {"token":"*","value":"*","keyword":null,"type":2,"flags":1,"position":55}
61-
// PhpMyAdmin\SqlParser\Components\ExpressionArray::parse@57 for token:
62-
// {"token":"from","value":"FROM","keyword":"FROM","type":1,"flags":3,"position":70}
63-
6453
// End of statement.
6554
if ($token->type === Token::TYPE_DELIMITER) {
6655
break;
@@ -89,9 +78,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
8978
$expr = CaseExpression::parse($parser, $list, $options);
9079
} else {
9180
$expr = Expression::parse($parser, $list, $options);
92-
93-
// TODO #156 to be removed
94-
echo __METHOD__ . '@' . __LINE__ . ' state: ' . $state . ' expr: ' . json_encode($expr) . PHP_EOL;
9581
}
9682

9783
if ($expr === null) {
@@ -108,9 +94,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
10894
}
10995
}
11096

111-
// TODO #156 to be removed
112-
echo __METHOD__ . '@' . __LINE__ . ' for end' . PHP_EOL;
113-
11497
if ($state === 0) {
11598
$parser->error(
11699
'An expression was expected.',
@@ -120,7 +103,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
120103

121104
--$list->idx;
122105

123-
// TODO #156 Hotfix
106+
// TODO verify #156 Hotfix
124107
if (is_array($ret)) {
125108
$expr = $ret[count($ret) - 1]->expr;
126109
if (preg_match('/\s*--\s.*$/', $expr, $matches)) {
@@ -129,15 +112,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
129112
}
130113
}
131114

132-
// TODO #156 to be removed
133-
foreach ($ret as $item) {
134-
echo __METHOD__ . '@' . __LINE__ . ' ret item: ' . json_encode($item) . PHP_EOL;
135-
// eventually the evidence came up:
136-
// $ret[4] as
137-
// PhpMyAdmin\SqlParser\Components\ExpressionArray::parse@114 ret item:
138-
// {"database":null,"table":null,"column":null,"expr":"* -- count(*)","alias":null,"function":null,"subquery":null}
139-
}
140-
141115
return $ret;
142116
}
143117

@@ -149,19 +123,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
149123
*/
150124
public static function build($component, array $options = [])
151125
{
152-
// TODO #156 to be removed
153-
// var_dump($component);
154-
155126
$ret = [];
156127
foreach ($component as $frag) {
157-
// TODO #156 to be removed
158-
//var_dump($frag);
159128
$ret[] = $frag::build($frag);
160129
}
161130

162-
// TODO #156 to be removed
163-
echo __METHOD__ . ' ret[] as ' . json_encode($ret) . PHP_EOL;
164-
165131
return implode(', ', $ret);
166132
}
167133
}

src/Parser.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,6 @@ public function parse()
487487
*/
488488
$class = static::$STATEMENT_PARSERS[$token->keyword];
489489

490-
// TODO #156 to be removed
491-
echo __METHOD__ . '@' . __LINE__ . ' class=' . $class . ' keyword=' . $token->keyword . PHP_EOL;
492-
493490
/**
494491
* Processed statement.
495492
*

src/Statement.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ public function build()
124124
$clauses = $this->getClauses();
125125

126126
foreach ($clauses as $clause) {
127-
// TODO #156 to be removed
128-
echo json_encode($clause) . PHP_EOL;
129127

130128
/**
131129
* The name of the clause.
@@ -150,9 +148,6 @@ public function build()
150148
*/
151149
$class = Parser::$KEYWORD_PARSERS[$name]['class'];
152150

153-
// TODO #156 to be removed
154-
echo json_encode([$name, $class]) . PHP_EOL;
155-
156151
/**
157152
* The name of the field that is used as source for the builder.
158153
* Same field is used to store the result of parsing.
@@ -184,8 +179,6 @@ public function build()
184179
$query = trim($query) . ' ' . $class::build($this->$field);
185180
}
186181

187-
// TODO #156 To be removed
188-
echo json_encode($query) . PHP_EOL;
189182
}
190183

191184
return $query;
@@ -220,9 +213,6 @@ public function parse(Parser $parser, TokensList $list)
220213
*/
221214
$parsedOptions = empty(static::$OPTIONS);
222215

223-
// TODO #156 to be removed
224-
echo __METHOD__ . '@' . __LINE__ . ' for start' . PHP_EOL;
225-
226216
for (; $list->idx < $list->count; ++$list->idx) {
227217
/**
228218
* Token parsed at this moment.
@@ -231,13 +221,8 @@ public function parse(Parser $parser, TokensList $list)
231221
*/
232222
$token = $list->tokens[$list->idx];
233223

234-
// TODO #156 to be removed
235-
echo __METHOD__ . '@' . __LINE__ . ' token: ' . json_encode($token) . PHP_EOL;
236-
237224
// End of statement.
238225
if ($token->type === Token::TYPE_DELIMITER) {
239-
// TODO #156 to be removed
240-
echo __METHOD__ . '@' . __LINE__ . ' token is delimiter!' . PHP_EOL;
241226
break;
242227
}
243228

@@ -405,18 +390,6 @@ public function parse(Parser $parser, TokensList $list)
405390

406391
$this->before($parser, $list, $token);
407392

408-
// TODO #156 to be removed
409-
echo __METHOD__ . '@' . __LINE__ . ' class: ' . json_encode($class) . PHP_EOL;
410-
{
411-
//var_dump($list);
412-
foreach ($list->tokens as $item) {
413-
echo __METHOD__ . '@' . __LINE__ . ' list item : ' . json_encode($item) . PHP_EOL;
414-
}
415-
416-
// from above shows the last `* -- count(*)` as ["*"," ","-- count(*)"]
417-
// so it must be `class: "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray"`::parse errored!
418-
}
419-
420393
// Parsing this keyword.
421394
if ($class !== null) {
422395
// We can't parse keyword at the end of statement
@@ -438,9 +411,6 @@ public function parse(Parser $parser, TokensList $list)
438411
}
439412
}
440413

441-
// TODO #156 to be removed
442-
echo __METHOD__ . '@' . __LINE__ . ' for over' . PHP_EOL;
443-
444414
// This may be corrected by the parser.
445415
$this->last = --$list->idx; // Go back to last used token.
446416
}

0 commit comments

Comments
 (0)