Skip to content

Commit fb8c14c

Browse files
authored
fix: 修复PHP8.4下隐式 nullable 参数声明弃用的问题(5.x) (#2930)
1 parent 967bcae commit fb8c14c

File tree

33 files changed

+81
-81
lines changed

33 files changed

+81
-81
lines changed

src/BasicService/Jssdk/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Client extends BaseClient
5555
* @throws \Psr\SimpleCache\InvalidArgumentException
5656
* @throws \GuzzleHttp\Exception\GuzzleException
5757
*/
58-
public function buildConfig(array $jsApiList, bool $debug = false, bool $beta = false, bool $json = true, array $openTagList = [], string $url = null)
58+
public function buildConfig(array $jsApiList, bool $debug = false, bool $beta = false, bool $json = true, array $openTagList = [], ?string $url = null)
5959
{
6060
$config = array_merge(compact('debug', 'beta', 'jsApiList', 'openTagList'), $this->configSignature($url));
6161

@@ -78,7 +78,7 @@ public function buildConfig(array $jsApiList, bool $debug = false, bool $beta =
7878
* @throws \Psr\SimpleCache\InvalidArgumentException
7979
* @throws \GuzzleHttp\Exception\GuzzleException
8080
*/
81-
public function getConfigArray(array $apis, bool $debug = false, bool $beta = false, array $openTagList = [], string $url = null)
81+
public function getConfigArray(array $apis, bool $debug = false, bool $beta = false, array $openTagList = [], ?string $url = null)
8282
{
8383
return $this->buildConfig($apis, $debug, $beta, false, $openTagList, $url);
8484
}
@@ -135,7 +135,7 @@ public function getTicket(bool $refresh = false, string $type = 'jsapi'): array
135135
* @throws \GuzzleHttp\Exception\GuzzleException
136136
* @throws \Psr\SimpleCache\InvalidArgumentException
137137
*/
138-
protected function configSignature(string $url = null, string $nonce = null, $timestamp = null): array
138+
protected function configSignature(?string $url = null, ?string $nonce = null, $timestamp = null): array
139139
{
140140
$url = $url ?: $this->getUrl();
141141
$nonce = $nonce ?: Support\Str::quickRandom(10);

src/Kernel/BaseClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class BaseClient
5050
* @param \EasyWeChat\Kernel\ServiceContainer $app
5151
* @param \EasyWeChat\Kernel\Contracts\AccessTokenInterface|null $accessToken
5252
*/
53-
public function __construct(ServiceContainer $app, AccessTokenInterface $accessToken = null)
53+
public function __construct(ServiceContainer $app, ?AccessTokenInterface $accessToken = null)
5454
{
5555
$this->app = $app;
5656
$this->accessToken = $accessToken ?? $this->app['access_token'];
@@ -261,7 +261,7 @@ protected function retryMiddleware()
261261
function (
262262
$retries,
263263
RequestInterface $request,
264-
ResponseInterface $response = null
264+
?ResponseInterface $response = null
265265
) {
266266
// Limit the number of retries to 2
267267
if ($retries < $this->app->config->get('http.max_retries', 1) && $response && $body = $response->getBody()) {

src/Kernel/Encryptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Encryptor
7070
* @param string|null $token
7171
* @param string|null $aesKey
7272
*/
73-
public function __construct(string $appId, string $token = null, string $aesKey = null)
73+
public function __construct(string $appId, ?string $token = null, ?string $aesKey = null)
7474
{
7575
$this->appId = $appId;
7676
$this->token = $token;

src/Kernel/Exceptions/HttpException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class HttpException extends Exception
3838
* @param null $formattedResponse
3939
* @param int $code
4040
*/
41-
public function __construct($message, ResponseInterface $response = null, $formattedResponse = null, $code = 0)
41+
public function __construct($message, ?ResponseInterface $response = null, $formattedResponse = null, $code = 0)
4242
{
4343
parent::__construct($message, $code);
4444

src/Kernel/Messages/Transfer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Transfer extends Message
4040
*
4141
* @param string|null $account
4242
*/
43-
public function __construct(string $account = null)
43+
public function __construct(?string $account = null)
4444
{
4545
parent::__construct(compact('account'));
4646
}

src/Kernel/ServiceContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ServiceContainer extends Container
6262
* @param array $prepends
6363
* @param string|null $id
6464
*/
65-
public function __construct(array $config = [], array $prepends = [], string $id = null)
65+
public function __construct(array $config = [], array $prepends = [], ?string $id = null)
6666
{
6767
$this->userConfig = $config;
6868

src/Kernel/Support/Arr.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static function exists(array $array, $key)
134134
*
135135
* @return mixed
136136
*/
137-
public static function first(array $array, callable $callback = null, $default = null)
137+
public static function first(array $array, ?callable $callback = null, $default = null)
138138
{
139139
if (is_null($callback)) {
140140
if (empty($array)) {
@@ -164,7 +164,7 @@ public static function first(array $array, callable $callback = null, $default =
164164
*
165165
* @return mixed
166166
*/
167-
public static function last(array $array, callable $callback = null, $default = null)
167+
public static function last(array $array, ?callable $callback = null, $default = null)
168168
{
169169
if (is_null($callback)) {
170170
return empty($array) ? $default : end($array);
@@ -389,7 +389,7 @@ public static function pull(array &$array, $key, $default = null)
389389
*
390390
* @throws \InvalidArgumentException
391391
*/
392-
public static function random(array $array, int $amount = null)
392+
public static function random(array $array, ?int $amount = null)
393393
{
394394
if (is_null($amount)) {
395395
return $array[array_rand($array)];

src/Kernel/Traits/HasHttpRequests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ public function getHttpClient(): ClientInterface
104104
/**
105105
* Add a middleware.
106106
*
107-
* @param callable $middleware
108-
* @param string $name
107+
* @param callable $middleware
108+
* @param string|null $name
109109
*
110110
* @return $this
111111
*/
112-
public function pushMiddleware(callable $middleware, string $name = null)
112+
public function pushMiddleware(callable $middleware, ?string $name = null)
113113
{
114114
if (!is_null($name)) {
115115
$this->middlewares[$name] = $middleware;

src/MiniProgram/AppCode/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getUnlimit(string $scene, array $optional = [])
6363
*
6464
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
6565
*/
66-
public function getQrCode(string $path, int $width = null)
66+
public function getQrCode(string $path, ?int $width = null)
6767
{
6868
return $this->getStream('cgi-bin/wxaapp/createwxaqrcode', compact('path', 'width'));
6969
}

src/MiniProgram/SubscribeMessage/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function restoreMessage()
123123
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
124124
* @throws \GuzzleHttp\Exception\GuzzleException
125125
*/
126-
public function addTemplate(string $tid, array $kidList, string $sceneDesc = null)
126+
public function addTemplate(string $tid, array $kidList, ?string $sceneDesc = null)
127127
{
128128
$sceneDesc = $sceneDesc ?? '';
129129
$data = \compact('tid', 'kidList', 'sceneDesc');

0 commit comments

Comments
 (0)