Skip to content

Conversation

@mohaelmrabet
Copy link

This Pull Request fixes a PHP 8.4 compatibility issue occurring in the Run/Grid/Collection and related grid collection classes.

PHP 8.3+ deprecates implicitly nullable parameters when a parameter defaults to null but is not explicitly typed as nullable.
Magento 2.4.8+ and PHP 8.4+ trigger the following deprecated warning:

Deprecated Functionality: Implicitly marking parameter $resource as nullable is deprecated,
the explicit nullable type must be used instead

This happens because the constructor declares:

\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null

Instead of:

?\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null

What this PR does

  • Explicitly marks the $resource and $connection parameters as nullable
  • Fixes all affected Grid Collection classes to ensure PHP 8.4 compatibility
  • Prevents deprecated warnings when running Magento CLI commands (e.g. bin/magento c:f)
  • Aligns with Magento’s strict typing guidelines introduced in recent versions

Why this change is needed

Magento 2.4.x now requires PHP 8.3+ compatibility.
Without this fix, Algolia’s Magento module triggers repeated deprecated notices, particularly on CLI usage and in admin grids.

This PR ensures full compatibility with PHP’s updated typing rules.

Testing

  • Tested on Magento 2.4.6-p3 with PHP 8.4
  • No deprecated warnings after the fix
  • Indexer and admin grids load correctly
  • Algolia indexing continues to work as expected

Backward compatibility

  • This update is backward-safe:
  • Nullable typehints are compatible with older PHP versions
  • No breaking changes to public API signatures
  • No behavioral changes to the module

@damcou
Copy link
Contributor

damcou commented Nov 26, 2025

Hello @mohaelmrabet and thanks for your contribution !

We will look at it ASAP and it will be added to our next release if it gets approved.
Thanks again !

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.

2 participants