14
14
use System \Database \MyQuery \Where ;
15
15
16
16
/**
17
- * @template TKey of array-key
18
- * @template TValue
19
- *
20
- * @implements \ArrayAccess<TKey, TValue>
21
- * @implements \IteratorAggregate<TKey, TValue>
17
+ * @implements \ArrayAccess<array-key, mixed>
18
+ * @implements \IteratorAggregate<array-key, mixed>
22
19
*/
23
20
class Model implements \ArrayAccess, \IteratorAggregate
24
21
{
@@ -28,7 +25,7 @@ class Model implements \ArrayAccess, \IteratorAggregate
28
25
29
26
protected string $ primery_key = 'id ' ;
30
27
31
- /** @var array<array<TKey, TValue >> */
28
+ /** @var array<array<array-key, mixed >> */
32
29
protected $ columns ;
33
30
34
31
/** @var string[] Hide from shoing column */
@@ -37,7 +34,7 @@ class Model implements \ArrayAccess, \IteratorAggregate
37
34
/** @var string[] Set Column cant be modify */
38
35
protected $ resistant = [];
39
36
40
- /** @var array<array<TKey, TValue >> Orginal data from database */
37
+ /** @var array<array<array-key, mixed >> Orginat data from database */
41
38
protected $ fresh ;
42
39
43
40
protected ?Where $ where = null ;
@@ -58,7 +55,7 @@ class Model implements \ArrayAccess, \IteratorAggregate
58
55
// magic ----------------------
59
56
60
57
/**
61
- * @param array<TKey, TValue > $column
58
+ * @param array<array-key, mixed > $column
62
59
*
63
60
* @final
64
61
*/
@@ -82,9 +79,9 @@ public function __debugInfo()
82
79
}
83
80
84
81
/**
85
- * @param array<array<TKey, TValue >> $column
86
- * @param string[] $stash
87
- * @param string[] $resistant
82
+ * @param array<array<array-key, mixed >> $column
83
+ * @param string[] $stash
84
+ * @param string[] $resistant
88
85
*
89
86
* @return static
90
87
*/
@@ -111,7 +108,7 @@ public function setUp(
111
108
/**
112
109
* Getter.
113
110
*
114
- * @return TValue
111
+ * @return mixed
115
112
*/
116
113
public function __get (string $ name )
117
114
{
@@ -121,7 +118,7 @@ public function __get(string $name)
121
118
/**
122
119
* Setter.
123
120
*
124
- * @param TValue $value
121
+ * @param mixed $value
125
122
*/
126
123
public function __set (string $ name , $ value )
127
124
{
@@ -147,7 +144,7 @@ public function has(string $name): bool
147
144
/**
148
145
* Setter.
149
146
*
150
- * @param TValue $value
147
+ * @param mixed $value
151
148
*
152
149
* @return static
153
150
*/
@@ -168,7 +165,7 @@ public function setter(string $key, $value): self
168
165
*
169
166
* @param mixed|null $default
170
167
*
171
- * @return TValue
168
+ * @return mixed
172
169
*/
173
170
public function getter (string $ key , $ default = null )
174
171
{
@@ -184,7 +181,7 @@ public function getter(string $key, $default = null)
184
181
/**
185
182
* Get value of primery key from first collumn/record.
186
183
*
187
- * @return TValue
184
+ * @return mixed
188
185
*
189
186
* @throws \Exception No records founds
190
187
*/
@@ -211,7 +208,7 @@ public function indentifer(): Where
211
208
*
212
209
* @param int|string|null $key ByRef key
213
210
*
214
- * @return array<TKey, TValue >
211
+ * @return array<array-key, mixed >
215
212
*/
216
213
public function first (&$ key = null ): array
217
214
{
@@ -226,18 +223,18 @@ public function first(&$key = null): array
226
223
/**
227
224
* Fetch query return as model collection.
228
225
*
229
- * @return ModelCollection<static<TKey, TValue> >
226
+ * @return ModelCollection<array-key, static >
230
227
*/
231
228
public function get (): ModelCollection
232
229
{
230
+ /** @var ModelCollection<array-key, static> */
233
231
$ collection = new ModelCollection ([], $ this );
234
232
foreach ($ this ->columns as $ column ) {
235
233
$ where = new Where ($ this ->table_name );
236
234
if (array_key_exists ($ this ->primery_key , $ column )) {
237
235
$ where ->equal ($ this ->primery_key , $ column [$ this ->primery_key ]);
238
236
}
239
237
240
- /* @phpstan-ignore-next-line */
241
238
$ collection ->push ((new static ($ this ->pdo , []))->setUp (
242
239
$ this ->table_name ,
243
240
[$ column ],
@@ -398,7 +395,7 @@ public function isDirty(?string $column = null): bool
398
395
/**
399
396
* Get change (diff) between fresh and current column.
400
397
*
401
- * @return array<TKey, TValue >
398
+ * @return array<array-key, mixed >
402
399
*/
403
400
public function changes (): array
404
401
{
@@ -422,7 +419,7 @@ public function changes(): array
422
419
/**
423
420
* Convert model column to array.
424
421
*
425
- * @return array<array<TKey, TValue >>
422
+ * @return array<array<array-key, mixed >>
426
423
*/
427
424
public function toArray (): array
428
425
{
@@ -521,17 +518,17 @@ public function order(string $column_name, int $order_using = MyQuery::ORDER_ASC
521
518
// array access --------------
522
519
523
520
/**
524
- * @param TKey $offset
521
+ * @param array-key $offset
525
522
*/
526
523
public function offsetExists ($ offset ): bool
527
524
{
528
525
return $ this ->has ($ offset );
529
526
}
530
527
531
528
/**
532
- * @param TKey $offset
529
+ * @param array-key $offset
533
530
*
534
- * @return TValue |null
531
+ * @return mixed |null
535
532
*/
536
533
#[\ReturnTypeWillChange]
537
534
public function offsetGet ($ offset )
@@ -549,7 +546,7 @@ public function offsetUnset($offset): void
549
546
}
550
547
551
548
/**
552
- * @return \Traversable<TKey, TValue >
549
+ * @return \Traversable<array-key, mixed >
553
550
*/
554
551
public function getIterator (): \Traversable
555
552
{
@@ -577,8 +574,8 @@ public static function find($id, MyPDO $pdo): static
577
574
/**
578
575
* Find model using defined primery key.
579
576
*
580
- * @param TValue $id
581
- * @param array<TKey, TValue > $column
577
+ * @param mixed $id
578
+ * @param array<array-key, mixed > $column
582
579
*
583
580
* @throws \Exception cant inset data
584
581
*/
@@ -624,8 +621,8 @@ public static function where(string $where_condition, array $binder, MyPDO $pdo)
624
621
/**
625
622
* Find model using costume equal.
626
623
*
627
- * @param TKey $column_name
628
- * @param TValue $value
624
+ * @param array-key $column_name
625
+ * @param mixed $value
629
626
*/
630
627
public static function equal ($ column_name , $ value , MyPDO $ pdo ): static
631
628
{
@@ -640,7 +637,7 @@ public static function equal($column_name, $value, MyPDO $pdo): static
640
637
/**
641
638
* Fetch all records.
642
639
*
643
- * @return ModelCollection<static<TKey, TValue >>
640
+ * @return ModelCollection<static<array-key, mixed >>
644
641
*/
645
642
public static function all (MyPDO $ pdo ): ModelCollection
646
643
{
@@ -655,7 +652,7 @@ public static function all(MyPDO $pdo): ModelCollection
655
652
/**
656
653
* Get current column without stash.
657
654
*
658
- * @return array<array<TKey, TValue >>
655
+ * @return array<array<array-key, mixed >>
659
656
*/
660
657
protected function getColumns (): array
661
658
{
@@ -672,7 +669,7 @@ protected function getColumns(): array
672
669
*
673
670
* @param int|string|null $key ByRef key
674
671
*
675
- * @return array<TKey, TValue >
672
+ * @return array<array-key, mixed >
676
673
*/
677
674
protected function firstColumn (&$ key = null ): array
678
675
{
0 commit comments