Skip to content

Commit ec91b10

Browse files
committed
Add native property types in Statements
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 94f2db2 commit ec91b10

29 files changed

Lines changed: 110 additions & 222 deletions

src/Statement.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract class Statement implements Stringable
4545
* @var array<string, int|array<int, int|string>>
4646
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
4747
*/
48-
public static $statementOptions = [];
48+
public static array $statementOptions = [];
4949

5050
/**
5151
* The clauses of this statement, in order.
@@ -60,30 +60,24 @@ abstract class Statement implements Stringable
6060
* @var array<string, array<int, int|string>>
6161
* @psalm-var array<string, array{non-empty-string, (1|2|3)}>
6262
*/
63-
public static $clauses = [];
63+
public static array $clauses = [];
6464

6565
/**
6666
* The options of this query.
6767
*
6868
* @see Statement::$statementOptions
69-
*
70-
* @var OptionsArray|null
7169
*/
72-
public $options;
70+
public OptionsArray|null $options = null;
7371

7472
/**
7573
* The index of the first token used in this statement.
76-
*
77-
* @var int|null
7874
*/
79-
public $first;
75+
public int|null $first = null;
8076

8177
/**
8278
* The index of the last token used in this statement.
83-
*
84-
* @var int|null
8579
*/
86-
public $last;
80+
public int|null $last = null;
8781

8882
/**
8983
* @param Parser|null $parser the instance that requests parsing

src/Statements/AlterStatement.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,23 @@ class AlterStatement extends Statement
2222
{
2323
/**
2424
* Table affected.
25-
*
26-
* @var Expression|null
2725
*/
28-
public $table;
26+
public Expression|null $table = null;
2927

3028
/**
3129
* Column affected by this statement.
3230
*
3331
* @var AlterOperation[]|null
3432
*/
35-
public $altered = [];
33+
public array|null $altered = [];
3634

