Skip to content

Commit 45765c1

Browse files
authored
CC-1903/remove-php-8-4-deprecations (#214)
* [CC-1903] explicitly set nullable string parameter.
1 parent 31b3140 commit 45765c1

29 files changed

+236
-252
lines changed

src/Adapter/ApplepayAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function validMerchantValidationDomain(string $merchantValidationURL): bo
6767
* This is necessary if the ssl cert file doesn't contain key already.
6868
* @param string|null $caCert Path to CA certificate.
6969
*/
70-
public function init(string $sslCert, string $sslKey = null, string $caCert = null): void
70+
public function init(string $sslCert, ?string $sslKey = null, ?string $caCert = null): void
7171
{
7272
$timeout = EnvironmentService::getTimeout();
7373
$curlVerbose = EnvironmentService::isCurlVerbose();

src/Adapter/CurlAdapter.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
namespace UnzerSDK\Adapter;
1212

13-
use UnzerSDK\Unzer;
14-
use UnzerSDK\Services\EnvironmentService;
15-
use UnzerSDK\Exceptions\UnzerApiException;
1613
use RuntimeException;
17-
14+
use UnzerSDK\Exceptions\UnzerApiException;
15+
use UnzerSDK\Services\EnvironmentService;
16+
use UnzerSDK\Unzer;
1817
use function extension_loaded;
1918
use function in_array;
2019

@@ -37,7 +36,7 @@ public function __construct()
3736
/**
3837
* {@inheritDoc}
3938
*/
40-
public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void
39+
public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void
4140
{
4241
$timeout = EnvironmentService::getTimeout();
4342
$curlVerbose = EnvironmentService::isCurlVerbose();

src/Adapter/HttpAdapterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface HttpAdapterInterface
2525
* @param string|null $payload Json encoded payload string.
2626
* @param string $httpMethod The Http method to perform.
2727
*/
28-
public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void;
28+
public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void;
2929

3030
/**
3131
* Executes the request and returns the response.

src/Exceptions/UnzerApiException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class UnzerApiException extends Exception
2626
*
2727
* @param string $merchantMessage
2828
* @param string $clientMessage
29-
* @param string $code
29+
* @param string|null $code
3030
* @param string|null $errorId
3131
*/
32-
public function __construct($merchantMessage = '', $clientMessage = '', $code = null, string $errorId = null)
32+
public function __construct($merchantMessage = '', $clientMessage = '', $code = null, ?string $errorId = null)
3333
{
3434
$merchantMessage = empty($merchantMessage) ? static::MESSAGE : $merchantMessage;
3535
$this->clientMessage = empty($clientMessage) ? static::CLIENT_MESSAGE : $clientMessage;

src/Interfaces/CancelServiceInterface.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
namespace UnzerSDK\Interfaces;
1010

11+
use RuntimeException;
1112
use UnzerSDK\Constants\CancelReasonCodes;
1213
use UnzerSDK\Exceptions\UnzerApiException;
1314
use UnzerSDK\Resources\Payment;
1415
use UnzerSDK\Resources\TransactionTypes\Authorization;
1516
use UnzerSDK\Resources\TransactionTypes\Cancellation;
1617
use UnzerSDK\Resources\TransactionTypes\Charge;
17-
use RuntimeException;
1818

1919
interface CancelServiceInterface
2020
{
@@ -30,7 +30,7 @@ interface CancelServiceInterface
3030
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
3131
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
3232
*/
33-
public function cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation;
33+
public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation;
3434

3535
/**
3636
* Performs a Cancellation transaction for the Authorization of the given Payment object.
@@ -44,7 +44,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount
4444
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
4545
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
4646
*/
47-
public function cancelAuthorizationByPayment($payment, float $amount = null): Cancellation;
47+
public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation;
4848

4949
/**
5050
* Performs a Cancellation transaction for the given Charge and returns the resulting Cancellation object.
@@ -67,11 +67,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca
6767
public function cancelChargeById(
6868
$payment,
6969
string $chargeId,
70-
float $amount = null,
71-
string $reasonCode = null,
72-
string $referenceText = null,
73-
float $amountNet = null,
74-
float $amountVat = null
70+
?float $amount = null,
71+
?string $reasonCode = null,
72+
?string $referenceText = null,
73+
?float $amountNet = null,
74+
?float $amountVat = null
7575
): Cancellation;
7676

7777
/**
@@ -93,11 +93,11 @@ public function cancelChargeById(
9393
*/
9494
public function cancelCharge(
9595
Charge $charge,
96-
float $amount = null,
97-
string $reasonCode = null,
98-
string $referenceText = null,
99-
float $amountNet = null,
100-
float $amountVat = null
96+
?float $amount = null,
97+
?string $reasonCode = null,
98+
?string $referenceText = null,
99+
?float $amountNet = null,
100+
?float $amountVat = null
101101
): Cancellation;
102102

103103
/**
@@ -119,11 +119,11 @@ public function cancelCharge(
119119
*/
120120
public function cancelPayment(
121121
$payment,
122-
float $amount = null,
122+
?float $amount = null,
123123
?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL,
124-
string $referenceText = null,
125-
float $amountNet = null,
126-
float $amountVat = null
124+
?string $referenceText = null,
125+
?float $amountNet = null,
126+
?float $amountVat = null
127127
): array;
128128

129129
/**
@@ -167,5 +167,5 @@ public function cancelChargedPayment($payment, ?Cancellation $cancellation = nul
167167
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
168168
* @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK.
169169
*/
170-
public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation;
170+
public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation;
171171
}

src/Interfaces/PaymentServiceInterface.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace UnzerSDK\Interfaces;
1010

1111
use DateTime;
12+
use RuntimeException;
1213
use UnzerSDK\Exceptions\UnzerApiException;
1314
use UnzerSDK\Resources\AbstractUnzerResource;
1415
use UnzerSDK\Resources\Basket;
@@ -24,7 +25,6 @@
2425
use UnzerSDK\Resources\TransactionTypes\Charge;
2526
use UnzerSDK\Resources\TransactionTypes\Payout;
2627
use UnzerSDK\Resources\TransactionTypes\Shipment;
27-
use RuntimeException;
2828

2929
interface PaymentServiceInterface
3030
{
@@ -48,8 +48,8 @@ public function performAuthorization(
4848
Authorization $authorization,
4949
$paymentType,
5050
$customer = null,
51-
Metadata $metadata = null,
52-
Basket $basket = null
51+
?Metadata $metadata = null,
52+
?Basket $basket = null
5353
): Authorization;
5454

5555
/**
@@ -130,8 +130,8 @@ public function performCharge(
130130
Charge $charge,
131131
$paymentType,
132132
$customer = null,
133-
Metadata $metadata = null,
134-
Basket $basket = null
133+
?Metadata $metadata = null,
134+
?Basket $basket = null
135135
): Charge;
136136

137137
/**
@@ -229,9 +229,9 @@ public function performChargeOnPayment(
229229
*/
230230
public function chargeAuthorization(
231231
$payment,
232-
float $amount = null,
233-
string $orderId = null,
234-
string $invoiceId = null
232+
?float $amount = null,
233+
?string $orderId = null,
234+
?string $invoiceId = null
235235
): Charge;
236236

237237
/**
@@ -252,9 +252,9 @@ public function chargeAuthorization(
252252
*/
253253
public function chargePayment(
254254
$payment,
255-
float $amount = null,
256-
string $orderId = null,
257-
string $invoiceId = null
255+
?float $amount = null,
256+
?string $orderId = null,
257+
?string $invoiceId = null
258258
): Charge;
259259

260260
/**
@@ -284,11 +284,11 @@ public function payout(
284284
$paymentType,
285285
string $returnUrl,
286286
$customer = null,
287-
string $orderId = null,
288-
Metadata $metadata = null,
289-
Basket $basket = null,
290-
string $invoiceId = null,
291-
string $referenceText = null
287+
?string $orderId = null,
288+
?Metadata $metadata = null,
289+
?Basket $basket = null,
290+
?string $invoiceId = null,
291+
?string $referenceText = null
292292
): Payout;
293293

294294
/**
@@ -303,7 +303,7 @@ public function payout(
303303
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
304304
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
305305
*/
306-
public function ship($payment, string $invoiceId = null, string $orderId = null): Shipment;
306+
public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment;
307307

308308
/**
309309
* Initializes a PayPage for charge transaction and returns the PayPage resource.
@@ -328,9 +328,9 @@ public function ship($payment, string $invoiceId = null, string $orderId = null)
328328
*/
329329
public function initPayPageCharge(
330330
Paypage $paypage,
331-
Customer $customer = null,
332-
Basket $basket = null,
333-
Metadata $metadata = null
331+
?Customer $customer = null,
332+
?Basket $basket = null,
333+
?Metadata $metadata = null
334334
): Paypage;
335335

336336
/**
@@ -356,9 +356,9 @@ public function initPayPageCharge(
356356
*/
357357
public function initPayPageAuthorize(
358358
Paypage $paypage,
359-
Customer $customer = null,
360-
Basket $basket = null,
361-
Metadata $metadata = null
359+
?Customer $customer = null,
360+
?Basket $basket = null,
361+
?Metadata $metadata = null
362362
): Paypage;
363363

364364
/**
@@ -378,7 +378,7 @@ public function fetchInstallmentPlans(
378378
float $amount,
379379
string $currency,
380380
float $effectiveInterest,
381-
DateTime $orderDate = null
381+
?DateTime $orderDate = null
382382
): InstalmentPlans;
383383

384384
/**

src/Interfaces/ResourceServiceInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function fetchPayout($payment): Payout;
5757
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
5858
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
5959
*/
60-
public function activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring;
60+
public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring;
6161

6262
/**
6363
* Fetch and return payment by given payment id or payment object.

src/Interfaces/WebhookServiceInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
namespace UnzerSDK\Interfaces;
1010

11+
use RuntimeException;
1112
use UnzerSDK\Exceptions\UnzerApiException;
1213
use UnzerSDK\Resources\AbstractUnzerResource;
1314
use UnzerSDK\Resources\Webhook;
14-
use RuntimeException;
1515

1616
interface WebhookServiceInterface
1717
{
@@ -106,5 +106,5 @@ public function registerMultipleWebhooks(string $url, array $events): array;
106106
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
107107
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
108108
*/
109-
public function fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource;
109+
public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource;
110110
}

src/Resources/EmbeddedResources/GooglePay/SignedMessage.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ class SignedMessage extends AbstractUnzerResource
1515
/** @var string */
1616
protected $encryptedMessage;
1717

18-
/**
19-
* @param string $tag
20-
* @param string $ephemeralPublicKey
21-
* @param string $encryptedMessage
22-
*/
23-
public function __construct(string $tag = null, string $ephemeralPublicKey = null, string $encryptedMessage = null)
18+
public function __construct(?string $tag = null, ?string $ephemeralPublicKey = null, ?string $encryptedMessage = null)
2419
{
2520
$this->tag = $tag;
2621
$this->ephemeralPublicKey = $ephemeralPublicKey;

src/Resources/InstalmentPlan.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace UnzerSDK\Resources;
44

55
use DateTime;
6+
use stdClass;
67
use UnzerSDK\Adapter\HttpAdapterInterface;
78
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
89
use UnzerSDK\Traits\CanAuthorizeWithCustomer;
9-
use stdClass;
1010

1111
/**
1212
* Resource representing the installment plan for Installment Secured.
@@ -77,17 +77,17 @@ class InstalmentPlan extends BasePaymentType
7777
* @param float|null $lastRate
7878
*/
7979
public function __construct(
80-
int $numberOfRates = null,
81-
string $dayOfPurchase = null,
82-
float $totalPurchaseAmount = null,
83-
float $totalInterestAmount = null,
84-
float $totalAmount = null,
85-
float $effectiveInterestRate = null,
86-
float $nominalInterestRate = null,
87-
float $feeFirstRate = null,
88-
float $feePerRate = null,
89-
float $monthlyRate = null,
90-
float $lastRate = null
80+
?int $numberOfRates = null,
81+
?string $dayOfPurchase = null,
82+
?float $totalPurchaseAmount = null,
83+
?float $totalInterestAmount = null,
84+
?float $totalAmount = null,
85+
?float $effectiveInterestRate = null,
86+
?float $nominalInterestRate = null,
87+
?float $feeFirstRate = null,
88+
?float $feePerRate = null,
89+
?float $monthlyRate = null,
90+
?float $lastRate = null
9191
) {
9292
$this->numberOfRates = $numberOfRates;
9393
$this->dayOfPurchase = $dayOfPurchase;

0 commit comments

Comments
 (0)