20
20
use think \contract \Arrayable ;
21
21
use think \contract \Jsonable ;
22
22
use think \helper \Arr ;
23
+ use Traversable ;
23
24
24
25
/**
25
26
* 数据集管理类
@@ -579,16 +580,19 @@ public function slice(int $offset, int $length = null, bool $preserveKeys = fals
579
580
}
580
581
581
582
// ArrayAccess
582
- public function offsetExists ($ offset )
583
+ #[\ReturnTypeWillChange]
584
+ public function offsetExists ($ offset ) : bool
583
585
{
584
586
return array_key_exists ($ offset , $ this ->items );
585
587
}
586
588
589
+ #[\ReturnTypeWillChange]
587
590
public function offsetGet ($ offset )
588
591
{
589
592
return $ this ->items [$ offset ];
590
593
}
591
594
595
+ #[\ReturnTypeWillChange]
592
596
public function offsetSet ($ offset , $ value )
593
597
{
594
598
if (is_null ($ offset )) {
@@ -598,24 +602,27 @@ public function offsetSet($offset, $value)
598
602
}
599
603
}
600
604
605
+ #[\ReturnTypeWillChange]
601
606
public function offsetUnset ($ offset )
602
607
{
603
608
unset($ this ->items [$ offset ]);
604
609
}
605
610
606
611
//Countable
607
- public function count ()
612
+ public function count (): int
608
613
{
609
614
return count ($ this ->items );
610
615
}
611
616
612
617
//IteratorAggregate
613
- public function getIterator ()
618
+ #[\ReturnTypeWillChange]
619
+ public function getIterator (): Traversable
614
620
{
615
621
return new ArrayIterator ($ this ->items );
616
622
}
617
623
618
624
//JsonSerializable
625
+ #[\ReturnTypeWillChange]
619
626
public function jsonSerialize ()
620
627
{
621
628
return $ this ->toArray ();
@@ -627,7 +634,7 @@ public function jsonSerialize()
627
634
* @param integer $options json参数
628
635
* @return string
629
636
*/
630
- public function toJson (int $ options = JSON_UNESCAPED_UNICODE ) : string
637
+ public function toJson (int $ options = JSON_UNESCAPED_UNICODE ): string
631
638
{
632
639
return json_encode ($ this ->toArray (), $ options );
633
640
}
0 commit comments