3735
/**
3836
* Options of this statement.
3937
*
4038
* @var array<string, int|array<int, int|string>>
4139
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
4240
*/
43-
public static $statementOptions = [
41+
public static array $statementOptions = [
4442
'ONLINE' => 1,
4543
'OFFLINE' => 1,
4644
'IGNORE' => 2,

src/Statements/AnalyzeStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AnalyzeStatement extends Statement
2121
* @var array<string, int|array<int, int|string>>
2222
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
2323
*/
24-
public static $statementOptions = [
24+
public static array $statementOptions = [
2525
'TABLE' => 1,
2626

2727
'NO_WRITE_TO_BINLOG' => 2,
@@ -33,5 +33,5 @@ class AnalyzeStatement extends Statement
3333
*
3434
* @var Expression[]|null
3535
*/
36-
public $tables;
36+
public array|null $tables = null;
3737
}

src/Statements/BackupStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BackupStatement extends MaintenanceStatement
1717
* @var array<string, int|array<int, int|string>>
1818
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
1919
*/
20-
public static $statementOptions = [
20+
public static array $statementOptions = [
2121
'TABLE' => 1,
2222

2323
'NO_WRITE_TO_BINLOG' => 2,

src/Statements/CallStatement.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ class CallStatement extends Statement
2222
{
2323
/**
2424
* The name of the function and its parameters.
25-
*
26-
* @var FunctionCall|null
2725
*/
28-
public $call;
26+
public FunctionCall|null $call = null;
2927

3028
/**
3129
* Build statement for CALL.

src/Statements/CheckStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CheckStatement extends MaintenanceStatement
1717
* @var array<string, int|array<int, int|string>>
1818
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
1919
*/
20-
public static $statementOptions = [
20+
public static array $statementOptions = [
2121
'TABLE' => 1,
2222

2323
'FOR UPGRADE' => 2,

src/Statements/ChecksumStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ChecksumStatement extends MaintenanceStatement
1717
* @var array<string, int|array<int, int|string>>
1818
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
1919
*/
20-
public static $statementOptions = [
20+
public static array $statementOptions = [
2121
'TABLE' => 1,
2222

2323
'QUICK' => 2,

src/Statements/CreateStatement.php

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CreateStatement extends Statement
3131
* @var array<string, int|array<int, int|string>>
3232
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
3333
*/
34-
public static $statementOptions = [
34+
public static array $statementOptions = [
3535
// CREATE TABLE
3636
'TEMPORARY' => 1,
3737

@@ -279,10 +279,8 @@ class CreateStatement extends Statement
279279
* @see CreateStatement::TABLE_OPTIONS
280280
* @see CreateStatement::FUNCTION_OPTIONS
281281
* @see CreateStatement::TRIGGER_OPTIONS
282-
*
283-
* @var OptionsArray|null
284282
*/
285-
public $entityOptions;
283+
public OptionsArray|null $entityOptions = null;
286284

287285
/**
288286
* If `CREATE TABLE`, a list of columns and keys.
@@ -292,90 +290,72 @@ class CreateStatement extends Statement
292290
*
293291
* @var CreateDefinition[]|ArrayObj|null
294292
*/
295-
public $fields;
293+
public array|ArrayObj|null $fields = null;
296294

297295
/**
298296
* If `CREATE TABLE WITH`.
299297
* If `CREATE TABLE AS WITH`.
300298
* If `CREATE VIEW AS WITH`.
301299
*
302300
* Used by `CREATE TABLE`, `CREATE VIEW`
303-
*
304-
* @var WithStatement|null
305301
*/
306-
public $with;
302+
public WithStatement|null $with = null;
307303

308304
/**
309305
* If `CREATE TABLE ... SELECT`.
310306
* If `CREATE VIEW AS ` ... SELECT`.
311307
*
312308
* Used by `CREATE TABLE`, `CREATE VIEW`
313-
*
314-
* @var SelectStatement|null
315309
*/
316-
public $select;
310+
public SelectStatement|null $select = null;
317311

318312
/**
319313
* If `CREATE TABLE ... LIKE`.
320314
*
321315
* Used by `CREATE TABLE`
322-
*
323-
* @var Expression|null
324316
*/
325-
public $like;
317+
public Expression|null $like = null;
326318

327319
/**
328320
* Expression used for partitioning.
329-
*
330-
* @var string|null
331321
*/
332-
public $partitionBy;
322+
public string|null $partitionBy = null;
333323

334324
/**
335325
* The number of partitions.
336-
*
337-
* @var int|null
338326
*/
339-
public $partitionsNum;
327+
public int|null $partitionsNum = null;
340328

341329
/**
342330
* Expression used for subpartitioning.
343-
*
344-
* @var string|null
345331
*/
346-
public $subpartitionBy;
332+
public string|null $subpartitionBy = null;
347333

348334
/**
349335
* The number of subpartitions.
350-
*
351-
* @var int|null
352336
*/
353-
public $subpartitionsNum;
337+
public int|null $subpartitionsNum = null;
354338

355339
/**
356340
* The partition of the new table.
357341
*
358342
* @var PartitionDefinition[]|null
359343
*/
360-
public $partitions;
344+
public array|null $partitions = null;
361345

362346
/**
363347
* If `CREATE TRIGGER` the name of the table.
364348
*
365349
* Used by `CREATE TRIGGER`.
366-
*
367-
* @var Expression|null
368350
*/
369-
public $table;
351+
public Expression|null $table = null;
370352

371353
/**
372354
* The return data type of this routine.
373355
*
374356
* Used by `CREATE FUNCTION`.
375-
*
376-
* @var DataType|null
377357
*/
378-
public $return;
358+
public DataType|null $return = null;
379359

380360
/**
381361
* The parameters of this routine.
@@ -384,7 +364,7 @@ class CreateStatement extends Statement
384364
*
385365
* @var ParameterDefinition[]|null
386366
*/
387-
public $parameters;
367+
public array|null $parameters = null;
388368

389369
/**
390370
* The body of this function or procedure.

src/Statements/DeleteStatement.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DeleteStatement extends Statement
5151
* @var array<string, int|array<int, int|string>>
5252
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
5353
*/
54-
public static $statementOptions = [
54+
public static array $statementOptions = [
5555
'LOW_PRIORITY' => 1,
5656
'QUICK' => 2,
5757
'IGNORE' => 3,
@@ -65,7 +65,7 @@ class DeleteStatement extends Statement
6565
* @var array<string, array<int, int|string>>
6666
* @psalm-var array<string, array{non-empty-string, (1|2|3)}>
6767
*/
68-
public static $clauses = [
68+
public static array $clauses = [
6969
'DELETE' => [
7070
'DELETE',
7171
2,
@@ -131,10 +131,8 @@ class DeleteStatement extends Statement
131131

132132
/**
133133
* Partitions used as source for this statement.
134-
*
135-
* @var ArrayObj|null
136134
*/
137-
public $partition;
135+
public ArrayObj|null $partition = null;
138136

139137
/**
140138
* Conditions used for filtering each row of the result set.
@@ -152,10 +150,8 @@ class DeleteStatement extends Statement
152150

153151
/**
154152
* Conditions used for limiting the size of the result set.
155-
*
156-
* @var Limit|null
157153
*/
158-
public $limit;
154+
public Limit|null $limit = null;
159155

160156
public function build(): string
161157
{

src/Statements/DropStatement.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DropStatement extends Statement
1818
* @var array<string, int|array<int, int|string>>
1919
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
2020
*/
21-
public static $statementOptions = [
21+
public static array $statementOptions = [
2222
'DATABASE' => 1,
2323
'EVENT' => 1,
2424
'FUNCTION' => 1,
@@ -45,7 +45,7 @@ class DropStatement extends Statement
4545
* @var array<string, array<int, int|string>>
4646
* @psalm-var array<string, array{non-empty-string, (1|2|3)}>
4747
*/
48-
public static $clauses = [
48+
public static array $clauses = [
4949
'DROP' => [
5050
'DROP',
5151
2,
@@ -71,12 +71,10 @@ class DropStatement extends Statement
7171
*
7272
* @var Expression[]|null
7373
*/
74-
public $fields;
74+
public array|null $fields = null;
7575

7676
/**
7777
* Table of the dropped index.
78-
*
79-
* @var Expression|null
8078
*/
81-
public $table;
79+
public Expression|null $table = null;
8280
}

0 commit comments

Comments
 (0)