Skip to content

Add PHP 8.4 and 8.5 compatibility#11

Merged
rhoerr merged 1 commit into
mage-os:mainfrom
SamueleMartini:php85-compatibility
May 1, 2026
Merged

Add PHP 8.4 and 8.5 compatibility#11
rhoerr merged 1 commit into
mage-os:mainfrom
SamueleMartini:php85-compatibility

Conversation

@SamueleMartini
Copy link
Copy Markdown
Contributor

@SamueleMartini SamueleMartini commented Apr 21, 2026

Summary

Adds PHP 8.4 and 8.5 compatibility to the module. Changes are fully backward compatible with PHP 8.2 and 8.3.

Changes

  • Plugin/ThemeAdminhtmlSwitcherPlugin.php: added explicit nullable types (?string $area = null) to comply with PHP 8.4 deprecation of implicit nullable parameters; added : array return type; promoted property visibility to protected; extracted config path to a class constant.
  • Model/Config/Source/AdminThemeList.php: promoted $themeList property visibility to protected; extracted magic string Magento/backend to a class constant; simplified title computation with a ternary; trimmed redundant PHPDoc descriptions.
  • composer.json: added explicit PHP constraint ~8.2.0||~8.3.0||~8.4.0||~8.5.0.
  • CHANGELOG.md: new 1.2.1 entry dated 2026-04-21.

PHP 8.4 rationale

PHP 8.4 deprecates implicit nullable parameter types — any parameter with a non-null type hint and a null default must be declared explicitly nullable (?Type). The upstream Magento\Theme\Model\View\Design::setDesignTheme($theme, $area = null) is not typed, but $area in the plugin's beforeSetDesignTheme is a string-or-null, so an explicit ?string is the safe and future-proof signature. $themeId is kept as mixed because the underlying method accepts both string theme paths and ThemeInterface objects.

PHP 8.5

No code changes were required specifically for 8.5 — the same typed signatures are forward compatible.

Suggested release

I'd suggest tagging this as 1.2.1 (patch — compatibility fix, no functional changes).

Test plan

  • composer install on a Magento 2 / Mage-OS instance running PHP 8.4
  • composer install on a Magento 2 / Mage-OS instance running PHP 8.5 (when available)
  • Verify admin theme selection in Stores > Configuration > Advanced > Admin > Admin Design lists all installed admin themes
  • Verify the selected admin theme is applied in the backend

cc @rhoerr for review.

@SamueleMartini SamueleMartini requested review from a team and artKozynets as code owners April 21, 2026 17:03
Copy link
Copy Markdown
Contributor

@rhoerr rhoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@rhoerr rhoerr merged commit 40d67d5 into mage-os:main May 1, 2026
1 check failed
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