From 9a7ba5cd8fb6b564a8393d62c768e59fe463d480 Mon Sep 17 00:00:00 2001 From: Vikram Kumar Date: Mon, 24 Aug 2026 13:25:48 +0530 Subject: [PATCH] Fixed PHP 8.4 compatibility issues. --- src/AuditLog/AuditLogApi.php | 4 +-- src/Batch/BatchApi.php | 4 +-- src/Batch/BatchApiV2.php | 6 ++--- src/Context/ContextApi.php | 6 ++--- .../DistributedLockServiceApi.php | 2 +- src/Exceptions/SmartlingApiException.php | 2 +- src/File/FileApi.php | 26 +++++++++---------- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/AuditLog/AuditLogApi.php b/src/AuditLog/AuditLogApi.php index aa1d456..4b902e7 100755 --- a/src/AuditLog/AuditLogApi.php +++ b/src/AuditLog/AuditLogApi.php @@ -19,7 +19,7 @@ class AuditLogApi extends BaseApiAbstract /** * {@inheritdoc} */ - public function __construct($projectId, ClientInterface $client, LoggerInterface $logger = null, $service_url = null) + public function __construct($projectId, ClientInterface $client, ?LoggerInterface $logger = null, $service_url = null) { parent::__construct($projectId, $client, $logger, $service_url); @@ -29,7 +29,7 @@ public function __construct($projectId, ClientInterface $client, LoggerInterface $this->setBaseUrl(\rtrim($service_url, '/')); } - public static function create(AuthApiInterface $authProvider, $projectId, LoggerInterface $logger = null) + public static function create(AuthApiInterface $authProvider, $projectId, ?LoggerInterface $logger = null) { $client = self::initializeHttpClient(self::ENDPOINT_URL); diff --git a/src/Batch/BatchApi.php b/src/Batch/BatchApi.php index 202d422..f9d1821 100755 --- a/src/Batch/BatchApi.php +++ b/src/Batch/BatchApi.php @@ -88,7 +88,7 @@ public function createBatch(CreateBatchParameters $parameters) * * @throws SmartlingApiException */ - public function uploadBatchFile($realPath, $fileName, $fileType, $batchUid, UploadFileParameters $parameters = null) { + public function uploadBatchFile($realPath, $fileName, $fileType, $batchUid, ?UploadFileParameters $parameters = null) { // @TODO: let's pass file, fileUri and fileType in UploadFileParameters. // In this case we could get rid of passing these variables into this // method. But this approach requires changes in UploadFileParameters @@ -121,7 +121,7 @@ public function uploadBatchFile($realPath, $fileName, $fileType, $batchUid, Uplo * * @throws SmartlingApiException */ - public function executeBatch($batchUid, ExecuteBatchParameters $parameters = null) + public function executeBatch($batchUid, ?ExecuteBatchParameters $parameters = null) { $endpoint = \vsprintf('batches/%s', [$batchUid]); diff --git a/src/Batch/BatchApiV2.php b/src/Batch/BatchApiV2.php index d61afe5..72cc8a5 100644 --- a/src/Batch/BatchApiV2.php +++ b/src/Batch/BatchApiV2.php @@ -19,8 +19,8 @@ class BatchApiV2 extends BaseApiAbstract public function __construct( AuthApiInterface $authProvider, string $projectId, - LoggerInterface $logger = null, - ClientInterface $client = null + ?LoggerInterface $logger = null, + ?ClientInterface $client = null ) { if ($client === null) { @@ -33,7 +33,7 @@ public function __construct( /** * @throws SmartlingApiException */ - public function cancelBatchFile(string $batchUid, string $fileUri, string $reason = null): void + public function cancelBatchFile(string $batchUid, string $fileUri, ?string $reason = null): void { if ($batchUid === '') { throw new \UnexpectedValueException('BatchUid cannot be empty.'); diff --git a/src/Context/ContextApi.php b/src/Context/ContextApi.php index a76d933..52b3173 100644 --- a/src/Context/ContextApi.php +++ b/src/Context/ContextApi.php @@ -149,7 +149,7 @@ public function uploadContext(UploadContextParameters $params) * @return array * @throws \Smartling\Exceptions\SmartlingApiException */ - public function matchContext($contextUid, MatchContextParameters $params = null) + public function matchContext($contextUid, ?MatchContextParameters $params = null) { $endpoint = \vsprintf('contexts/%s/match/async', [$contextUid]); $requestData = $this->getDefaultRequestData('json', \is_null($params) ? [] : $params->exportToArray()); @@ -165,7 +165,7 @@ public function matchContext($contextUid, MatchContextParameters $params = null) * * @throws \Smartling\Exceptions\SmartlingApiException */ - public function matchContextSync($contextUid, MatchContextParameters $params = null) + public function matchContextSync($contextUid, ?MatchContextParameters $params = null) { $this->wait($this->matchContext($contextUid, $params)); } @@ -216,7 +216,7 @@ public function getMatchStatus($processUid) { * @return array * @throws \Smartling\Exceptions\SmartlingApiException */ - public function getMissingResources(MissingResourcesParameters $params = null) { + public function getMissingResources(?MissingResourcesParameters $params = null) { $requestData = $this->getDefaultRequestData('query', \is_null($params) ? [] : $params->exportToArray()); return $this->sendRequest('missing-resources', $requestData, self::HTTP_METHOD_GET); diff --git a/src/DistributedLockService/DistributedLockServiceApi.php b/src/DistributedLockService/DistributedLockServiceApi.php index d4d0c8b..cac9f38 100644 --- a/src/DistributedLockService/DistributedLockServiceApi.php +++ b/src/DistributedLockService/DistributedLockServiceApi.php @@ -18,7 +18,7 @@ class DistributedLockServiceApi extends BaseApiAbstract * * @return self */ - public static function create(AuthApiInterface $authProvider, $projectId, LoggerInterface $logger = null) + public static function create(AuthApiInterface $authProvider, $projectId, ?LoggerInterface $logger = null) { $instance = new self($projectId, self::initializeHttpClient(self::ENDPOINT_URL), $logger, self::ENDPOINT_URL); $instance->setAuth($authProvider); diff --git a/src/Exceptions/SmartlingApiException.php b/src/Exceptions/SmartlingApiException.php index ff8d3f4..983a238 100755 --- a/src/Exceptions/SmartlingApiException.php +++ b/src/Exceptions/SmartlingApiException.php @@ -34,7 +34,7 @@ class SmartlingApiException extends \Exception * @param int $code * @param \Exception $previous */ - public function __construct($errors, $code = 0, \Exception $previous = null) + public function __construct($errors, $code = 0, ?\Exception $previous = null) { $message = ''; diff --git a/src/File/FileApi.php b/src/File/FileApi.php index a3efa82..16912d4 100755 --- a/src/File/FileApi.php +++ b/src/File/FileApi.php @@ -125,7 +125,7 @@ protected function getDefaultRequestData($parametersType, $parameters, $auth = t * * @see http://docs.smartling.com/pages/API/FileAPI/Upload-File/ */ - public function uploadFile($realPath, $file_name, $file_type, UploadFileParameters $params = null) + public function uploadFile($realPath, $file_name, $file_type, ?UploadFileParameters $params = null) { if (\is_null($params)) { $params = new UploadFileParameters(); @@ -170,7 +170,7 @@ public function uploadFile($realPath, $file_name, $file_type, UploadFileParamete * * @see http://docs.smartling.com/pages/API/FileAPI/Download-File/ */ - public function downloadFile($fileUri, $locale = '', DownloadFileParameters $params = null) + public function downloadFile($fileUri, $locale = '', ?DownloadFileParameters $params = null) { if ((!\is_string($locale)) || \strlen($locale) < 2) { $message = \vsprintf( @@ -192,7 +192,7 @@ public function downloadFile($fileUri, $locale = '', DownloadFileParameters $par return $this->sendRequest("locales/{$locale}/file", $requestData, self::HTTP_METHOD_GET, true); } - public function downloadAllTranslationsOfFile($fileUri, DownloadFileParameters $params = null) + public function downloadAllTranslationsOfFile($fileUri, ?DownloadFileParameters $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -203,7 +203,7 @@ public function downloadAllTranslationsOfFile($fileUri, DownloadFileParameters $ return $this->sendRequest("locales/all/file/zip", $requestData, self::HTTP_METHOD_GET, true); } - public function downloadMultipleTranslationsOfFiles(DownloadMultipleFilesParameters $params = null) + public function downloadMultipleTranslationsOfFiles(?DownloadMultipleFilesParameters $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); @@ -228,7 +228,7 @@ public function downloadMultipleTranslationsOfFiles(DownloadMultipleFilesParamet * @throws SmartlingApiException * @see http://docs.smartling.com/pages/API/FileAPI/Status/ */ - public function getStatus($fileUri, $locale, ParameterInterface $params = null) + public function getStatus($fileUri, $locale, ?ParameterInterface $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -251,7 +251,7 @@ public function getStatus($fileUri, $locale, ParameterInterface $params = null) * @throws SmartlingApiException * @see http://docs.smartling.com/pages/API/v2/FileAPI/Status/All-Locales/ */ - public function getStatusForAllLocales($fileUri, ParameterInterface $params = null) + public function getStatusForAllLocales($fileUri, ?ParameterInterface $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -291,7 +291,7 @@ public function getStatusForAllLocales($fileUri, ParameterInterface $params = nu * * @see http://docs.smartling.com/pages/API/FileAPI/List/ */ - public function getList(ListFilesParameters $params = null) + public function getList(?ListFilesParameters $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); @@ -307,7 +307,7 @@ public function getList(ListFilesParameters $params = null) * can only be of a value 'COMPLETED' * @return bool */ - public function getExtendedList($locale, ExtendedListFilesParameters $params = null) + public function getExtendedList($locale, ?ExtendedListFilesParameters $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); @@ -334,7 +334,7 @@ public function getExtendedList($locale, ExtendedListFilesParameters $params = n * @throws SmartlingApiException * @see http://docs.smartling.com/pages/API/FileAPI/Rename/ */ - public function renameFile($fileUri, $newFileUri, ParameterInterface $params = null) + public function renameFile($fileUri, $newFileUri, ?ParameterInterface $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -360,7 +360,7 @@ public function renameFile($fileUri, $newFileUri, ParameterInterface $params = n * @return array * @throws SmartlingApiException */ - public function deleteFile($fileUri, ParameterInterface $params = null) + public function deleteFile($fileUri, ?ParameterInterface $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -422,7 +422,7 @@ public function import($locale, $fileUri, $fileType, $fileRealPath, $translation * @return array * @throws SmartlingApiException */ - public function getStatusAllLocales($fileUri, ParameterInterface $params = null) + public function getStatusAllLocales($fileUri, ?ParameterInterface $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -442,7 +442,7 @@ public function getStatusAllLocales($fileUri, ParameterInterface $params = null) * @return array * @throws SmartlingApiException */ - public function getLastModified($fileUri, ParameterInterface $params = null) + public function getLastModified($fileUri, ?ParameterInterface $params = null) { $params = (\is_null($params)) ? [] : $params->exportToArray(); $params['fileUri'] = $fileUri; @@ -465,7 +465,7 @@ public function getLastModified($fileUri, ParameterInterface $params = null) * * @see http://docs.smartling.com/pages/API/v2/FileAPI/Last-Modified/All-Locales/ */ - public function lastModified($fileUri, ParameterInterface $params = null) + public function lastModified($fileUri, ?ParameterInterface $params = null) { $result = $this->getLastModified($fileUri, $params);