Skip to content

Commit 530c180

Browse files
committed
Fix CS
1 parent 1c9a204 commit 530c180

File tree

9 files changed

+61
-22
lines changed

9 files changed

+61
-22
lines changed

src/DataIntegrity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public static function coerceValueToColumn(
196196
return (float) $value;
197197

198198
case 'null':
199-
if ($value === nulL) {
199+
if ($value === null) {
200200
return null;
201201
}
202202

src/Parser/FromParser.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,14 @@ private function buildJoin(string $left_table, Token $token)
326326
if ($arg->type !== TokenType::IDENTIFIER) {
327327
throw new ParserException("Expected identifier in USING clause");
328328
}
329-
$filter = self::addJoinFilterExpression($filter, $left_table, $table['name'], $arg->value, $arg->start);
329+
330+
$filter = self::addJoinFilterExpression(
331+
$filter,
332+
$left_table,
333+
$table['name'],
334+
$arg->value,
335+
$arg->start
336+
);
330337
} else {
331338
if ($arg->value !== ',') {
332339
throw new ParserException("Expected , after argument in USING clause");

src/Processor/Expression/BinaryOperatorEvaluator.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ public static function evaluate(
126126
&& \preg_match('/^[0-9]{2,4}-[0-1][0-9]-[0-3][0-9]$/', $r_value)
127127
) {
128128
$r_value .= ' 00:00:00';
129-
} elseif (\preg_match('/^[0-9]{2,4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/', $r_value)
130-
&& \preg_match('/^[0-9]{2,4}-[0-1][0-9]-[0-3][0-9]$/', $l_value)
129+
} elseif (\preg_match(
130+
'/^[0-9]{2,4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/',
131+
$r_value
132+
) && \preg_match('/^[0-9]{2,4}-[0-1][0-9]-[0-3][0-9]$/', $l_value)
131133
) {
132134
$l_value .= ' 00:00:00';
133135
}
@@ -142,7 +144,8 @@ public static function evaluate(
142144
switch ($expr->operator) {
143145
case '=':
144146
if ($as_string) {
145-
return \strtolower((string) $l_value) === \strtolower((string) $r_value) ? 1 : 0 ^ $expr->negatedInt;
147+
return (\strtolower((string) $l_value) === \strtolower((string) $r_value) ? 1 : 0)
148+
^ $expr->negatedInt;
146149
}
147150

148151
if (empty($l_value) && empty($r_value)) {
@@ -154,7 +157,8 @@ public static function evaluate(
154157
case '<>':
155158
case '!=':
156159
if ($as_string) {
157-
return \strtolower((string) $l_value) !== \strtolower((string) $r_value) ? 1 : 0 ^ $expr->negatedInt;
160+
return (\strtolower((string) $l_value) !== \strtolower((string) $r_value) ? 1 : 0)
161+
^ $expr->negatedInt;
158162
}
159163

160164
if (empty($l_value) && empty($r_value)) {
@@ -192,6 +196,8 @@ public static function evaluate(
192196
return (float) $l_value <= (float) $r_value ? 1 : 0 ^ $expr->negatedInt;
193197
}
194198

199+
// PHPCS thinks there's a fallthrough here, but there provably is not
200+
195201
case '*':
196202
case '%':
197203
case 'MOD':

src/Processor/Expression/Evaluator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public static function combineColumnTypes(array $types) : Column
330330
$column = new Column\Varchar(255);
331331
} elseif ($has_floating_point) {
332332
$column = new Column\FloatColumn(10, 2);
333-
} else if ($has_integer) {
333+
} elseif ($has_integer) {
334334
$column = new Column\IntColumn(false, 10);
335335
} else {
336336
$column = new Column\Varchar(255);

src/Processor/Expression/ParameterEvaluator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ public static function evaluate(Scope $scope, ParameterExpression $expr)
1919
throw new ProcessorException('Parameter offset ' . $expr->parameterName . ' out of range');
2020
}
2121
}
22-
23-

src/Processor/JoinProcessor.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ public static function process(
4242
$left_row = $row;
4343
$candidate_row = \array_merge($row, $r);
4444
if (!$filter
45-
|| ExpressionEvaluator::evaluate($conn, $scope, $filter, $candidate_row, new QueryResult([], $joined_columns))
45+
|| ExpressionEvaluator::evaluate(
46+
$conn,
47+
$scope,
48+
$filter,
49+
$candidate_row,
50+
new QueryResult([], $joined_columns)
51+
)
4652
) {
4753
$rows[] = $candidate_row;
4854
}
@@ -146,7 +152,13 @@ public static function process(
146152
foreach ($right_result->rows as $r) {
147153
$left_row = $row;
148154
$candidate_row = \array_merge($left_row, $r);
149-
if (ExpressionEvaluator::evaluate($conn, $scope, $filter, $candidate_row, new QueryResult([], $joined_columns))) {
155+
if (ExpressionEvaluator::evaluate(
156+
$conn,
157+
$scope,
158+
$filter,
159+
$candidate_row,
160+
new QueryResult([], $joined_columns)
161+
)) {
150162
$rows[] = $candidate_row;
151163
}
152164
}

src/Processor/Scope.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
class Scope
55
{
6-
/**
7-
* @var array<string, mixed>
8-
*/
9-
public $variables = [];
6+
/**
7+
* @var array<string, mixed>
8+
*/
9+
public $variables = [];
1010

1111
/**
1212
* @var array<string, mixed>

src/Processor/SelectProcessor.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,20 @@ private static function getSelectSchema(
498498
}
499499
} else {
500500
if (!isset($existing_columns[$expr->name])) {
501-
$columns[$expr->name] = Expression\Evaluator::getColumnSchema($expr, $scope, $from_columns, $use_cache);
501+
$columns[$expr->name] = Expression\Evaluator::getColumnSchema(
502+
$expr,
503+
$scope,
504+
$from_columns,
505+
$use_cache
506+
);
502507
} elseif ($existing_columns[$expr->name] instanceof Column\NullColumn) {
503-
$columns[$expr->name] = clone Expression\Evaluator::getColumnSchema($expr, $scope, $from_columns, $use_cache);
508+
$columns[$expr->name] = clone Expression\Evaluator::getColumnSchema(
509+
$expr,
510+
$scope,
511+
$from_columns,
512+
$use_cache
513+
);
514+
504515
$columns[$expr->name]->isNullable = true;
505516
}
506517
}

tests/EndToEndTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ public function testAssignUndefinedIntToVariable()
248248
$query = $pdo->prepare(
249249
'SELECT @a := `id` as `id`, @b := @a AS `id_copy`
250250
FROM `video_game_characters`
251-
LIMIT 3');
251+
LIMIT 3'
252+
);
252253

253254
$query->execute();
254255

@@ -563,7 +564,8 @@ public function testSelectHavingCount()
563564
'SELECT `console`
564565
FROM `video_game_characters`
565566
GROUP BY `console`
566-
HAVING COUNT(*) > 2');
567+
HAVING COUNT(*) > 2'
568+
);
567569

568570
$query->execute();
569571

@@ -584,7 +586,8 @@ public function testSelectHavingOnAliasField()
584586
'SELECT `console`, COUNT(*) as `c`
585587
FROM `video_game_characters`
586588
GROUP BY `console`
587-
HAVING `c` > 2');
589+
HAVING `c` > 2'
590+
);
588591

589592
$query->execute();
590593

@@ -648,7 +651,8 @@ public function testOrderBySecondDimensionAliased()
648651
'SELECT `id`, `console` AS `console_name`
649652
FROM `video_game_characters`
650653
ORDER BY `console`, `powerups`, `name`
651-
LIMIT 4');
654+
LIMIT 4'
655+
);
652656

653657
$query->execute();
654658

@@ -671,7 +675,8 @@ public function testOrderByAliasedSecondDimension()
671675
'SELECT `id`, `console` AS `console_name`
672676
FROM `video_game_characters`
673677
ORDER BY `console_name`, `powerups`, `name`
674-
LIMIT 4');
678+
LIMIT 4'
679+
);
675680

676681
$query->execute();
677682

0 commit comments

Comments
 (0)