优化PHP8.4兼容性

This commit is contained in:
Karson
2025-06-17 11:27:15 +08:00
parent bf57bdb9e1
commit 0216ba5027
3 changed files with 4 additions and 4 deletions

View File

@@ -263,7 +263,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @param callable|null $callback 回调函数
* @return static
*/
public function filter(callable $callback = null)
public function filter(?callable $callback = null)
{
return new static(array_filter($this->items, $callback ?: null));
}
@@ -317,7 +317,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @param callable|null $callback 回调函数
* @return static
*/
public function sort(callable $callback = null)
public function sort(?callable $callback = null)
{
$items = $this->items;
$callback = $callback ?: function ($a, $b) {