From 2b14951e6401bf33f947f991f6b8508f49fe6f45 Mon Sep 17 00:00:00 2001 From: bnzo <17174973+bnzo@users.noreply.github.com> Date: Thu, 2 Apr 2026 14:21:39 +0200 Subject: [PATCH] Fix PHP 8.4 deprecation: use explicit nullable types PHP 8.4 deprecated implicitly nullable parameters (e.g. `Type $param = null`). This updates all occurrences to use the explicit `?Type $param = null` syntax across the codebase. Affected files: - Client.php - Api/ApiWrapper.php (get, post, patch, delete) - Api/Auth/Token.php - Api/Ais/Connect.php - Api/Customers/Customers.php - Api/Pis/Initiate.php, Payment.php, Refund.php, RequestToPay.php, Settlement.php - Api/Resources/Provider.php - Config/Endpoint.php, Telemetry.php - Util/Header.php, PemManager.php --- src/Api/Ais/Connect.php | 2 +- src/Api/ApiWrapper.php | 8 ++++---- src/Api/Auth/Token.php | 2 +- src/Api/Customers/Customers.php | 2 +- src/Api/Pis/Initiate.php | 2 +- src/Api/Pis/Payment.php | 2 +- src/Api/Pis/Refund.php | 2 +- src/Api/Pis/RequestToPay.php | 4 ++-- src/Api/Pis/Settlement.php | 2 +- src/Api/Resources/Provider.php | 2 +- src/Client.php | 2 +- src/Config/Endpoint.php | 2 +- src/Config/Telemetry.php | 4 ++-- src/Util/Header.php | 2 +- src/Util/PemManager.php | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Api/Ais/Connect.php b/src/Api/Ais/Connect.php index c3d0e65..dc7fab4 100644 --- a/src/Api/Ais/Connect.php +++ b/src/Api/Ais/Connect.php @@ -17,7 +17,7 @@ class Connect extends Api * * @return ApiResponse Generated connect. */ - public function generate(string $redirectUri, string $state, string $scope = null): ApiResponse + public function generate(string $redirectUri, string $state, ?string $scope = null): ApiResponse { $params = Http::buildHttpQuery([ 'redirect_uri' => $redirectUri, diff --git a/src/Api/ApiWrapper.php b/src/Api/ApiWrapper.php index c99076b..e28904a 100644 --- a/src/Api/ApiWrapper.php +++ b/src/Api/ApiWrapper.php @@ -47,7 +47,7 @@ public function __construct() */ public function get( string $endpoint, - array $headers = null, + ?array $headers = null, int $authMethod = 1 ): ApiResponse { if (!$headers) { @@ -88,7 +88,7 @@ public function post( string $endpoint, $body = [], bool $json = true, - array $headers = null, + ?array $headers = null, int $authMethod = 1 ): ApiResponse { if (!$headers) { @@ -136,7 +136,7 @@ public function patch( string $endpoint, $body = null, bool $json = true, - array $headers = null, + ?array $headers = null, int $authMethod = 1 ): ApiResponse { if (!$headers) { @@ -184,7 +184,7 @@ public function delete( string $endpoint, $body = null, bool $json = true, - array $headers = null, + ?array $headers = null, int $authMethod = 1 ): ApiResponse { if (!$headers) { diff --git a/src/Api/Auth/Token.php b/src/Api/Auth/Token.php index 2365767..1a87da6 100644 --- a/src/Api/Auth/Token.php +++ b/src/Api/Auth/Token.php @@ -16,7 +16,7 @@ class Token extends Api * * @return ApiResponse Generated token. */ - public function generate(string $clientIdentifier = 'pis', string $code = null): ApiResponse + public function generate(string $clientIdentifier = 'pis', ?string $code = null): ApiResponse { if (!$config = Fintecture::getConfig()) { throw new FintectureException('Token needs a configured client'); diff --git a/src/Api/Customers/Customers.php b/src/Api/Customers/Customers.php index c7e1814..297778c 100644 --- a/src/Api/Customers/Customers.php +++ b/src/Api/Customers/Customers.php @@ -21,7 +21,7 @@ class Customers extends Api * * @return ApiResponse */ - public function get(string $customerId = null, array $additionalParams = []): ApiResponse + public function get(?string $customerId = null, array $additionalParams = []): ApiResponse { $path = '/v1/customers'; diff --git a/src/Api/Pis/Initiate.php b/src/Api/Pis/Initiate.php index 3e2b6b0..97cf897 100644 --- a/src/Api/Pis/Initiate.php +++ b/src/Api/Pis/Initiate.php @@ -18,7 +18,7 @@ class Initiate extends Api * * @return ApiResponse Generated connect. */ - public function generate(array $data, string $providerId, string $redirectUri, string $state = null): ApiResponse + public function generate(array $data, string $providerId, string $redirectUri, ?string $state = null): ApiResponse { $params = Http::buildHttpQuery([ 'redirect_uri' => $redirectUri, diff --git a/src/Api/Pis/Payment.php b/src/Api/Pis/Payment.php index 9e863d1..9418130 100644 --- a/src/Api/Pis/Payment.php +++ b/src/Api/Pis/Payment.php @@ -17,7 +17,7 @@ class Payment extends Api * * @return ApiResponse Payments. */ - public function get(string $sessionId = null, bool $withBeneficiary = null, bool $withVirtualBeneficiary = null): ApiResponse + public function get(?string $sessionId = null, ?bool $withBeneficiary = null, ?bool $withVirtualBeneficiary = null): ApiResponse { $path = '/pis/v2/payments'; if ($sessionId) { diff --git a/src/Api/Pis/Refund.php b/src/Api/Pis/Refund.php index d5d9d47..f3729c7 100644 --- a/src/Api/Pis/Refund.php +++ b/src/Api/Pis/Refund.php @@ -16,7 +16,7 @@ class Refund extends Api * * @return ApiResponse Generated refund. */ - public function generate(array $data, string $state = null): ApiResponse + public function generate(array $data, ?string $state = null): ApiResponse { $params = Http::buildHttpQuery([ 'state' => $state diff --git a/src/Api/Pis/RequestToPay.php b/src/Api/Pis/RequestToPay.php index 027b4c7..6087f31 100644 --- a/src/Api/Pis/RequestToPay.php +++ b/src/Api/Pis/RequestToPay.php @@ -22,8 +22,8 @@ class RequestToPay extends Api public function generate( array $data, string $xLanguage, - string $redirectUri = null, - string $state = null + ?string $redirectUri = null, + ?string $state = null ): ApiResponse { $params = Http::buildHttpQuery([ 'redirect_uri' => $redirectUri, diff --git a/src/Api/Pis/Settlement.php b/src/Api/Pis/Settlement.php index 0fc1372..d166f9d 100644 --- a/src/Api/Pis/Settlement.php +++ b/src/Api/Pis/Settlement.php @@ -20,7 +20,7 @@ class Settlement extends Api * * @return ApiResponse Disbursements. */ - public function get(string $settlementId = null, array $additionalParams = []): ApiResponse + public function get(?string $settlementId = null, array $additionalParams = []): ApiResponse { $path = '/pis/v2/settlements'; if ($settlementId) { diff --git a/src/Api/Resources/Provider.php b/src/Api/Resources/Provider.php index e1e4db2..3fc0065 100644 --- a/src/Api/Resources/Provider.php +++ b/src/Api/Resources/Provider.php @@ -27,7 +27,7 @@ class Provider extends Api * * @return ApiResponse Provider(s) infos. */ - public function get(string $id = null, array $additionalParams = []): ApiResponse + public function get(?string $id = null, array $additionalParams = []): ApiResponse { $path = '/res/v1/providers' . ($id ? '/' . $id : ''); if (!empty($additionalParams)) { diff --git a/src/Client.php b/src/Client.php index c15dc06..e5e22ee 100644 --- a/src/Client.php +++ b/src/Client.php @@ -57,7 +57,7 @@ abstract class Client * @param array $config The config of the user app to create the main client. * @param ?ClientInterface $httpClient Client to do HTTP requests, if not set, auto discovery will be used to find a HTTP client. */ - public function __construct(array $config, ClientInterface $httpClient = null) + public function __construct(array $config, ?ClientInterface $httpClient = null) { // Set a unique identifier for the current instance $this->identifier .= '-' . uniqid(); diff --git a/src/Config/Endpoint.php b/src/Config/Endpoint.php index 1381cb0..4727453 100644 --- a/src/Config/Endpoint.php +++ b/src/Config/Endpoint.php @@ -27,7 +27,7 @@ private static function getCurrentEnvironment(): string * * @return string Main API URL. */ - public static function getApiUrl(string $environment = null): string + public static function getApiUrl(?string $environment = null): string { $environment = $environment ?: self::getCurrentEnvironment(); switch ($environment) { diff --git a/src/Config/Telemetry.php b/src/Config/Telemetry.php index af6eb18..069b438 100644 --- a/src/Config/Telemetry.php +++ b/src/Config/Telemetry.php @@ -14,7 +14,7 @@ class Telemetry * * @return bool Sending status. */ - public static function logAction(string $action, array $additionalMetrics = null): bool + public static function logAction(string $action, ?array $additionalMetrics = null): bool { // Don't send a call if telemetry is disabled if (Fintecture::getConfig() && !Fintecture::getConfig()->getEnabledTelemetry()) { @@ -68,7 +68,7 @@ public static function logMetric(string $category): bool * * @return array Configuration. */ - private static function getMetrics(string $action, array $additionalMetrics = null): array + private static function getMetrics(string $action, ?array $additionalMetrics = null): array { // Construct configuration return $metrics = [ diff --git a/src/Util/Header.php b/src/Util/Header.php index b9d19ad..a5a2bae 100644 --- a/src/Util/Header.php +++ b/src/Util/Header.php @@ -25,7 +25,7 @@ public static function generate( string $path, $body = null, int $authMethod = 1, - array $customCredentials = null + ?array $customCredentials = null ): array { if (isset($customCredentials['appId']) && isset($customCredentials['appSecret']) && isset($customCredentials['privateKey'])) { $appId = $customCredentials['appId']; diff --git a/src/Util/PemManager.php b/src/Util/PemManager.php index ab1eefe..c11b091 100644 --- a/src/Util/PemManager.php +++ b/src/Util/PemManager.php @@ -7,7 +7,7 @@ class PemManager /** @var ?EncryptionManager $encryptionManager */ private $encryptionManager; - public function __construct(EncryptionManager $encryptionManager = null) + public function __construct(?EncryptionManager $encryptionManager = null) { $this->encryptionManager = $encryptionManager ?: null; }