优化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 回调函数 * @param callable|null $callback 回调函数
* @return static * @return static
*/ */
public function filter(callable $callback = null) public function filter(?callable $callback = null)
{ {
return new static(array_filter($this->items, $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 回调函数 * @param callable|null $callback 回调函数
* @return static * @return static
*/ */
public function sort(callable $callback = null) public function sort(?callable $callback = null)
{ {
$items = $this->items; $items = $this->items;
$callback = $callback ?: function ($a, $b) { $callback = $callback ?: function ($a, $b) {

View File

@@ -50,7 +50,7 @@ class Controller
* @access public * @access public
* @param Request $request Request 对象 * @param Request $request Request 对象
*/ */
public function __construct(Request $request = null) public function __construct(?Request $request = null)
{ {
$this->view = View::instance(Config::get('template'), Config::get('view_replace_str')); $this->view = View::instance(Config::get('template'), Config::get('view_replace_str'));
$this->request = is_null($request) ? Request::instance() : $request; $this->request = is_null($request) ? Request::instance() : $request;

View File

@@ -16,7 +16,7 @@ class HttpException extends \RuntimeException
private $statusCode; private $statusCode;
private $headers; private $headers;
public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0) public function __construct($statusCode, $message = null, ?\Exception $previous = null, array $headers = [], $code = 0)
{ {
$this->statusCode = $statusCode; $this->statusCode = $statusCode;
$this->headers = $headers; $this->headers = $headers;