Skip to content

Commit 5f0da17

Browse files
committed
Merge #467 - Use a strict array type
Pull-request: #467 Signed-off-by: William Desportes <[email protected]>
2 parents 595f82a + c73d0dc commit 5f0da17

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

src/Components/ArrayObj.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ final class ArrayObj implements Component
2424
*
2525
* @var string[]
2626
*/
27-
public $raw = [];
27+
public array $raw = [];
2828

2929
/**
3030
* The array that contains the processed value of each token.
3131
*
3232
* @var string[]
3333
*/
34-
public $values = [];
34+
public array $values = [];
3535

3636
/**
3737
* @param string[] $raw the unprocessed values
@@ -168,7 +168,7 @@ public static function build($component, array $options = []): string
168168
return implode(', ', $component);
169169
}
170170

171-
if (! empty($component->raw)) {
171+
if ($component->raw !== []) {
172172
return '(' . implode(', ', $component->raw) . ')';
173173
}
174174

src/Components/DataType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final class DataType implements Component
6363
*
6464
* @var int[]|string[]
6565
*/
66-
public $parameters = [];
66+
public array $parameters = [];
6767

6868
/**
6969
* The options of this data type.
@@ -162,7 +162,7 @@ public static function build($component, array $options = []): string
162162
$component->name : strtolower($component->name);
163163

164164
$parameters = '';
165-
if (! empty($component->parameters)) {
165+
if ($component->parameters !== []) {
166166
$parameters = '(' . implode(',', $component->parameters) . ')';
167167
}
168168

src/Components/Key.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
198198
$state = 3;
199199
} elseif (($token->value === ',') || ($token->value === ')')) {
200200
$state = $token->value === ',' ? 2 : 4;
201-
if (! empty($lastColumn)) {
201+
if ($lastColumn !== []) {
202202
$ret->columns[] = $lastColumn;
203203
$lastColumn = [];
204204
}

src/Statements/SelectStatement.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ class SelectStatement extends Statement
236236
*
237237
* @var Expression[]
238238
*/
239-
public $expr = [];
239+
public array $expr = [];
240240

241241
/**
242242
* Tables used as sources for this statement.
243243
*
244244
* @var Expression[]
245245
*/
246-
public $from = [];
246+
public array $from = [];
247247

248248
/**
249249
* Index hints
@@ -327,7 +327,7 @@ class SelectStatement extends Statement
327327
*
328328
* @var SelectStatement[]
329329
*/
330-
public $union = [];
330+
public array $union = [];
331331

332332
/**
333333
* The end options of this query.
@@ -349,7 +349,7 @@ public function getClauses()
349349
// This is a cheap fix for `SELECT` statements that contain `UNION`.
350350
// The `ORDER BY` and `LIMIT` clauses should be at the end of the
351351
// statement.
352-
if (! empty($this->union)) {
352+
if ($this->union !== []) {
353353
$clauses = static::$clauses;
354354
unset($clauses['ORDER BY'], $clauses['LIMIT']);
355355
$clauses['ORDER BY'] = [
@@ -376,7 +376,7 @@ public function getClauses()
376376
*/
377377
public function getAliases(string $database): array
378378
{
379-
if (empty($this->expr) || empty($this->from)) {
379+
if ($this->expr === [] || $this->from === []) {
380380
return [];
381381
}
382382

src/TokensList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TokensList implements ArrayAccess
4747
*/
4848
public function __construct(array $tokens = [], $count = -1)
4949
{
50-
if (empty($tokens)) {
50+
if ($tokens === []) {
5151
return;
5252
}
5353

src/Utils/Query.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ class Query
287287
* @return array<string, bool|string>
288288
* @psalm-return QueryFlagsType
289289
*/
290-
private static function getFlagsSelect($statement, $flags)
290+
private static function getFlagsSelect(SelectStatement $statement, $flags)
291291
{
292292
$flags['querytype'] = 'SELECT';
293293
$flags['is_select'] = true;
294294

295-
if (! empty($statement->from)) {
295+
if ($statement->from !== []) {
296296
$flags['select_from'] = true;
297297
}
298298

@@ -343,7 +343,7 @@ private static function getFlagsSelect($statement, $flags)
343343
$flags['having'] = true;
344344
}
345345

346-
if (! empty($statement->union)) {
346+
if ($statement->union !== []) {
347347
$flags['union'] = true;
348348
}
349349

0 commit comments

Comments
 (0)