From 72848e8c1983299de256296dd4e7dcff67055150 Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 9 May 2024 22:44:44 +0800 Subject: [PATCH] feat: dify ai --- src/Kernel/Contracts/Aes.php | 4 ++-- src/Kernel/Encryptor.php | 4 ++-- src/Kernel/Exceptions/HttpException.php | 2 +- src/Kernel/Form/File.php | 18 ++++++++--------- .../HttpClient/AccessTokenAwareClient.php | 2 +- src/Kernel/HttpClient/RequestWithPresets.php | 4 ++-- src/Kernel/HttpClient/Response.php | 20 +++++++++---------- src/Kernel/HttpClient/RetryableClient.php | 2 +- src/Kernel/HttpClient/ScopingHttpClient.php | 2 +- src/Kernel/Support/AesCbc.php | 4 ++-- src/Kernel/Support/AesEcb.php | 4 ++-- src/Kernel/Support/AesGcm.php | 4 ++-- src/Kernel/Traits/RespondXmlMessage.php | 4 ++-- src/OfficialAccount/AccessToken.php | 10 +++++----- src/OfficialAccount/Server.php | 6 +++--- src/OpenPlatform/ComponentAccessToken.php | 4 ++-- src/OpenPlatform/Server.php | 6 +++--- src/OpenPlatform/VerifyTicket.php | 2 +- src/OpenWork/Application.php | 12 +++++------ src/OpenWork/AuthorizerAccessToken.php | 4 ++-- src/OpenWork/JsApiTicket.php | 4 ++-- src/OpenWork/ProviderAccessToken.php | 4 ++-- src/OpenWork/Server.php | 6 +++--- src/OpenWork/SuiteAccessToken.php | 4 ++-- src/OpenWork/SuiteTicket.php | 2 +- src/Pay/Client.php | 4 ++-- src/Pay/Server.php | 4 ++-- src/Work/AccessToken.php | 4 ++-- src/Work/JsApiTicket.php | 4 ++-- src/Work/Server.php | 6 +++--- 30 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/Kernel/Contracts/Aes.php b/src/Kernel/Contracts/Aes.php index 02c3e6076..e72969f37 100644 --- a/src/Kernel/Contracts/Aes.php +++ b/src/Kernel/Contracts/Aes.php @@ -4,7 +4,7 @@ interface Aes { - public static function encrypt(string $plaintext, string $key, ?string $iv = null): string; + public static function encrypt(string $plaintext, string $key, string $iv = null): string; - public static function decrypt(string $ciphertext, string $key, ?string $iv = null): string; + public static function decrypt(string $ciphertext, string $key, string $iv = null): string; } diff --git a/src/Kernel/Encryptor.php b/src/Kernel/Encryptor.php index cbdf54cda..8e9d3c9b7 100644 --- a/src/Kernel/Encryptor.php +++ b/src/Kernel/Encryptor.php @@ -65,7 +65,7 @@ class Encryptor protected ?string $receiveId = null; - public function __construct(string $appId, string $token, string $aesKey, ?string $receiveId = null) + public function __construct(string $appId, string $token, string $aesKey, string $receiveId = null) { $this->appId = $appId; $this->token = $token; @@ -82,7 +82,7 @@ public function getToken(): string * @throws RuntimeException * @throws Exception */ - public function encrypt(string $plaintext, ?string $nonce = null, int|string|null $timestamp = null): string + public function encrypt(string $plaintext, string $nonce = null, int|string $timestamp = null): string { try { $plaintext = Pkcs7::padding(random_bytes(16).pack('N', strlen($plaintext)).$plaintext.$this->appId, 32); diff --git a/src/Kernel/Exceptions/HttpException.php b/src/Kernel/Exceptions/HttpException.php index db27bd276..6dbae96a5 100644 --- a/src/Kernel/Exceptions/HttpException.php +++ b/src/Kernel/Exceptions/HttpException.php @@ -13,7 +13,7 @@ class HttpException extends Exception /** * HttpException constructor. */ - public function __construct(string $message, ?ResponseInterface $response = null, int $code = 0) + public function __construct(string $message, ResponseInterface $response = null, int $code = 0) { parent::__construct($message, $code); diff --git a/src/Kernel/Form/File.php b/src/Kernel/Form/File.php index 120833bcf..6f1db1152 100644 --- a/src/Kernel/Form/File.php +++ b/src/Kernel/Form/File.php @@ -22,9 +22,9 @@ class File extends DataPart */ public static function from( string $pathOrContents, - ?string $filename = null, - ?string $contentType = null, - ?string $encoding = null + string $filename = null, + string $contentType = null, + string $encoding = null ): DataPart { if (file_exists($pathOrContents)) { return static::fromPath($pathOrContents, $filename, $contentType); @@ -38,9 +38,9 @@ public static function from( */ public static function fromContents( string $contents, - ?string $filename = null, - ?string $contentType = null, - ?string $encoding = null + string $filename = null, + string $contentType = null, + string $encoding = null ): DataPart { if ($contentType === null) { $mimeTypes = new MimeTypes(); @@ -70,9 +70,9 @@ public static function fromContents( */ public static function withContents( string $contents, - ?string $filename = null, - ?string $contentType = null, - ?string $encoding = null + string $filename = null, + string $contentType = null, + string $encoding = null ): DataPart { return self::fromContents(...func_get_args()); } diff --git a/src/Kernel/HttpClient/AccessTokenAwareClient.php b/src/Kernel/HttpClient/AccessTokenAwareClient.php index cd639e2bf..2cbcc6b88 100644 --- a/src/Kernel/HttpClient/AccessTokenAwareClient.php +++ b/src/Kernel/HttpClient/AccessTokenAwareClient.php @@ -32,7 +32,7 @@ class AccessTokenAwareClient implements AccessTokenAwareHttpClientInterface use RetryableClient; public function __construct( - ?HttpClientInterface $client = null, + HttpClientInterface $client = null, protected ?AccessTokenInterface $accessToken = null, protected ?Closure $failureJudge = null, protected bool $throw = true diff --git a/src/Kernel/HttpClient/RequestWithPresets.php b/src/Kernel/HttpClient/RequestWithPresets.php index 70a1de332..79ac016ef 100644 --- a/src/Kernel/HttpClient/RequestWithPresets.php +++ b/src/Kernel/HttpClient/RequestWithPresets.php @@ -88,7 +88,7 @@ public function with(string|array $key, mixed $value = null): static * @throws RuntimeException * @throws InvalidArgumentException */ - public function withFile(string $pathOrContents, string $formName = 'file', ?string $filename = null): static + public function withFile(string $pathOrContents, string $formName = 'file', string $filename = null): static { $file = is_file($pathOrContents) ? File::fromPath( $pathOrContents, @@ -111,7 +111,7 @@ public function withFile(string $pathOrContents, string $formName = 'file', ?str * @throws RuntimeException * @throws InvalidArgumentException */ - public function withFileContents(string $contents, string $formName = 'file', ?string $filename = null): static + public function withFileContents(string $contents, string $formName = 'file', string $filename = null): static { return $this->withFile($contents, $formName, $filename); } diff --git a/src/Kernel/HttpClient/Response.php b/src/Kernel/HttpClient/Response.php index 60d0eccbd..bb9cf9b3c 100644 --- a/src/Kernel/HttpClient/Response.php +++ b/src/Kernel/HttpClient/Response.php @@ -112,7 +112,7 @@ public function isFailed(): bool * @throws ClientExceptionInterface * @throws BadResponseException */ - public function toArray(?bool $throw = null): array + public function toArray(bool $throw = null): array { $throw ??= $this->throw; @@ -143,7 +143,7 @@ public function toArray(?bool $throw = null): array * @throws ClientExceptionInterface * @throws BadResponseException */ - public function toJson(?bool $throw = null): string|false + public function toJson(bool $throw = null): string|false { return json_encode($this->toArray($throw), JSON_UNESCAPED_UNICODE); } @@ -151,7 +151,7 @@ public function toJson(?bool $throw = null): string|false /** * {@inheritdoc} */ - public function toStream(?bool $throw = null) + public function toStream(bool $throw = null) { if ($this->response instanceof StreamableInterface) { return $this->response->toStream($throw ?? $this->throw); @@ -175,7 +175,7 @@ public function toDataUrl(): string return 'data:'.$this->getHeaderLine('content-type').';base64,'.base64_encode($this->getContent()); } - public function toPsrResponse(?ResponseFactoryInterface $responseFactory = null, ?StreamFactoryInterface $streamFactory = null): \Psr\Http\Message\ResponseInterface + public function toPsrResponse(ResponseFactoryInterface $responseFactory = null, StreamFactoryInterface $streamFactory = null): \Psr\Http\Message\ResponseInterface { $streamFactory ??= $responseFactory instanceof StreamFactoryInterface ? $responseFactory : null; @@ -290,12 +290,12 @@ public function getStatusCode(): int return $this->response->getStatusCode(); } - public function getHeaders(?bool $throw = null): array + public function getHeaders(bool $throw = null): array { return $this->response->getHeaders($throw ?? $this->throw); } - public function getContent(?bool $throw = null): string + public function getContent(bool $throw = null): string { return $this->response->getContent($throw ?? $this->throw); } @@ -305,7 +305,7 @@ public function cancel(): void $this->response->cancel(); } - public function getInfo(?string $type = null): mixed + public function getInfo(string $type = null): mixed { return $this->response->getInfo($type); } @@ -329,7 +329,7 @@ public function __toString(): string * @throws RedirectionExceptionInterface * @throws ClientExceptionInterface */ - public function hasHeader(string $name, ?bool $throw = null): bool + public function hasHeader(string $name, bool $throw = null): bool { return isset($this->getHeaders($throw)[$name]); } @@ -342,7 +342,7 @@ public function hasHeader(string $name, ?bool $throw = null): bool * @throws RedirectionExceptionInterface * @throws ClientExceptionInterface */ - public function getHeader(string $name, ?bool $throw = null): array + public function getHeader(string $name, bool $throw = null): array { $name = strtolower($name); $throw ??= $this->throw; @@ -356,7 +356,7 @@ public function getHeader(string $name, ?bool $throw = null): array * @throws RedirectionExceptionInterface * @throws ClientExceptionInterface */ - public function getHeaderLine(string $name, ?bool $throw = null): string + public function getHeaderLine(string $name, bool $throw = null): string { $name = strtolower($name); $throw ??= $this->throw; diff --git a/src/Kernel/HttpClient/RetryableClient.php b/src/Kernel/HttpClient/RetryableClient.php index c43daa0ca..44b4e6c18 100644 --- a/src/Kernel/HttpClient/RetryableClient.php +++ b/src/Kernel/HttpClient/RetryableClient.php @@ -36,7 +36,7 @@ public function retry(array $config = []): static public function retryUsing( RetryStrategyInterface $strategy, int $maxRetries = 3, - ?LoggerInterface $logger = null + LoggerInterface $logger = null ): static { $this->client = new RetryableHttpClient($this->client, $strategy, $maxRetries, $logger); diff --git a/src/Kernel/HttpClient/ScopingHttpClient.php b/src/Kernel/HttpClient/ScopingHttpClient.php index fad671052..74c3ed54e 100644 --- a/src/Kernel/HttpClient/ScopingHttpClient.php +++ b/src/Kernel/HttpClient/ScopingHttpClient.php @@ -38,7 +38,7 @@ public function request(string $method, string $url, array $options = []): Respo return $this->client->request($method, $url, $options); } - public function stream(ResponseInterface|iterable $responses, ?float $timeout = null): ResponseStreamInterface + public function stream(ResponseInterface|iterable $responses, float $timeout = null): ResponseStreamInterface { return $this->client->stream($responses, $timeout); } diff --git a/src/Kernel/Support/AesCbc.php b/src/Kernel/Support/AesCbc.php index b349b9c70..3b4e66447 100644 --- a/src/Kernel/Support/AesCbc.php +++ b/src/Kernel/Support/AesCbc.php @@ -16,7 +16,7 @@ class AesCbc implements Aes /** * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException */ - public static function encrypt(string $plaintext, string $key, ?string $iv = null): string + public static function encrypt(string $plaintext, string $key, string $iv = null): string { $ciphertext = \openssl_encrypt($plaintext, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, (string) $iv); @@ -30,7 +30,7 @@ public static function encrypt(string $plaintext, string $key, ?string $iv = nul /** * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException */ - public static function decrypt(string $ciphertext, string $key, ?string $iv = null): string + public static function decrypt(string $ciphertext, string $key, string $iv = null): string { $plaintext = openssl_decrypt( base64_decode($ciphertext), diff --git a/src/Kernel/Support/AesEcb.php b/src/Kernel/Support/AesEcb.php index f910f19d5..b95ed85a9 100644 --- a/src/Kernel/Support/AesEcb.php +++ b/src/Kernel/Support/AesEcb.php @@ -16,7 +16,7 @@ class AesEcb implements Aes /** * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException */ - public static function encrypt(string $plaintext, string $key, ?string $iv = null): string + public static function encrypt(string $plaintext, string $key, string $iv = null): string { $ciphertext = \openssl_encrypt($plaintext, 'aes-256-ecb', $key, OPENSSL_RAW_DATA, (string) $iv); @@ -30,7 +30,7 @@ public static function encrypt(string $plaintext, string $key, ?string $iv = nul /** * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException */ - public static function decrypt(string $ciphertext, string $key, ?string $iv = null): string + public static function decrypt(string $ciphertext, string $key, string $iv = null): string { $plaintext = openssl_decrypt( base64_decode($ciphertext, true) ?: '', diff --git a/src/Kernel/Support/AesGcm.php b/src/Kernel/Support/AesGcm.php index 5745b7b39..d7f90428c 100644 --- a/src/Kernel/Support/AesGcm.php +++ b/src/Kernel/Support/AesGcm.php @@ -20,7 +20,7 @@ class AesGcm implements Aes /** * @throws InvalidArgumentException */ - public static function encrypt(string $plaintext, string $key, ?string $iv = null, string $aad = ''): string + public static function encrypt(string $plaintext, string $key, string $iv = null, string $aad = ''): string { $ciphertext = openssl_encrypt( $plaintext, @@ -43,7 +43,7 @@ public static function encrypt(string $plaintext, string $key, ?string $iv = nul /** * @throws InvalidArgumentException */ - public static function decrypt(string $ciphertext, string $key, ?string $iv = null, string $aad = ''): string + public static function decrypt(string $ciphertext, string $key, string $iv = null, string $aad = ''): string { $ciphertext = base64_decode($ciphertext); diff --git a/src/Kernel/Traits/RespondXmlMessage.php b/src/Kernel/Traits/RespondXmlMessage.php index 99555e512..95307c866 100644 --- a/src/Kernel/Traits/RespondXmlMessage.php +++ b/src/Kernel/Traits/RespondXmlMessage.php @@ -22,7 +22,7 @@ trait RespondXmlMessage * @throws RuntimeException * @throws InvalidArgumentException */ - public function transformToReply(mixed $response, Message $message, ?Encryptor $encryptor = null): ResponseInterface + public function transformToReply(mixed $response, Message $message, Encryptor $encryptor = null): ResponseInterface { if (empty($response)) { return new Response(200, [], 'success'); @@ -79,7 +79,7 @@ protected function normalizeResponse(mixed $response): array * * @throws RuntimeException */ - protected function createXmlResponse(array $attributes, ?Encryptor $encryptor = null): ResponseInterface + protected function createXmlResponse(array $attributes, Encryptor $encryptor = null): ResponseInterface { $xml = Xml::build($attributes); diff --git a/src/OfficialAccount/AccessToken.php b/src/OfficialAccount/AccessToken.php index 50d8693c6..7a9140bc5 100644 --- a/src/OfficialAccount/AccessToken.php +++ b/src/OfficialAccount/AccessToken.php @@ -36,8 +36,8 @@ public function __construct( protected string $appId, protected string $secret, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null, + CacheInterface $cache = null, + HttpClientInterface $httpClient = null, protected ?bool $stable = false ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://api.weixin.qq.com/']); @@ -46,7 +46,7 @@ public function __construct( public function getKey(): string { - return $this->key ?? $this->key = sprintf('%s.access_token.%s.%s.%s', static::CACHE_KEY_PREFIX, $this->appId, $this->secret, (int)$this->stable); + return $this->key ?? $this->key = sprintf('%s.access_token.%s.%s.%s', static::CACHE_KEY_PREFIX, $this->appId, $this->secret, (int) $this->stable); } public function setKey(string $key): static @@ -132,7 +132,7 @@ public function getStableAccessToken(bool $force_refresh = false): string )->toArray(false); if (empty($response['access_token'])) { - throw new HttpException('Failed to get stable access_token: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); + throw new HttpException('Failed to get stable access_token: '.json_encode($response, JSON_UNESCAPED_UNICODE)); } $this->cache->set($this->getKey(), $response['access_token'], intval($response['expires_in'])); @@ -164,7 +164,7 @@ public function getAccessToken(): string )->toArray(false); if (empty($response['access_token'])) { - throw new HttpException('Failed to get access_token: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); + throw new HttpException('Failed to get access_token: '.json_encode($response, JSON_UNESCAPED_UNICODE)); } $this->cache->set($this->getKey(), $response['access_token'], intval($response['expires_in'])); diff --git a/src/OfficialAccount/Server.php b/src/OfficialAccount/Server.php index 948c390c7..f6fcf6495 100644 --- a/src/OfficialAccount/Server.php +++ b/src/OfficialAccount/Server.php @@ -32,7 +32,7 @@ class Server implements ServerInterface * @throws Throwable */ public function __construct( - ?ServerRequestInterface $request = null, + ServerRequestInterface $request = null, protected ?Encryptor $encryptor = null, ) { $this->request = $request ?? RequestUtil::createDefaultServerRequest(); @@ -122,7 +122,7 @@ protected function decryptRequestMessage(array $query): Closure /** * @throws BadRequestException */ - public function getRequestMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getRequestMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { return Message::createFromRequest($request ?? $this->request); } @@ -131,7 +131,7 @@ public function getRequestMessage(?ServerRequestInterface $request = null): \Eas * @throws BadRequestException * @throws RuntimeException */ - public function getDecryptedMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getDecryptedMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { $request = $request ?? $this->request; $message = $this->getRequestMessage($request); diff --git a/src/OpenPlatform/ComponentAccessToken.php b/src/OpenPlatform/ComponentAccessToken.php index 390efb05c..eaa0cefbb 100644 --- a/src/OpenPlatform/ComponentAccessToken.php +++ b/src/OpenPlatform/ComponentAccessToken.php @@ -29,8 +29,8 @@ public function __construct( protected string $secret, protected VerifyTicketInterface $verifyTicket, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null, + CacheInterface $cache = null, + HttpClientInterface $httpClient = null, ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://api.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/OpenPlatform/Server.php b/src/OpenPlatform/Server.php index bc0616f5b..45dba65b6 100644 --- a/src/OpenPlatform/Server.php +++ b/src/OpenPlatform/Server.php @@ -36,7 +36,7 @@ class Server implements ServerInterface */ public function __construct( protected Encryptor $encryptor, - ?ServerRequestInterface $request = null, + ServerRequestInterface $request = null, ) { $this->request = $request ?? RequestUtil::createDefaultServerRequest(); } @@ -146,7 +146,7 @@ protected function decryptRequestMessage(): Closure /** * @throws BadRequestException */ - public function getRequestMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getRequestMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { return Message::createFromRequest($request ?? $this->request); } @@ -155,7 +155,7 @@ public function getRequestMessage(?ServerRequestInterface $request = null): \Eas * @throws BadRequestException * @throws RuntimeException */ - public function getDecryptedMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getDecryptedMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { $request = $request ?? $this->request; $message = $this->getRequestMessage($request); diff --git a/src/OpenPlatform/VerifyTicket.php b/src/OpenPlatform/VerifyTicket.php index e97acf7be..5692d7416 100644 --- a/src/OpenPlatform/VerifyTicket.php +++ b/src/OpenPlatform/VerifyTicket.php @@ -21,7 +21,7 @@ class VerifyTicket implements VerifyTicketInterface public function __construct( protected string $appId, protected ?string $key = null, - ?CacheInterface $cache = null, + CacheInterface $cache = null, ) { $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); } diff --git a/src/OpenWork/Application.php b/src/OpenWork/Application.php index 7a713b01b..9ccbe694e 100644 --- a/src/OpenWork/Application.php +++ b/src/OpenWork/Application.php @@ -220,7 +220,7 @@ public function setSuiteTicket(SuiteTicketInterface $suiteTicket): SuiteTicketIn public function getAuthorization( string $corpId, string $permanentCode, - ?AccessTokenInterface $suiteAccessToken = null + AccessTokenInterface $suiteAccessToken = null ): Authorization { $suiteAccessToken = $suiteAccessToken ?? $this->getSuiteAccessToken(); @@ -252,7 +252,7 @@ public function getAuthorization( public function getAuthorizerAccessToken( string $corpId, string $permanentCode, - ?AccessTokenInterface $suiteAccessToken = null + AccessTokenInterface $suiteAccessToken = null ): AuthorizerAccessToken { $suiteAccessToken = $suiteAccessToken ?? $this->getSuiteAccessToken(); @@ -283,7 +283,7 @@ public function createClient(): AccessTokenAwareClient * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ - public function getAuthorizerClient(string $corpId, string $permanentCode, ?AccessTokenInterface $suiteAccessToken = null): AccessTokenAwareClient + public function getAuthorizerClient(string $corpId, string $permanentCode, AccessTokenInterface $suiteAccessToken = null): AccessTokenAwareClient { return (new AccessTokenAwareClient( client: $this->getHttpClient(), @@ -301,7 +301,7 @@ public function getAuthorizerClient(string $corpId, string $permanentCode, ?Acce * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ - public function getJsApiTicket(string $corpId, string $permanentCode, ?AccessTokenInterface $suiteAccessToken = null): JsApiTicket + public function getJsApiTicket(string $corpId, string $permanentCode, AccessTokenInterface $suiteAccessToken = null): JsApiTicket { return new JsApiTicket( corpId: $corpId, @@ -312,7 +312,7 @@ public function getJsApiTicket(string $corpId, string $permanentCode, ?AccessTok public function getOAuth( string $suiteId, - ?AccessTokenInterface $suiteAccessToken = null + AccessTokenInterface $suiteAccessToken = null ): SocialiteProviderInterface { $suiteAccessToken = $suiteAccessToken ?? $this->getSuiteAccessToken(); @@ -327,7 +327,7 @@ public function getOAuth( public function getCorpOAuth( string $corpId, - ?AccessTokenInterface $suiteAccessToken = null + AccessTokenInterface $suiteAccessToken = null ): SocialiteProviderInterface { $suiteAccessToken = $suiteAccessToken ?? $this->getSuiteAccessToken(); diff --git a/src/OpenWork/AuthorizerAccessToken.php b/src/OpenWork/AuthorizerAccessToken.php index 7818600a8..229c9e56c 100644 --- a/src/OpenWork/AuthorizerAccessToken.php +++ b/src/OpenWork/AuthorizerAccessToken.php @@ -32,8 +32,8 @@ public function __construct( protected string $permanentCodeOrAccessToken, protected ?AccessTokenInterface $suiteAccessToken = null, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null, + CacheInterface $cache = null, + HttpClientInterface $httpClient = null, ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/OpenWork/JsApiTicket.php b/src/OpenWork/JsApiTicket.php index 492a12c62..50ae2d381 100644 --- a/src/OpenWork/JsApiTicket.php +++ b/src/OpenWork/JsApiTicket.php @@ -30,8 +30,8 @@ class JsApiTicket public function __construct( protected string $corpId, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null + CacheInterface $cache = null, + HttpClientInterface $httpClient = null ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/OpenWork/ProviderAccessToken.php b/src/OpenWork/ProviderAccessToken.php index f8b447777..06de80d0b 100644 --- a/src/OpenWork/ProviderAccessToken.php +++ b/src/OpenWork/ProviderAccessToken.php @@ -27,8 +27,8 @@ public function __construct( protected string $corpId, protected string $providerSecret, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null, + CacheInterface $cache = null, + HttpClientInterface $httpClient = null, ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/OpenWork/Server.php b/src/OpenWork/Server.php index db0ede39f..3a8f7f9b3 100644 --- a/src/OpenWork/Server.php +++ b/src/OpenWork/Server.php @@ -37,7 +37,7 @@ class Server implements ServerInterface public function __construct( protected Encryptor $encryptor, protected Encryptor $providerEncryptor, - ?ServerRequestInterface $request = null, + ServerRequestInterface $request = null, ) { $this->request = $request ?? RequestUtil::createDefaultServerRequest(); } @@ -261,7 +261,7 @@ protected function decryptRequestMessage(): Closure /** * @throws BadRequestException */ - public function getRequestMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getRequestMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { return Message::createFromRequest($request ?? $this->request); } @@ -270,7 +270,7 @@ public function getRequestMessage(?ServerRequestInterface $request = null): \Eas * @throws BadRequestException * @throws RuntimeException */ - public function getDecryptedMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getDecryptedMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { $request = $request ?? $this->request; $message = $this->getRequestMessage($request); diff --git a/src/OpenWork/SuiteAccessToken.php b/src/OpenWork/SuiteAccessToken.php index 4065ae863..1735b94b2 100644 --- a/src/OpenWork/SuiteAccessToken.php +++ b/src/OpenWork/SuiteAccessToken.php @@ -31,8 +31,8 @@ public function __construct( protected string $suiteSecret, protected ?SuiteTicketInterface $suiteTicket = null, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null, + CacheInterface $cache = null, + HttpClientInterface $httpClient = null, ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/OpenWork/SuiteTicket.php b/src/OpenWork/SuiteTicket.php index 467b5b508..7cdaff346 100644 --- a/src/OpenWork/SuiteTicket.php +++ b/src/OpenWork/SuiteTicket.php @@ -20,7 +20,7 @@ class SuiteTicket implements SuiteTicketInterface public function __construct( protected string $suiteId, - ?CacheInterface $cache = null, + CacheInterface $cache = null, protected ?string $key = null, ) { $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/Pay/Client.php b/src/Pay/Client.php index 914658d88..13352faee 100644 --- a/src/Pay/Client.php +++ b/src/Pay/Client.php @@ -78,7 +78,7 @@ class Client implements HttpClientInterface */ public function __construct( protected Merchant $merchant, - ?HttpClientInterface $client = null, + HttpClientInterface $client = null, array $defaultOptions = [] ) { $this->throw = (bool) ($defaultOptions['throw'] ?? true); @@ -182,7 +182,7 @@ public function __call(string $name, array $arguments): mixed * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException */ - public function uploadMedia(string $uri, string $pathOrContents, ?array $meta = null, ?string $filename = null): ResponseInterface + public function uploadMedia(string $uri, string $pathOrContents, array $meta = null, string $filename = null): ResponseInterface { $isFile = is_file($pathOrContents); diff --git a/src/Pay/Server.php b/src/Pay/Server.php index 4aacbe63f..5e02d8b70 100644 --- a/src/Pay/Server.php +++ b/src/Pay/Server.php @@ -111,7 +111,7 @@ public function handleRefunded(callable $handler): static * @throws InvalidArgumentException * @throws RuntimeException */ - public function getRequestMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message|Message + public function getRequestMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message|Message { $originContent = (string) ($request ?? $this->request)->getBody(); @@ -189,7 +189,7 @@ protected function decodeJsonMessage(string $contents): array * @throws InvalidArgumentException * @throws RuntimeException */ - public function getDecryptedMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message|Message + public function getDecryptedMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message|Message { return $this->getRequestMessage($request); } diff --git a/src/Work/AccessToken.php b/src/Work/AccessToken.php index 26597be49..760885e97 100644 --- a/src/Work/AccessToken.php +++ b/src/Work/AccessToken.php @@ -36,8 +36,8 @@ public function __construct( protected string $corpId, protected string $secret, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null + CacheInterface $cache = null, + HttpClientInterface $httpClient = null ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/Work/JsApiTicket.php b/src/Work/JsApiTicket.php index 313cba7e0..f68bb4cd4 100644 --- a/src/Work/JsApiTicket.php +++ b/src/Work/JsApiTicket.php @@ -31,8 +31,8 @@ class JsApiTicket public function __construct( protected string $corpId, protected ?string $key = null, - ?CacheInterface $cache = null, - ?HttpClientInterface $httpClient = null + CacheInterface $cache = null, + HttpClientInterface $httpClient = null ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); diff --git a/src/Work/Server.php b/src/Work/Server.php index ee9f29efc..1394dc588 100644 --- a/src/Work/Server.php +++ b/src/Work/Server.php @@ -33,7 +33,7 @@ class Server implements ServerInterface */ public function __construct( protected Encryptor $encryptor, - ?ServerRequestInterface $request = null, + ServerRequestInterface $request = null, ) { $this->request = $request ?? RequestUtil::createDefaultServerRequest(); } @@ -261,7 +261,7 @@ protected function decryptRequestMessage(): Closure /** * @throws BadRequestException */ - public function getRequestMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getRequestMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { return Message::createFromRequest($request ?? $this->request); } @@ -270,7 +270,7 @@ public function getRequestMessage(?ServerRequestInterface $request = null): \Eas * @throws BadRequestException * @throws RuntimeException */ - public function getDecryptedMessage(?ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message + public function getDecryptedMessage(ServerRequestInterface $request = null): \EasyWeChat\Kernel\Message { $request = $request ?? $this->request; $message = $this->getRequestMessage($request);