Skip to content

Commit 7aa564c

Browse files
committed
Remove unused code
1 parent bfb8759 commit 7aa564c

19 files changed

+19
-88
lines changed

src/FakePdoStatementTrait.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,6 @@ function ($row) {
405405
},
406406
$this->result ?: []
407407
);
408-
409-
return $this->result ?: [];
410408
}
411409

412410
if ($fetch_style === \PDO::FETCH_NUM) {

src/Parser/CreateTableParser.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function lexImpl(string $sql)
117117
}
118118
continue;
119119
}
120-
$match = \preg_match('!(\d+\.?\d*|\.\d+)!A', $sql, $matches, 0, $pos);
120+
\preg_match('!(\d+\.?\d*|\.\d+)!A', $sql, $matches, 0, $pos);
121121
if ($matches) {
122122
$source_map[] = [$pos, \strlen($matches[0])];
123123
$pos += \strlen($matches[0]);
@@ -159,7 +159,7 @@ private static function walk(array $tokens, string $sql, array $source_map)
159159
$temp = [];
160160
$start = 0;
161161

162-
foreach ($tokens as $i => $t) {
162+
foreach ($tokens as $i => $_t) {
163163
$t = $tokens[$i];
164164
if ($t === ';') {
165165
if (\count($temp)) {
@@ -293,12 +293,8 @@ private static function parseCreateDefinition(array &$tokens)
293293
*/
294294
private static function parseFieldOrKey(array &$tokens, array &$fields, array &$indexes)
295295
{
296-
$has_constraint = false;
297-
$constraint = null;
298296

299297
if ($tokens[0] === 'CONSTRAINT') {
300-
$has_constraint = true;
301-
302298
if ($tokens[1] === 'PRIMARY KEY'
303299
|| $tokens[1] === 'UNIQUE'
304300
|| $tokens[1] === 'UNIQUE KEY'
@@ -308,7 +304,7 @@ private static function parseFieldOrKey(array &$tokens, array &$fields, array &$
308304
\array_shift($tokens);
309305
} else {
310306
\array_shift($tokens);
311-
$constraint = \array_shift($tokens);
307+
\array_shift($tokens);
312308
}
313309
}
314310

src/Parser/ExpressionParser.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ function ($token) {
291291
public function build()
292292
{
293293
$token = $this->nextToken();
294-
$break_while = false;
295294
while ($token !== null) {
296295
switch ($token->type) {
297296
case TokenType::PAREN:
@@ -303,7 +302,6 @@ public function build()
303302
}
304303

305304
$this->pointer = $close;
306-
$expr = new StubExpression();
307305

308306
if ($arg_tokens[0]->value === 'SELECT') {
309307
$subquery_sql = \implode(

src/Parser/FromParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private function getSubquery()
185185
throw new ParserException("Empty parentheses found");
186186
}
187187
$this->pointer = $close;
188-
$expr = new StubExpression();
188+
189189
$subquery_sql = \implode(
190190
' ',
191191
\array_map(

src/Parser/InsertParser.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function parse()
7777
$query = new InsertQuery($token->value, $this->sql, $ignore_dupes);
7878
$count = \count($this->tokens);
7979
$needs_comma = false;
80-
$end_of_set = false;
8180

8281
while ($this->pointer < $count) {
8382
$token = $this->tokens[$this->pointer];
@@ -221,7 +220,6 @@ protected function parseValues(array $tokens)
221220
$count = \count($tokens);
222221
$expressions = [];
223222
$needs_comma = false;
224-
$end_of_set = false;
225223
while ($pointer < $count) {
226224
$token = $tokens[$pointer];
227225
switch ($token->type) {
@@ -238,7 +236,7 @@ protected function parseValues(array $tokens)
238236
);
239237
}
240238
$expression_parser = new ExpressionParser($tokens, $pointer - 1);
241-
$start = $pointer;
239+
242240
list($pointer, $expression) = $expression_parser->buildWithPointer();
243241
$expressions[] = $expression;
244242
$needs_comma = true;

src/Parser/SQLParser.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ public static function findMatchingParen(int $pointer, array $tokens)
400400
{
401401
$paren_count = 0;
402402
$remaining_tokens = \array_slice($tokens, $pointer);
403-
$token_count = \count($remaining_tokens);
404403
foreach ($remaining_tokens as $i => $token) {
405404
if ($token->type === TokenType::PAREN) {
406405
$paren_count++;
@@ -425,7 +424,6 @@ public static function findMatchingEnd(int $pointer, array $tokens)
425424
{
426425
$paren_count = 0;
427426
$remaining_tokens = \array_slice($tokens, $pointer);
428-
$token_count = \count($remaining_tokens);
429427
foreach ($remaining_tokens as $i => $token) {
430428
if ($token->type === TokenType::OPERATOR
431429
&& $token->value === 'CASE'

src/Parser/SelectParser.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public function parse() : SelectQuery
7171

7272
if (\array_key_exists($this->pointer, $this->tokens)) {
7373
$next = $this->tokens[$this->pointer] ?? null;
74-
$val = $next ? $next->value : 'null';
7574
while ($next !== null
7675
&& ($next->value === 'UNION' || $next->value === 'INTERSECT' || $next->value === 'EXCEPT')
7776
) {
@@ -180,7 +179,7 @@ private function parseMainSelect() : SelectQuery
180179
$this->pointer++;
181180
$next = $this->tokens[$this->pointer] ?? null;
182181
$expressions = [];
183-
$sort_directions = [];
182+
184183
if ($next === null || $next->value !== 'BY') {
185184
throw new ParserException("Expected BY after GROUP");
186185
}
@@ -224,7 +223,7 @@ private function parseMainSelect() : SelectQuery
224223
case 'EXCEPT':
225224
case 'INTERSECT':
226225
return $query;
227-
break;
226+
228227
default:
229228
throw new ParserException("Unexpected {$token->value}");
230229
}

src/Parser/SetParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function parse(bool $skip_set = false)
5858
throw new ParserException("Expected , between expressions in SET clause");
5959
}
6060
$expression_parser = new ExpressionParser($this->tokens, $this->pointer - 1);
61-
$start = $this->pointer;
61+
6262
list($this->pointer, $expression) = $expression_parser->buildWithPointer();
6363

6464
if (!$expression instanceof BinaryOperatorExpression || $expression->operator !== '=') {

src/Processor/Expression/BinaryOperatorEvaluator.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ public static function evaluate(
246246
throw new ProcessorException("Operator recognized but not implemented");
247247

248248
case 'LIKE':
249-
$l_value = Evaluator::evaluate($conn, $scope, $left, $row, $result);
250249
$r_value = Evaluator::evaluate($conn, $scope, $right, $row, $result);
251250

252251
$left_string = (string) Evaluator::evaluate($conn, $scope, $left, $row, $result);
@@ -356,8 +355,6 @@ public static function getColumnSchema(
356355
if ($right instanceof IntervalOperatorExpression
357356
&& ($expr->operator === '+' || $expr->operator === '-')
358357
) {
359-
$functionName = $expr->operator === '+' ? 'DATE_ADD' : 'DATE_SUB';
360-
361358
return new Column\DateTime();
362359
}
363360

@@ -486,7 +483,6 @@ private static function evaluateRowComparison(
486483
throw new ProcessorException("Mismatched column count in row comparison expression");
487484
}
488485
$last_index = \array_key_last($left_elems);
489-
$match = true;
490486
foreach ($left_elems as $index => $le) {
491487
$re = $right_elems[$index];
492488
if ($le == $re && $index !== $last_index) {

src/Processor/Expression/Evaluator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ public static function combineColumnTypes(array $types) : Column
306306
$has_floating_point = false;
307307
$has_integer = false;
308308
$has_string = false;
309-
$has_date = false;
310309

311310
$non_null_types = [];
312311

0 commit comments

Comments
 (0)