Skip to content

Commit 769acbe

Browse files
committed
兼容8.1
1 parent a7e7178 commit 769acbe

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Collection.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use think\contract\Arrayable;
2121
use think\contract\Jsonable;
2222
use think\helper\Arr;
23+
use Traversable;
2324

2425
/**
2526
* 数据集管理类
@@ -579,16 +580,19 @@ public function slice(int $offset, int $length = null, bool $preserveKeys = fals
579580
}
580581

581582
// ArrayAccess
582-
public function offsetExists($offset)
583+
#[\ReturnTypeWillChange]
584+
public function offsetExists($offset) : bool
583585
{
584586
return array_key_exists($offset, $this->items);
585587
}
586588

589+
#[\ReturnTypeWillChange]
587590
public function offsetGet($offset)
588591
{
589592
return $this->items[$offset];
590593
}
591594

595+
#[\ReturnTypeWillChange]
592596
public function offsetSet($offset, $value)
593597
{
594598
if (is_null($offset)) {
@@ -598,24 +602,27 @@ public function offsetSet($offset, $value)
598602
}
599603
}
600604

605+
#[\ReturnTypeWillChange]
601606
public function offsetUnset($offset)
602607
{
603608
unset($this->items[$offset]);
604609
}
605610

606611
//Countable
607-
public function count()
612+
public function count(): int
608613
{
609614
return count($this->items);
610615
}
611616

612617
//IteratorAggregate
613-
public function getIterator()
618+
#[\ReturnTypeWillChange]
619+
public function getIterator(): Traversable
614620
{
615621
return new ArrayIterator($this->items);
616622
}
617623

618624
//JsonSerializable
625+
#[\ReturnTypeWillChange]
619626
public function jsonSerialize()
620627
{
621628
return $this->toArray();
@@ -627,7 +634,7 @@ public function jsonSerialize()
627634
* @param integer $options json参数
628635
* @return string
629636
*/
630-
public function toJson(int $options = JSON_UNESCAPED_UNICODE) : string
637+
public function toJson(int $options = JSON_UNESCAPED_UNICODE): string
631638
{
632639
return json_encode($this->toArray(), $options);
633640
}

0 commit comments

Comments
 (0)