Skip to content

fix: explicit nullable parameters for PHP 8.4 compatibility - #305

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

fix: explicit nullable parameters for PHP 8.4 compatibility#305
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 module.

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 aborts before producing output. Affected commands include setup:upgrade, deploy:mode:show, index:status, and module:status — meaning a merchant upgrading to 2.4.8 + PHP 8.4 in developer mode (a normal upgrade workflow) cannot run setup commands at all without this fix or a workaround.

Changes

10 occurrences updated across:

  • Block/Customer/Subscriptions.php — constructor ?Serializer\Json $serializer = null
  • Block/Vault/Edit/BillingAddress.phprender(?PaymentProfileInterface $profile = null)
  • Model/Config/OrderCallback.phpgetSharedSecret(?string $websiteCode = null), isLogEnabled(?string $websiteCode = null)
  • Model/Config/ThirdPartyPayment.phpisAllowed(?int $storeId = null), getAllowedMethods(?int $storeId = null)
  • Platform/Service/Transaction.phpauthorizeByToken, purchaseByToken, capture, credit (4 ?AddressInterface/?TransactionInterface parameters)
  • Service/OrderCallback/ResponseProcessor.phpexecute(..., ?OrderInterface $order = 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 240+ module PHP files on PHP 8.4.21
  • Reproduced reporter's symptom in a sandbox (Magento 2.4.8 + PHP 8.4.21, developer mode, stock app/bootstrap.php with error_reporting(E_ALL)): bin/magento commands abort with no output
  • After patch applied: all four affected commands run to completion with no deprecation notices in output
  • All 17 core SP module classes resolve cleanly through Magento's DI

Dependency

Pairs with subscribepro/subscribepro-php#XX (SDK has 13 of its own deprecations that surface independently). Both PRs are required to fully resolve developer-mode CLI noise; merging only one leaves the other repo's deprecations active.

PHP 8.4 deprecates implicit-nullable parameters (`Type $arg = null`)
and requires explicit nullable syntax (`?Type $arg = null`). In
Magento developer mode (which promotes E_DEPRECATED to thrown
exceptions) these notices cause bin/magento CLI commands to abort
before producing output (setup:upgrade, deploy:mode:show,
index:status, module:status all affected).

Updated 10 occurrences across:
- Block/Customer/Subscriptions.php
- Block/Vault/Edit/BillingAddress.php
- Model/Config/{OrderCallback,ThirdPartyPayment}.php
- Platform/Service/Transaction.php
- Service/OrderCallback/ResponseProcessor.php

Verified on Magento 2.4.8 + PHP 8.4.21 with developer mode and stock
app/bootstrap.php (error_reporting(E_ALL)). All four affected CLI
commands now run to completion with no output noise.
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