fix: explicit nullable parameters for PHP 8.4 compatibility#55
Open
chrismshea wants to merge 1 commit into
Open
fix: explicit nullable parameters for PHP 8.4 compatibility#55chrismshea wants to merge 1 commit into
chrismshea wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PHP 8.4 deprecates implicit-nullable parameters (
Type $arg = null) — the explicit nullable syntax (?Type $arg = null) is now required. This PR adds the?prefix to every typed nullable-default parameter in the SDK.Why this matters
Beyond eventual PHP 9 fatal removal, the immediate impact is in Magento developer mode, where Magento's error handler promotes
E_DEPRECATEDnotices into thrown exceptions. Anybin/magentoCLI command that loads this SDK (viasubscribepro/subscribepro-magento2-ext) aborts before producing output. Affected commands includesetup:upgrade,deploy:mode:show,index:status, andmodule:status.Changes
13 occurrences updated across:
src/SubscribePro/Exception/HttpException.php—__construct(..., ?Exception $previous = null)src/SubscribePro/Service/AbstractService.php—retrieveItem(..., ?DataInterface $item = null)and 9 corresponding@methoddocblock annotations in service classessrc/SubscribePro/Service/Subscription/SubscriptionService.php—saveSubscription(..., ?array $metadata = null)src/SubscribePro/Service/Transaction/TransactionService.php— 5 methods (verifyAndStoreToken,authorizeByToken,purchaseByToken,capture,credit)src/SubscribePro/Service/Transaction/Transaction.phpandTransactionInterface.php—getTokenFormData(?AddressInterface $address = null)Compatibility
?Type $arg = nullis fully backward-compatible with the previous signature for both callers and subclasses. No behavior change; this is purely a syntax modernization.Verification
php -lclean across all modified files on PHP 8.4.21subscribepro-magento2-extsandbox (Magento 2.4.8 + PHP 8.4.21, developer mode, stockapp/bootstrap.php) confirmsbin/magento setup:upgrade,deploy:mode:show,index:status, andmodule:statusnow run to completion with no output noisePairs with
subscribepro-magento2-ext#XXX.