Add PHP 8.4 and PHP 8.5 compatibility#26
Merged
Conversation
rhoerr
requested changes
Apr 30, 2026
marcelmtz
previously requested changes
Apr 30, 2026
marcelmtz
left a comment
There was a problem hiding this comment.
I didn't find anything critical but the version conflict with the const tyep declared, once we take a decision with that, we can proceed
- Drop typed class constants (`const string`/`const array`) for PHP 8.1/8.2 compatibility per composer.json constraint. - Restore docblock and inline comments removed across Http, BfCache, SpeculationRules, and UpdateSpeculationRulesConfigPathPatch. - Revert the array_map refactors in SpeculationRules::getExcludedExtensions() and getExcludedSelectors() to the original foreach style for readability. - Update CHANGELOG to drop the typed-const note. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Replace `@dataProvider` PHPDoc annotations with `#[DataProvider]` attributes (PHPUnit 12 dropped the doctype form, which caused testIsEnabled and testGetEagerness to be invoked with no arguments). - Make the two data-provider methods static (PHPUnit 12 requirement). - Type the variant `$configValue` parameter as `mixed`. - Migrate `phpunit.xml.dist` to the current schema (drops `verbose` attribute, adds `cacheDirectory`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Updated release date for version 2.3.0 and added new features and improvements.
rhoerr
approved these changes
May 12, 2026
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
This PR adds PHP 8.4 and PHP 8.5 compatibility to
MageOS_ThemeOptimizationwhile keeping the module working on PHP 8.1/8.2/8.3.Current last tag:
2.2.0. Suggested next tag:2.3.0(backwards-compatible additions/changes only).cc @rhoerr
Changes
declare(strict_types=1)to every PHP class in the module (previously missing onViewTransitions,SpeculationRules,UpdateSpeculationRulesConfigPathPatch).Setup\Patch\Data\UpdateSpeculationRulesConfigPathPatch::apply(),getAliases()andgetDependencies(), so subclasses and static analysis don't fall back on the implicit-nullable/void deprecations introduced in PHP 8.4.const string,const array) onViewTransitions,SpeculationRules,BfCacheand theHttpplugin to take advantage of PHP 8.3+ typed constants.int|string|null $storeinHttp::getConfig()) so PHP 8.4's "implicit nullable parameter is deprecated" warning doesn't trigger.afterSetNoCacheHeadersnow usesmixed $result/mixedreturn type instead of an untyped parameter.strpos($theme->getCode(), 'Hyva/') === 0withstr_starts_with()inSpeculationRules::isHyva().protected(instead ofprivate) on every class, and private helpers (isHyva,isRequestCacheable,isRequestInExcludePatterns,parseExcludePatterns,isEnabled,getConfig) are alsoprotected, so downstream modules/themes can extend the behavior without plugins.array_mapin place of manualforeach-and-append loops inSpeculationRules::getExcludedExtensions()/getExcludedSelectors();unset($pattern)after the foreach-by-reference loop ingetExcludedPaths(); re-importedMagento\Framework\App\Response\HttpasResponseHttpin the plugin so the fully-qualified-name isn't repeated in method signatures.composer.json: added an explicitphpconstraint~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0.CHANGELOG.mdwith a2.3.0 — 2026-04-21entry.Backwards compatibility
@return).DataPatchInterface::apply()doesn't declare a return type in Magento framework (its PHPDoc says@return $this); the concreteapply()now declares: selfandreturn $this, which is covariance-compatible with the interface.private->protected), so no downstream break.Test plan
composer installand module registration on PHP 8.1, 8.3, 8.4 and 8.5.vendor/bin/phpunit Test/Unit) on PHP 8.4 and 8.5.no-storeon cacheable responses.error_reporting(E_ALL)on PHP 8.4 / 8.5.Suggested release
Tag
2.3.0(minor bump — only additive/internal changes, no public API break).