Open
Conversation
PHP 8.5 promotes several previously-deprecated coercions to errors, notably casting non-scalar values to string. This hardens type handling in places where mixed/untyped values flow into typed APIs. - ViewModel/SpeculationRules::getConfigValue: guard mixed scopeConfig return with is_scalar before casting to string - ViewModel/SpeculationRules::getSpeculationRulesJson: handle SerializerInterface::serialize returning false - ViewModel/ViewTransitions::getConfigValue: same guard as above - Plugin/Framework/App/Response/Http: narrow getHeader() result with instanceof checks (Laminas returns false|HeaderInterface|ArrayIterator; removeDirective is on CacheControl, not HeaderInterface) - Plugin/Framework/App/Response/Http::getConfig: same scalar guard - Setup/Patch/Data/UpdateSpeculationRulesConfigPathPatch::apply: return \$this to match PatchInterface contract Verified with phpstan level 9 (clean) and existing unit tests (41/41). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
PHP 8.5 promotes several previously-deprecated coercions to errors — notably casting non-scalar values to string. This PR hardens type handling in places where
mixed/ untyped values flow into typed APIs, so the module is forward-compatible.ViewModel/SpeculationRules::getConfigValue— guard themixedscopeConfig->getValue()result withis_scalarbefore casting to string. Previously a non-scalar config value (rare, but possible via custom backends) would fatal in PHP 8.5.ViewModel/SpeculationRules::getSpeculationRulesJson— handleSerializerInterface::serialize()returningfalse. The interface return isstring|false; the method signature promisedstring.ViewModel/ViewTransitions::getConfigValue— same scalar guard as above.Plugin/Framework/App/Response/Http— narrowgetHeader()result withinstanceofchecks. LaminasHeaders::get()returnsfalse|HeaderInterface|ArrayIterator; the previousif (!$header)only ruled outfalse, leavingArrayIteratorcallable as if it were aHeaderInterface.removeDirective()lives onCacheControl, notHeaderInterface, so the second narrowing uses that concrete class. Also dropped a redundant secondgetHeader()call inafterSetNoCacheHeaders.Plugin/Framework/App/Response/Http::getConfig— same scalar guard before casting to string.Setup/Patch/Data/UpdateSpeculationRulesConfigPathPatch::apply— return$thisto matchPatchInterfacedocblock (@return $this). Not a PHP 8.5 issue per se, but caught by phpstan and trivial to align.Verification
phpstanlevel 9 against the module — clean (was 8 errors before)phpunitagainstapp/code/MageOS/ThemeOptimization/phpunit.xml.dist— 41/41 passTest plan
setup:upgradestill appliesUpdateSpeculationRulesConfigPathPatchcleanly🤖 Generated with Claude Code