From 1866e6ee95c15036038d6c95a5c54c6fe648de36 Mon Sep 17 00:00:00 2001 From: Shyim Date: Tue, 27 Aug 2024 12:13:25 +0200 Subject: [PATCH] fix: php 8.4 deprecations (#226) Signed-off-by: Soner Sayakci --- CHANGELOG.md | 1 + src/OpenSearch/ClientBuilder.php | 4 ++-- .../Common/Exceptions/Serializer/JsonErrorException.php | 2 +- src/OpenSearch/Connections/Connection.php | 4 ++-- src/OpenSearch/Connections/ConnectionInterface.php | 2 +- src/OpenSearch/Handlers/SigV4Handler.php | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce00ec56..7c7f9851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Fixed upcomming PHP 8.4 deprecations ### Updated APIs - Updated opensearch-php APIs to reflect [opensearch-api-specification@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722) ### Security diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index 20c6b7af..1865bc3d 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -531,7 +531,7 @@ public function setSniffOnStart(bool $sniffOnStart): ClientBuilder * @param string $cert The name of a file containing a PEM formatted certificate. * @param string $password if the certificate requires a password */ - public function setSSLCert(string $cert, string $password = null): ClientBuilder + public function setSSLCert(string $cert, ?string $password = null): ClientBuilder { $this->sslCert = [$cert, $password]; @@ -544,7 +544,7 @@ public function setSSLCert(string $cert, string $password = null): ClientBuilder * @param string $key The name of a file containing a private SSL key * @param string $password if the private key requires a password */ - public function setSSLKey(string $key, string $password = null): ClientBuilder + public function setSSLKey(string $key, ?string $password = null): ClientBuilder { $this->sslKey = [$key, $password]; diff --git a/src/OpenSearch/Common/Exceptions/Serializer/JsonErrorException.php b/src/OpenSearch/Common/Exceptions/Serializer/JsonErrorException.php index 2456ae8c..db2de9ad 100644 --- a/src/OpenSearch/Common/Exceptions/Serializer/JsonErrorException.php +++ b/src/OpenSearch/Common/Exceptions/Serializer/JsonErrorException.php @@ -60,7 +60,7 @@ class JsonErrorException extends \Exception implements OpenSearchException * @param mixed $input * @param mixed $result */ - public function __construct(int $code, $input, $result, \Throwable $previous = null) + public function __construct(int $code, $input, $result, ?\Throwable $previous = null) { if (isset(self::$messages[$code]) !== true) { throw new \InvalidArgumentException(sprintf('Encountered unknown JSON error code: [%d]', $code)); diff --git a/src/OpenSearch/Connections/Connection.php b/src/OpenSearch/Connections/Connection.php index c81861f8..7279f56c 100644 --- a/src/OpenSearch/Connections/Connection.php +++ b/src/OpenSearch/Connections/Connection.php @@ -202,7 +202,7 @@ public function __construct( * @param Transport|null $transport * @return mixed */ - public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], Transport $transport = null) + public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], ?Transport $transport = null) { if ($body !== null) { $body = $this->serializer->serialize($body); @@ -256,7 +256,7 @@ public function getLastRequestInfo(): array private function wrapHandler(callable $handler): callable { - return function (array $request, Connection $connection, Transport $transport = null, $options) use ($handler) { + return function (array $request, Connection $connection, ?Transport $transport, $options) use ($handler) { $this->lastRequest = []; $this->lastRequest['request'] = $request; diff --git a/src/OpenSearch/Connections/ConnectionInterface.php b/src/OpenSearch/Connections/ConnectionInterface.php index 0a5adcf5..0e6280ae 100644 --- a/src/OpenSearch/Connections/ConnectionInterface.php +++ b/src/OpenSearch/Connections/ConnectionInterface.php @@ -79,5 +79,5 @@ public function getLastRequestInfo(): array; * @param mixed $body * @return mixed */ - public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], Transport $transport = null); + public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], ?Transport $transport = null); } diff --git a/src/OpenSearch/Handlers/SigV4Handler.php b/src/OpenSearch/Handlers/SigV4Handler.php index b40613b4..e45639c7 100644 --- a/src/OpenSearch/Handlers/SigV4Handler.php +++ b/src/OpenSearch/Handlers/SigV4Handler.php @@ -47,8 +47,8 @@ class SigV4Handler public function __construct( string $region, string $service, - callable $credentialProvider = null, - callable $wrappedHandler = null + ?callable $credentialProvider = null, + ?callable $wrappedHandler = null ) { self::assertDependenciesInstalled(); $this->signer = new SignatureV4($service, $region);