Skip to content

fix: explicit nullable parameters for PHP 8.4 compatibility#55

Open
chrismshea wants to merge 1 commit into
mainfrom
fix/php84-implicit-nullable-parameters
Open

fix: explicit nullable parameters for PHP 8.4 compatibility#55
chrismshea wants to merge 1 commit into
mainfrom
fix/php84-implicit-nullable-parameters

Conversation

@chrismshea

Copy link
Copy Markdown

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_DEPRECATED notices into thrown exceptions. Any bin/magento CLI command that loads this SDK (via subscribepro/subscribepro-magento2-ext) aborts before producing output. Affected commands include setup:upgrade, deploy:mode:show, index:status, and module:status.

Changes

13 occurrences updated across:

  • src/SubscribePro/Exception/HttpException.php__construct(..., ?Exception $previous = null)
  • src/SubscribePro/Service/AbstractService.phpretrieveItem(..., ?DataInterface $item = null) and 9 corresponding @method docblock annotations in service classes
  • src/SubscribePro/Service/Subscription/SubscriptionService.phpsaveSubscription(..., ?array $metadata = null)
  • src/SubscribePro/Service/Transaction/TransactionService.php — 5 methods (verifyAndStoreToken, authorizeByToken, purchaseByToken, capture, credit)
  • src/SubscribePro/Service/Transaction/Transaction.php and TransactionInterface.phpgetTokenFormData(?AddressInterface $address = null)

Compatibility

?Type $arg = null is fully backward-compatible with the previous signature for both callers and subclasses. No behavior change; this is purely a syntax modernization.

Verification

  • php -l clean across all modified files on PHP 8.4.21
  • Functional smoke test: SDK constructs all services and builds data objects (Address/Customer/Product/Subscription) without emitting any deprecation notices
  • Integration test in subscribepro-magento2-ext sandbox (Magento 2.4.8 + PHP 8.4.21, developer mode, stock app/bootstrap.php) confirms bin/magento setup:upgrade, deploy:mode:show, index:status, and module:status now run to completion with no output noise

Pairs with subscribepro-magento2-ext#XXX.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant