From f94219c9474e4378d97379166098d471bb4baaa4 Mon Sep 17 00:00:00 2001 From: auooru Date: Tue, 20 Aug 2024 09:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E7=A9=BA=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=BC=BA=E7=B1=BB=E5=9E=8B=E5=A3=B0=E6=98=8E=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Collection.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index 4df2223..35dfca7 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -96,10 +96,10 @@ public function merge($items) * 按指定键整理数据 * * @param mixed $items 数据 - * @param string $indexKey 键名 + * @param string|null $indexKey 键名 * @return array */ - public function dictionary($items = null, string &$indexKey = null) + public function dictionary($items = null, ?string &$indexKey = null) { if ($items instanceof self) { $items = $items->all(); @@ -122,10 +122,10 @@ public function dictionary($items = null, string &$indexKey = null) * 比较数组,返回差集 * * @param mixed $items 数据 - * @param string $indexKey 指定比较的键名 + * @param string|null $indexKey 指定比较的键名 * @return static */ - public function diff($items, string $indexKey = null) + public function diff($items, ?string $indexKey = null) { if ($this->isEmpty() || is_scalar($this->items[0])) { return new static(array_diff($this->items, $this->convertToArray($items))); @@ -149,10 +149,10 @@ public function diff($items, string $indexKey = null) * 比较数组,返回交集 * * @param mixed $items 数据 - * @param string $indexKey 指定比较的键名 + * @param string|null $indexKey 指定比较的键名 * @return static */ - public function intersect($items, string $indexKey = null) + public function intersect($items, ?string $indexKey = null) { if ($this->isEmpty() || is_scalar($this->items[0])) { return new static(array_intersect($this->items, $this->convertToArray($items))); @@ -247,10 +247,10 @@ public function shift() * 在数组结尾插入一个元素 * * @param mixed $value 元素 - * @param string $key KEY + * @param string|null $key KEY * @return $this */ - public function push($value, string $key = null) + public function push($value, ?string $key = null) { if (is_null($key)) { $this->items[] = $value; @@ -283,10 +283,10 @@ public function chunk(int $size, bool $preserveKeys = false) * 在数组开头插入一个元素 * * @param mixed $value 元素 - * @param string $key KEY + * @param string|null $key KEY * @return $this */ - public function unshift($value, string $key = null) + public function unshift($value, ?string $key = null) { if (is_null($key)) { array_unshift($this->items, $value); @@ -336,7 +336,7 @@ public function map(callable $callback) * @param callable|null $callback 回调 * @return static */ - public function filter(callable $callback = null) + public function filter(?callable $callback = null) { if ($callback) { return new static(array_filter($this->items, $callback)); @@ -486,7 +486,7 @@ public function whereNotBetween(string $field, $value) * @param string|null $indexKey 作为索引值的列 * @return array */ - public function column(?string $columnKey, string $indexKey = null) + public function column(?string $columnKey, ?string $indexKey = null) { return array_column($this->items, $columnKey, $indexKey); } @@ -548,7 +548,7 @@ public function shuffle() * @param null $default * @return TValue */ - public function first(callable $callback = null, $default = null) + public function first(?callable $callback = null, $default = null) { return Arr::first($this->items, $callback, $default); } @@ -560,7 +560,7 @@ public function first(callable $callback = null, $default = null) * @param null $default * @return TValue */ - public function last(callable $callback = null, $default = null) + public function last(?callable $callback = null, $default = null) { return Arr::last($this->items, $callback, $default); } @@ -569,7 +569,7 @@ public function last(callable $callback = null, $default = null) * 截取数组 * * @param int $offset 起始位置 - * @param ?int $length 截取长度 + * @param int|null $length 截取长度 * @param bool $preserveKeys preserveKeys * @return static */