1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhpMyAdmin; |
6
|
|
|
|
7
|
|
|
use PhpMyAdmin\SqlParser\Parser; |
8
|
|
|
use PhpMyAdmin\SqlParser\Statement; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @psalm-immutable |
12
|
|
|
*/ |
13
|
|
|
class StatementInfo |
14
|
|
|
{ |
15
|
|
|
/** @var bool */ |
16
|
|
|
public $distinct; |
17
|
|
|
/** @var bool */ |
18
|
|
|
public $dropDatabase; |
19
|
|
|
/** @var bool */ |
20
|
|
|
public $group; |
21
|
|
|
/** @var bool */ |
22
|
|
|
public $having; |
23
|
|
|
/** @var bool */ |
24
|
|
|
public $isAffected; |
25
|
|
|
/** @var bool */ |
26
|
|
|
public $isAnalyse; |
27
|
|
|
/** @var bool */ |
28
|
|
|
public $isCount; |
29
|
|
|
/** @var bool */ |
30
|
|
|
public $isDelete; |
31
|
|
|
/** @var bool */ |
32
|
|
|
public $isExplain; |
33
|
|
|
/** @var bool */ |
34
|
|
|
public $isExport; |
35
|
|
|
/** @var bool */ |
36
|
|
|
public $isFunction; |
37
|
|
|
/** @var bool */ |
38
|
|
|
public $isGroup; |
39
|
|
|
/** @var bool */ |
40
|
|
|
public $isInsert; |
41
|
|
|
/** @var bool */ |
42
|
|
|
public $isMaint; |
43
|
|
|
/** @var bool */ |
44
|
|
|
public $isProcedure; |
45
|
|
|
/** @var bool */ |
46
|
|
|
public $isReplace; |
47
|
|
|
/** @var bool */ |
48
|
|
|
public $isSelect; |
49
|
|
|
/** @var bool */ |
50
|
|
|
public $isShow; |
51
|
|
|
/** @var bool */ |
52
|
|
|
public $isSubquery; |
53
|
|
|
/** @var bool */ |
54
|
|
|
public $join; |
55
|
|
|
/** @var bool */ |
56
|
|
|
public $limit; |
57
|
|
|
/** @var bool */ |
58
|
|
|
public $offset; |
59
|
|
|
/** @var bool */ |
60
|
|
|
public $order; |
61
|
|
|
/** @var string|false */ |
62
|
|
|
public $queryType; |
63
|
|
|
/** @var bool */ |
64
|
|
|
public $reload; |
65
|
|
|
/** @var bool */ |
66
|
|
|
public $selectFrom; |
67
|
|
|
/** @var bool */ |
68
|
|
|
public $union; |
69
|
|
|
/** @var Parser|null */ |
70
|
|
|
public $parser; |
71
|
|
|
/** @var Statement|null */ |
72
|
|
|
public $statement; |
73
|
|
|
/** |
74
|
|
|
* @var array<int, array<int, string|null>> |
75
|
|
|
* @psalm-var list<array{string|null, string|null}> |
76
|
|
|
*/ |
77
|
|
|
public $selectTables; |
78
|
|
|
/** |
79
|
|
|
* @var array<int, string|null> |
80
|
|
|
* @psalm-var list<string|null> |
81
|
|
|
*/ |
82
|
|
|
public $selectExpression; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string|false $queryType |
86
|
|
|
* @param array<int, array<int, string|null>> $selectTables |
87
|
|
|
* @param array<int, string|null> $selectExpression |
88
|
|
|
* @psalm-param list<array{string|null, string|null}> $selectTables |
89
|
|
|
* @psalm-param list<string|null> $selectExpression |
90
|
|
|
*/ |
91
|
|
|
private function __construct( |
92
|
|
|
bool $distinct, |
93
|
|
|
bool $dropDatabase, |
94
|
|
|
bool $group, |
95
|
|
|
bool $having, |
96
|
|
|
bool $isAffected, |
97
|
|
|
bool $isAnalyse, |
98
|
|
|
bool $isCount, |
99
|
|
|
bool $isDelete, |
100
|
|
|
bool $isExplain, |
101
|
|
|
bool $isExport, |
102
|
|
|
bool $isFunction, |
103
|
|
|
bool $isGroup, |
104
|
|
|
bool $isInsert, |
105
|
|
|
bool $isMaint, |
106
|
|
|
bool $isProcedure, |
107
|
|
|
bool $isReplace, |
108
|
|
|
bool $isSelect, |
109
|
|
|
bool $isShow, |
110
|
|
|
bool $isSubquery, |
111
|
|
|
bool $join, |
112
|
|
|
bool $limit, |
113
|
|
|
bool $offset, |
114
|
|
|
bool $order, |
115
|
|
|
$queryType, |
116
|
|
|
bool $reload, |
117
|
|
|
bool $selectFrom, |
118
|
|
|
bool $union, |
119
|
|
|
?SqlParser\Parser $parser, |
120
|
|
|
?SqlParser\Statement $statement, |
121
|
|
|
array $selectTables, |
122
|
|
|
array $selectExpression |
123
|
|
|
) { |
124
|
|
|
$this->distinct = $distinct; |
125
|
|
|
$this->dropDatabase = $dropDatabase; |
126
|
|
|
$this->group = $group; |
127
|
|
|
$this->having = $having; |
128
|
|
|
$this->isAffected = $isAffected; |
129
|
|
|
$this->isAnalyse = $isAnalyse; |
130
|
|
|
$this->isCount = $isCount; |
131
|
|
|
$this->isDelete = $isDelete; |
132
|
|
|
$this->isExplain = $isExplain; |
133
|
|
|
$this->isExport = $isExport; |
134
|
|
|
$this->isFunction = $isFunction; |
135
|
|
|
$this->isGroup = $isGroup; |
136
|
|
|
$this->isInsert = $isInsert; |
137
|
|
|
$this->isMaint = $isMaint; |
138
|
|
|
$this->isProcedure = $isProcedure; |
139
|
|
|
$this->isReplace = $isReplace; |
140
|
|
|
$this->isSelect = $isSelect; |
141
|
|
|
$this->isShow = $isShow; |
142
|
|
|
$this->isSubquery = $isSubquery; |
143
|
|
|
$this->join = $join; |
144
|
|
|
$this->limit = $limit; |
145
|
|
|
$this->offset = $offset; |
146
|
|
|
$this->order = $order; |
147
|
|
|
$this->queryType = $queryType; |
148
|
|
|
$this->reload = $reload; |
149
|
|
|
$this->selectFrom = $selectFrom; |
150
|
|
|
$this->union = $union; |
151
|
|
|
$this->parser = $parser; |
152
|
|
|
$this->statement = $statement; |
153
|
|
|
$this->selectTables = $selectTables; |
154
|
|
|
$this->selectExpression = $selectExpression; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param array<string, array<int, array<int, string|null>|string|null>|bool|string|Parser|Statement> $info |
159
|
|
|
* @psalm-param array{ |
160
|
|
|
* distinct: bool, |
161
|
|
|
* drop_database: bool, |
162
|
|
|
* group: bool, |
163
|
|
|
* having: bool, |
164
|
|
|
* is_affected: bool, |
165
|
|
|
* is_analyse: bool, |
166
|
|
|
* is_count: bool, |
167
|
|
|
* is_delete: bool, |
168
|
|
|
* is_explain: bool, |
169
|
|
|
* is_export: bool, |
170
|
|
|
* is_func: bool, |
171
|
|
|
* is_group: bool, |
172
|
|
|
* is_insert: bool, |
173
|
|
|
* is_maint: bool, |
174
|
|
|
* is_procedure: bool, |
175
|
|
|
* is_replace: bool, |
176
|
|
|
* is_select: bool, |
177
|
|
|
* is_show: bool, |
178
|
|
|
* is_subquery: bool, |
179
|
|
|
* join: bool, |
180
|
|
|
* limit: bool, |
181
|
|
|
* offset: bool, |
182
|
|
|
* order: bool, |
183
|
|
|
* querytype: ( |
184
|
|
|
* 'ALTER'|'ANALYZE'|'CALL'|'CHECK'|'CHECKSUM'|'CREATE'|'DELETE'|'DROP'| |
185
|
|
|
* 'EXPLAIN'|'INSERT'|'LOAD'|'OPTIMIZE'|'REPAIR'|'REPLACE'|'SELECT'|'SET'|'SHOW'|'UPDATE'|false |
186
|
|
|
* ), |
187
|
|
|
* reload: bool, |
188
|
|
|
* select_from: bool, |
189
|
|
|
* union: bool, |
190
|
|
|
* parser?: Parser, |
191
|
|
|
* statement?: Statement, |
192
|
|
|
* select_tables?: list<array{string|null, string|null}>, |
193
|
|
|
* select_expr?: list<string|null> |
194
|
|
|
* } $info |
195
|
|
|
*/ |
196
|
|
|
public static function fromArray(array $info): self |
197
|
|
|
{ |
198
|
|
|
return new self( |
199
|
|
|
$info['distinct'], |
200
|
|
|
$info['drop_database'], |
201
|
|
|
$info['group'], |
202
|
|
|
$info['having'], |
203
|
|
|
$info['is_affected'], |
204
|
|
|
$info['is_analyse'], |
205
|
|
|
$info['is_count'], |
206
|
|
|
$info['is_delete'], |
207
|
|
|
$info['is_explain'], |
208
|
|
|
$info['is_export'], |
209
|
|
|
$info['is_func'], |
210
|
|
|
$info['is_group'], |
211
|
|
|
$info['is_insert'], |
212
|
|
|
$info['is_maint'], |
213
|
|
|
$info['is_procedure'], |
214
|
|
|
$info['is_replace'], |
215
|
|
|
$info['is_select'], |
216
|
|
|
$info['is_show'], |
217
|
|
|
$info['is_subquery'], |
218
|
|
|
$info['join'], |
219
|
|
|
$info['limit'], |
220
|
|
|
$info['offset'], |
221
|
|
|
$info['order'], |
222
|
|
|
$info['querytype'], |
223
|
|
|
$info['reload'], |
224
|
|
|
$info['select_from'], |
225
|
|
|
$info['union'], |
226
|
|
|
$info['parser'] ?? null, |
227
|
|
|
$info['statement'] ?? null, |
228
|
|
|
$info['select_tables'] ?? [], |
229
|
|
|
$info['select_expr'] ?? [] |
230
|
|
|
); |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|