Skip to content

Commit 4af7cdf

Browse files
authored
Merge pull request #28 from utopia-php/fix/php84-nullables
Fix explicit nullable types for PHP 8.4+ deprecations
2 parents 8032d55 + 7b20f28 commit 4af7cdf

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/Pay/Adapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ abstract public function cancelAuthorization(string $paymentId, array $additiona
123123
* @param array<mixed> $additionalParams Additional parameters (optional)
124124
* @return array<mixed> Result of the update
125125
*/
126-
abstract public function updatePayment(string $paymentId, ?string $paymentMethodId = null, ?int $amount = null, string $currency = null, array $additionalParams = []): array;
126+
abstract public function updatePayment(string $paymentId, ?string $paymentMethodId = null, ?int $amount = null, ?string $currency = null, array $additionalParams = []): array;
127127

128128
/**
129129
* Retry a purchase for a payment intent
@@ -143,7 +143,7 @@ abstract public function retryPurchase(string $paymentId, ?string $paymentMethod
143143
* @param string $reason
144144
* @return array<mixed>
145145
*/
146-
abstract public function refund(string $paymentId, int $amount = null, string $reason = null): array;
146+
abstract public function refund(string $paymentId, ?int $amount = null, ?string $reason = null): array;
147147

148148
/**
149149
* Get a payment details
@@ -173,7 +173,7 @@ abstract public function createPaymentMethod(string $customerId, string $type, a
173173
* @param array<mixed>|null $address
174174
* @return array<mixed>
175175
*/
176-
abstract public function updatePaymentMethodBillingDetails(string $paymentMethodId, string $name = null, string $email = null, string $phone = null, array $address = null): array;
176+
abstract public function updatePaymentMethodBillingDetails(string $paymentMethodId, ?string $name = null, ?string $email = null, ?string $phone = null, ?array $address = null): array;
177177

178178
/**
179179
* Update payment method
@@ -210,7 +210,7 @@ abstract public function deletePaymentMethod(string $paymentMethodId): bool;
210210
* @param string|null $paymentMethod
211211
* @return array<mixed>
212212
*/
213-
abstract public function createCustomer(string $name, string $email, array $address = [], string $paymentMethod = null): array;
213+
abstract public function createCustomer(string $name, string $email, array $address = [], ?string $paymentMethod = null): array;
214214

215215
/**
216216
* List customers
@@ -237,7 +237,7 @@ abstract public function getCustomer(string $customerId): array;
237237
* @param string|null $paymentMethod
238238
* @return array<mixed>
239239
*/
240-
abstract public function updateCustomer(string $customerId, string $name, string $email, Address $address = null, string $paymentMethod = null): array;
240+
abstract public function updateCustomer(string $customerId, string $name, string $email, ?Address $address = null, ?string $paymentMethod = null): array;
241241

242242
/**
243243
* Delete Customer

src/Pay/Adapter/Stripe.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function retryPurchase(string $paymentId, ?string $paymentMethodId = null
126126
/**
127127
* Refund payment
128128
*/
129-
public function refund(string $paymentId, int $amount = null, string $reason = null): array
129+
public function refund(string $paymentId, ?int $amount = null, ?string $reason = null): array
130130
{
131131
$path = '/refunds';
132132
$requestBody = ['payment_intent' => $paymentId];
@@ -164,7 +164,7 @@ public function getPayment(string $paymentId): array
164164
* @param array<mixed> $additionalParams Additional parameters (optional)
165165
* @return array<mixed> Result of the update
166166
*/
167-
public function updatePayment(string $paymentId, ?string $paymentMethodId = null, ?int $amount = null, string $currency = null, array $additionalParams = []): array
167+
public function updatePayment(string $paymentId, ?string $paymentMethodId = null, ?int $amount = null, ?string $currency = null, array $additionalParams = []): array
168168
{
169169
$path = '/payment_intents/'.$paymentId;
170170
$requestBody = [];
@@ -236,7 +236,7 @@ public function getPaymentMethod(string $customerId, string $paymentMethodId): a
236236
* @param array<mixed>|null $address
237237
* @return array<mixed>
238238
*/
239-
public function updatePaymentMethodBillingDetails(string $paymentMethodId, string $name = null, string $email = null, string $phone = null, array $address = null): array
239+
public function updatePaymentMethodBillingDetails(string $paymentMethodId, ?string $name = null, ?string $email = null, ?string $phone = null, ?array $address = null): array
240240
{
241241
$path = '/payment_methods/'.$paymentMethodId;
242242
$requestBody = [];
@@ -285,7 +285,7 @@ public function deletePaymentMethod(string $paymentMethodId): bool
285285
*
286286
* @throws \Exception
287287
*/
288-
public function createCustomer(string $name, string $email, array $address = [], string $paymentMethod = null): array
288+
public function createCustomer(string $name, string $email, array $address = [], ?string $paymentMethod = null): array
289289
{
290290
$path = '/customers';
291291
$requestBody = [
@@ -325,7 +325,7 @@ public function getCustomer(string $customerId): array
325325
/**
326326
* Update customer details
327327
*/
328-
public function updateCustomer(string $customerId, string $name, string $email, Address $address = null, string $paymentMethod = null): array
328+
public function updateCustomer(string $customerId, string $name, string $email, ?Address $address = null, ?string $paymentMethod = null): array
329329
{
330330
$path = '/customers/'.$customerId;
331331
$requestBody = [

src/Pay/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Address
4747
*/
4848
protected ?string $state;
4949

50-
public function __construct(string $city, string $country, string $line1 = null, string $line2 = null, string $postalCode = null, string $state = null)
50+
public function __construct(string $city, string $country, ?string $line1 = null, ?string $line2 = null, ?string $postalCode = null, ?string $state = null)
5151
{
5252
$this->city = $city;
5353
$this->country = $country;

src/Pay/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Exception extends \Exception
2323
*/
2424
protected array $metadata = [];
2525

26-
public function __construct(string $type = Exception::GENERAL_UNKNOWN, string $message = null, int $code = null, array $metadata = [], \Throwable $previous = null)
26+
public function __construct(string $type = Exception::GENERAL_UNKNOWN, ?string $message = null, ?int $code = null, array $metadata = [], ?\Throwable $previous = null)
2727
{
2828
$this->type = $type;
2929
$this->code = $code ?? 500;

src/Pay/Pay.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getCurrency(): string
8181
* @param array<mixed> $additionalParams
8282
* @return array<mixed>
8383
*/
84-
public function purchase(int $amount, string $customerId, string $paymentMethodId = null, array $additionalParams = []): array
84+
public function purchase(int $amount, string $customerId, ?string $paymentMethodId = null, array $additionalParams = []): array
8585
{
8686
return $this->adapter->purchase($amount, $customerId, $paymentMethodId, $additionalParams);
8787
}
@@ -98,7 +98,7 @@ public function purchase(int $amount, string $customerId, string $paymentMethodI
9898
* @param array<mixed> $additionalParams
9999
* @return array<mixed>
100100
*/
101-
public function authorize(int $amount, string $customerId, string $paymentMethodId = null, array $additionalParams = []): array
101+
public function authorize(int $amount, string $customerId, ?string $paymentMethodId = null, array $additionalParams = []): array
102102
{
103103
return $this->adapter->authorize($amount, $customerId, $paymentMethodId, $additionalParams);
104104
}
@@ -178,7 +178,7 @@ public function getPayment(string $paymentId): array
178178
* @param array<mixed> $additionalParams Additional parameters (optional)
179179
* @return array<mixed> Result of the update
180180
*/
181-
public function updatePayment(string $paymentId, ?string $paymentMethodId = null, ?int $amount = null, string $currency = null, array $additionalParams = []): array
181+
public function updatePayment(string $paymentId, ?string $paymentMethodId = null, ?int $amount = null, ?string $currency = null, array $additionalParams = []): array
182182
{
183183
return $this->adapter->updatePayment($paymentId, $paymentMethodId, $amount, $currency, $additionalParams);
184184
}
@@ -218,7 +218,7 @@ public function createPaymentMethod(string $customerId, string $type, array $det
218218
* @param array<mixed> $address
219219
* @return array<mixed>
220220
*/
221-
public function updatePaymentMethodBillingDetails(string $paymentMethodId, string $type, string $name = null, string $email = null, string $phone = null, array $address = null): array
221+
public function updatePaymentMethodBillingDetails(string $paymentMethodId, string $type, ?string $name = null, ?string $email = null, ?string $phone = null, ?array $address = null): array
222222
{
223223
return $this->adapter->updatePaymentMethodBillingDetails($paymentMethodId, $name, $email, $phone, $address);
224224
}
@@ -307,7 +307,7 @@ public function getCustomer(string $customerId): array
307307
* @param Address $address
308308
* @return array<mixed>
309309
*/
310-
public function updateCustomer(string $customerId, string $name, string $email, Address $address = null, ?string $paymentMethod = null): array
310+
public function updateCustomer(string $customerId, string $name, string $email, ?Address $address = null, ?string $paymentMethod = null): array
311311
{
312312
return $this->adapter->updateCustomer($customerId, $name, $email, $address, $paymentMethod);
313313
}

0 commit comments

Comments
 (0)