@@ -19,10 +19,12 @@ class ORM
19
19
20
20
private static int | string | null $ currentInstance = null ;
21
21
22
+ /** @var array<\PHPFUI\ORM\PDOInstance> */
22
23
private static array $ instances = [];
23
24
24
25
private static ?\Psr \Log \AbstractLogger $ logger = null ;
25
26
27
+ /** @var ?callable */
26
28
private static $ translationCallback = null ;
27
29
28
30
/**
@@ -60,6 +62,9 @@ public static function commit() : bool
60
62
return self ::getInstance ()->commit ();
61
63
}
62
64
65
+ /**
66
+ * @return array<\PHPFUI\ORM\Schema\Field>
67
+ */
63
68
public static function describeTable (string $ table ) : array
64
69
{
65
70
return self ::getInstance ()->describeTable ($ table );
@@ -68,6 +73,8 @@ public static function describeTable(string $table) : array
68
73
/**
69
74
* Executes the SQL string using the matching $input array
70
75
*
76
+ * @param array<mixed> $input
77
+ *
71
78
* @return bool status of command run
72
79
*/
73
80
public static function execute (string $ sql , array $ input = []) : bool
@@ -77,13 +84,17 @@ public static function execute(string $sql, array $input = []) : bool
77
84
78
85
/**
79
86
* Executes the query and catches any errors
87
+ *
88
+ * @param array<mixed> $input
80
89
*/
81
90
public static function executeStatement (\PDOStatement $ statement , array $ input = []) : ?\PDOStatement
82
91
{
83
92
return self ::getInstance ()->executeStatement ($ statement , $ input );
84
93
}
85
94
86
95
/**
96
+ * @param array<mixed> $input
97
+ *
87
98
* @return \PHPFUI\ORM\ArrayCursor tracking the sql and input passed
88
99
*/
89
100
public static function getArrayCursor (string $ sql = 'select 0 limit 0 ' , array $ input = []) : \PHPFUI \ORM \ArrayCursor
@@ -115,13 +126,18 @@ public static function getConnection() : int | string | null
115
126
}
116
127
117
128
/**
129
+ * @param array<mixed> $input
130
+ *
118
131
* @return \PHPFUI\ORM\DataObjectCursor tracking the sql and input passed
119
132
*/
120
133
public static function getDataObjectCursor (string $ sql = 'select 0 limit 0 ' , array $ input = []) : \PHPFUI \ORM \DataObjectCursor
121
134
{
122
135
return self ::getInstance ()->getDataObjectCursor ($ sql , $ input );
123
136
}
124
137
138
+ /**
139
+ * @return array<\PHPFUI\ORM\Schema\Index>
140
+ */
125
141
public static function getIndexes (string $ table ) : array
126
142
{
127
143
return self ::getInstance ()->getIndexes ($ table );
@@ -154,15 +170,15 @@ public static function getLastErrorCode() : int
154
170
}
155
171
156
172
/**
157
- * @return array of all errors since the last transaction or last time cleared
173
+ * @return array<array<string,string>> of all errors since the last transaction or last time cleared
158
174
*/
159
175
public static function getLastErrors () : array
160
176
{
161
177
return self ::getInstance ()->getLastErrors ();
162
178
}
163
179
164
180
/**
165
- * @return array of parameters from the last operation
181
+ * @return array<mixed> of parameters from the last operation
166
182
*/
167
183
public static function getLastParameters () : array
168
184
{
@@ -183,7 +199,9 @@ public static function getMigrationNamespacePath() : string
183
199
}
184
200
185
201
/**
186
- * @return \PHPFUI\ORM\RecordCursor tracking the sql and input passed
202
+ * @param array<mixed> $input
203
+ *
204
+ * @return \PHPFUI\ORM\RecordCursor tracking the sql and input passed
187
205
*/
188
206
public static function getRecordCursor (\PHPFUI \ORM \Record $ crud , string $ sql = 'select 0 limit 0 ' , array $ input = []) : \PHPFUI \ORM \RecordCursor
189
207
{
@@ -196,6 +214,8 @@ public static function getRecordNamespacePath() : string
196
214
}
197
215
198
216
/**
217
+ * @param array<mixed> $input
218
+ *
199
219
* @return array<string, string> a single row of the first matching record or an empty array if an error
200
220
*/
201
221
public static function getRow (string $ sql , array $ input = []) : array
@@ -207,6 +227,10 @@ public static function getRow(string $sql, array $input = []) : array
207
227
* Similar to getArrayCursor except returns a fully populated array
208
228
*
209
229
* It is recommended to use getArrayCursor if you don't need array functionality
230
+ *
231
+ * @param array<mixed> $input
232
+ *
233
+ * @return array<array<string, string>>
210
234
*/
211
235
public static function getRows (string $ sql , array $ input = [], int $ fetchType = \PDO ::FETCH_ASSOC ) : array
212
236
{
@@ -218,12 +242,17 @@ public static function getTableNamespacePath() : string
218
242
return self ::filePath (self ::$ namespaceRoot . '/ ' . self ::$ tableNamespace );
219
243
}
220
244
245
+ /**
246
+ * @return array<string>
247
+ */
221
248
public static function getTables () : array
222
249
{
223
250
return self ::getInstance ()->getTables ();
224
251
}
225
252
226
253
/**
254
+ * @param array<mixed> $input
255
+ *
227
256
* @return string value returned from the first field in the first row returned by the querry, or blank if error
228
257
*/
229
258
public static function getValue (string $ sql , array $ input = []) : string
@@ -232,6 +261,8 @@ public static function getValue(string $sql, array $input = []) : string
232
261
}
233
262
234
263
/**
264
+ * @param array<mixed> $input
265
+ *
235
266
* @return array<mixed> of the first value in each row from the query
236
267
*/
237
268
public static function getValueArray (string $ sql , array $ input = []) : array
@@ -249,6 +280,8 @@ public static function lastInsertId(string $name = '') : string
249
280
250
281
/**
251
282
* Logs array of errors via error_log
283
+ *
284
+ * @param array<mixed> $context
252
285
*/
253
286
public static function log (string $ type , string $ message , array $ context = []) : void
254
287
{
@@ -287,6 +320,9 @@ public static function setLogger(\Psr\Log\AbstractLogger $logger) : void
287
320
self ::$ logger = $ logger ;
288
321
}
289
322
323
+ /**
324
+ * @param callable $callback
325
+ */
290
326
public static function setTranslationCallback ($ callback ) : void
291
327
{
292
328
self ::$ translationCallback = $ callback ;
0 commit comments