From 8f7cfe40e5a0824d2416b04065cfaec5e5ef66fb Mon Sep 17 00:00:00 2001 From: Chris Shea Date: Tue, 9 Jun 2026 17:37:50 +0000 Subject: [PATCH] fix: explicit nullable parameters for PHP 8.4 compatibility PHP 8.4 deprecates implicit-nullable parameters (`Type $arg = null`) and requires explicit nullable syntax (`?Type $arg = null`). Failure to suppress E_DEPRECATED in Magento developer mode causes CLI commands that load this SDK to abort with no output. Updated 13 occurrences across: - Exception/HttpException.php - Service/AbstractService.php (and 9 @method docblock annotations) - Service/Subscription/SubscriptionService.php - Service/Transaction/{Transaction,TransactionInterface,TransactionService}.php No behavior change; signatures remain compatible. --- src/SubscribePro/Exception/HttpException.php | 2 +- src/SubscribePro/Service/AbstractService.php | 2 +- src/SubscribePro/Service/Address/AddressService.php | 2 +- .../Service/Customer/CustomerService.php | 2 +- .../Service/PaymentProfile/PaymentProfileService.php | 2 +- src/SubscribePro/Service/Product/ProductService.php | 2 +- .../Service/SalesOrder/SalesOrderService.php | 2 +- .../Service/Subscription/SubscriptionService.php | 4 ++-- src/SubscribePro/Service/Token/TokenService.php | 2 +- src/SubscribePro/Service/Transaction/Transaction.php | 2 +- .../Service/Transaction/TransactionInterface.php | 2 +- .../Service/Transaction/TransactionService.php | 12 ++++++------ src/SubscribePro/Service/Webhook/WebhookService.php | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/SubscribePro/Exception/HttpException.php b/src/SubscribePro/Exception/HttpException.php index 13b7cea..5bd1038 100644 --- a/src/SubscribePro/Exception/HttpException.php +++ b/src/SubscribePro/Exception/HttpException.php @@ -17,7 +17,7 @@ class HttpException extends \RuntimeException * @param int $code * @param Exception|null $previous */ - public function __construct(ResponseInterface $response, $code = 0, Exception $previous = null) + public function __construct(ResponseInterface $response, $code = 0, ?Exception $previous = null) { parent::__construct($this->getErrorMessage($response), $code, $previous); diff --git a/src/SubscribePro/Service/AbstractService.php b/src/SubscribePro/Service/AbstractService.php index c839874..178b480 100644 --- a/src/SubscribePro/Service/AbstractService.php +++ b/src/SubscribePro/Service/AbstractService.php @@ -45,7 +45,7 @@ public function __construct(Http $http, DataFactoryInterface $factory, array $co * * @return \SubscribePro\Service\DataInterface */ - protected function retrieveItem($response, $entityName, DataInterface $item = null) + protected function retrieveItem($response, $entityName, ?DataInterface $item = null) { $itemData = !empty($response[$entityName]) ? $response[$entityName] : []; $item = $item ? $item->importData($itemData) : $this->dataFactory->create($itemData); diff --git a/src/SubscribePro/Service/Address/AddressService.php b/src/SubscribePro/Service/Address/AddressService.php index fdb24f6..e87d37f 100644 --- a/src/SubscribePro/Service/Address/AddressService.php +++ b/src/SubscribePro/Service/Address/AddressService.php @@ -12,7 +12,7 @@ * * @see \SubscribePro\Service\Address\AddressInterface * - * @method \SubscribePro\Service\Address\AddressInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Address\AddressInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Address\AddressInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Address\AddressFactory $dataFactory diff --git a/src/SubscribePro/Service/Customer/CustomerService.php b/src/SubscribePro/Service/Customer/CustomerService.php index 2af4dfd..a725be7 100644 --- a/src/SubscribePro/Service/Customer/CustomerService.php +++ b/src/SubscribePro/Service/Customer/CustomerService.php @@ -13,7 +13,7 @@ * * @see \SubscribePro\Service\Customer\CustomerInterface * - * @method \SubscribePro\Service\Customer\CustomerInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Customer\CustomerInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Customer\CustomerInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Customer\CustomerFactory $dataFactory diff --git a/src/SubscribePro/Service/PaymentProfile/PaymentProfileService.php b/src/SubscribePro/Service/PaymentProfile/PaymentProfileService.php index 84dc15c..0c2dfa7 100644 --- a/src/SubscribePro/Service/PaymentProfile/PaymentProfileService.php +++ b/src/SubscribePro/Service/PaymentProfile/PaymentProfileService.php @@ -14,7 +14,7 @@ * * @see \SubscribePro\Service\PaymentProfile\PaymentProfileInterface * - * @method \SubscribePro\Service\PaymentProfile\PaymentProfileInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\PaymentProfile\PaymentProfileInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\PaymentProfile\PaymentProfileInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\PaymentProfile\PaymentProfileFactory $dataFactory diff --git a/src/SubscribePro/Service/Product/ProductService.php b/src/SubscribePro/Service/Product/ProductService.php index 541ec80..57d409f 100644 --- a/src/SubscribePro/Service/Product/ProductService.php +++ b/src/SubscribePro/Service/Product/ProductService.php @@ -12,7 +12,7 @@ * * @see \SubscribePro\Service\Product\ProductInterface * - * @method \SubscribePro\Service\Product\ProductInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Product\ProductInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Product\ProductInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Product\ProductFactory $dataFactory diff --git a/src/SubscribePro/Service/SalesOrder/SalesOrderService.php b/src/SubscribePro/Service/SalesOrder/SalesOrderService.php index 02384bc..9d19ab5 100644 --- a/src/SubscribePro/Service/SalesOrder/SalesOrderService.php +++ b/src/SubscribePro/Service/SalesOrder/SalesOrderService.php @@ -12,7 +12,7 @@ * * @see \SubscribePro\Service\SalesOrder\SalesOrderInterface * - * @method \SubscribePro\Service\SalesOrder\SalesOrderInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\SalesOrder\SalesOrderInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\SalesOrder\SalesOrderInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\SalesOrder\SubscriptionFactory $dataFactory diff --git a/src/SubscribePro/Service/Subscription/SubscriptionService.php b/src/SubscribePro/Service/Subscription/SubscriptionService.php index 542b8d0..6433d53 100644 --- a/src/SubscribePro/Service/Subscription/SubscriptionService.php +++ b/src/SubscribePro/Service/Subscription/SubscriptionService.php @@ -12,7 +12,7 @@ * * @see \SubscribePro\Service\Subscription\SubscriptionInterface * - * @method \SubscribePro\Service\Subscription\SubscriptionInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Subscription\SubscriptionInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Subscription\SubscriptionInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Subscription\SubscriptionFactory $dataFactory @@ -47,7 +47,7 @@ public function createSubscription(array $subscriptionData = []) * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ - public function saveSubscription(SubscriptionInterface $subscription, array $metadata = null) + public function saveSubscription(SubscriptionInterface $subscription, ?array $metadata = null) { $url = $subscription->isNew() ? '/services/v2/subscription.json' : "/services/v2/subscriptions/{$subscription->getId()}.json"; $formData = $subscription->getFormData(); diff --git a/src/SubscribePro/Service/Token/TokenService.php b/src/SubscribePro/Service/Token/TokenService.php index 8c0cde0..11b2446 100644 --- a/src/SubscribePro/Service/Token/TokenService.php +++ b/src/SubscribePro/Service/Token/TokenService.php @@ -12,7 +12,7 @@ * * @see \SubscribePro\Service\Token\TokenInterface * - * @method \SubscribePro\Service\Token\TokenInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Token\TokenInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Token\TokenInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Token\TokenFactory $dataFactory diff --git a/src/SubscribePro/Service/Transaction/Transaction.php b/src/SubscribePro/Service/Transaction/Transaction.php index c786d5a..a30a546 100644 --- a/src/SubscribePro/Service/Transaction/Transaction.php +++ b/src/SubscribePro/Service/Transaction/Transaction.php @@ -105,7 +105,7 @@ public function isVerifyDataValid() * * @return mixed[] */ - public function getTokenFormData(AddressInterface $address = null) + public function getTokenFormData(?AddressInterface $address = null) { $tokenFormData = array_intersect_key($this->data, $this->createTokenFields); if ($address) { diff --git a/src/SubscribePro/Service/Transaction/TransactionInterface.php b/src/SubscribePro/Service/Transaction/TransactionInterface.php index d4dc243..1c113c4 100644 --- a/src/SubscribePro/Service/Transaction/TransactionInterface.php +++ b/src/SubscribePro/Service/Transaction/TransactionInterface.php @@ -103,7 +103,7 @@ public function isServiceDataValid(); * * @return mixed[] */ - public function getTokenFormData(AddressInterface $address = null); + public function getTokenFormData(?AddressInterface $address = null); /** * @return bool diff --git a/src/SubscribePro/Service/Transaction/TransactionService.php b/src/SubscribePro/Service/Transaction/TransactionService.php index c995fc6..dc2f52b 100644 --- a/src/SubscribePro/Service/Transaction/TransactionService.php +++ b/src/SubscribePro/Service/Transaction/TransactionService.php @@ -14,7 +14,7 @@ * * @see \SubscribePro\Service\Transaction\TransactionInterface * - * @method \SubscribePro\Service\Transaction\TransactionInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Transaction\TransactionInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Transaction\TransactionInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Transaction\TransactionFactory $dataFactory @@ -90,7 +90,7 @@ public function verifyProfile($paymentProfileId, TransactionInterface $transacti * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ - public function verifyAndStoreToken($token, TransactionInterface $transaction, AddressInterface $address = null) + public function verifyAndStoreToken($token, TransactionInterface $transaction, ?AddressInterface $address = null) { if (!$transaction->isTokenDataValid()) { throw new EntityInvalidDataException('Not all required Transaction fields are set'); @@ -175,7 +175,7 @@ public function purchaseByProfile($authorizeData, TransactionInterface $transact * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ - public function authorizeByToken($token, TransactionInterface $transaction, AddressInterface $address = null, $metadata = null) + public function authorizeByToken($token, TransactionInterface $transaction, ?AddressInterface $address = null, $metadata = null) { if (!$transaction->isTokenDataValid()) { throw new EntityInvalidDataException('Not all required Transaction fields are set.'); @@ -205,7 +205,7 @@ public function authorizeByToken($token, TransactionInterface $transaction, Addr * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ - public function purchaseByToken($token, TransactionInterface $transaction, AddressInterface $address = null, $metadata = null) + public function purchaseByToken($token, TransactionInterface $transaction, ?AddressInterface $address = null, $metadata = null) { if (!$transaction->isTokenDataValid()) { throw new EntityInvalidDataException('Not all required Transaction fields are set.'); @@ -234,7 +234,7 @@ public function purchaseByToken($token, TransactionInterface $transaction, Addre * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ - public function capture($transactionId, TransactionInterface $transaction = null, $metadata = null) + public function capture($transactionId, ?TransactionInterface $transaction = null, $metadata = null) { if ($transaction && !$transaction->isServiceDataValid()) { throw new EntityInvalidDataException('Currency code not specified for given amount.'); @@ -259,7 +259,7 @@ public function capture($transactionId, TransactionInterface $transaction = null * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ - public function credit($transactionId, TransactionInterface $transaction = null, $metadata = null) + public function credit($transactionId, ?TransactionInterface $transaction = null, $metadata = null) { if ($transaction && !$transaction->isServiceDataValid()) { throw new EntityInvalidDataException('Currency code not specified for given amount.'); diff --git a/src/SubscribePro/Service/Webhook/WebhookService.php b/src/SubscribePro/Service/Webhook/WebhookService.php index 8837d54..1875efe 100644 --- a/src/SubscribePro/Service/Webhook/WebhookService.php +++ b/src/SubscribePro/Service/Webhook/WebhookService.php @@ -21,7 +21,7 @@ * Default value is \SubscribePro\Service\Webhook\Event\Destination\Endpoint * @see \SubscribePro\Service\Webhook\Event\Destination\EndpointInterface * - * @method \SubscribePro\Service\Webhook\EventInterface retrieveItem($response, $entityName, \SubscribePro\Service\DataInterface $item = null) + * @method \SubscribePro\Service\Webhook\EventInterface retrieveItem($response, $entityName, ?\SubscribePro\Service\DataInterface $item = null) * @method \SubscribePro\Service\Webhook\EventInterface[] retrieveItems($response, $entitiesName) * * @property \SubscribePro\Service\Webhook\EventFactory $dataFactory