Skip to content

Commit

Permalink
修复可空类型强类型声明问题
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Aug 20, 2024
1 parent c05074b commit f94219c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand 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<TKey, TValue>
*/
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)));
Expand All @@ -149,10 +149,10 @@ public function diff($items, string $indexKey = null)
* 比较数组,返回交集
*
* @param mixed $items 数据
* @param string $indexKey 指定比较的键名
* @param string|null $indexKey 指定比较的键名
* @return static<TKey, TValue>
*/
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)));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -336,7 +336,7 @@ public function map(callable $callback)
* @param callable|null $callback 回调
* @return static<TKey, TValue>
*/
public function filter(callable $callback = null)
public function filter(?callable $callback = null)
{
if ($callback) {
return new static(array_filter($this->items, $callback));
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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<TKey, TValue>
*/
Expand Down

0 comments on commit f94219c

Please sign in to comment.