feat: support PHP 8.1 via #[ScopeShared] attribute - #5
Merged
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
Lower the minimum PHP version to 8.1. Since `readonly class` and ReflectionClass::isReadOnly() are 8.2-only, add a #[ScopeShared] attribute that opts a service out of per-scope cloning explicitly, so the same instance is shared across the whole scope tree on any supported version. State::clone() now shares a service when it is an enum, a readonly class (8.2+), or carries #[ScopeShared]. Refs #4 Assisted-By: Claude Opus 4.8 (1M context)
roxblnfk
force-pushed
the
feat/php-8.1-support
branch
from
September 8, 2026 09:17
a3c7efd to
b483030
Compare
Merged
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.
🔍 What was changed
Lowers the minimum PHP version to 8.1 and adds a
#[ScopeShared]attribute (TARGET_CLASS, no parameters) that marks a service to be shared across scopes instead of cloned per-scope.State::clone()now shares a cached service with the child scope when it is an enum, a readonly class (guarded byPHP_VERSION_ID >= 80200), or carries#[ScopeShared].composer.jsonandpsalm.xmlare moved to 8.1.Why?
Scope cloning already shares immutable services with the parent instead of cloning them, detecting them via
ReflectionClass::isReadOnly(). Bothreadonly classand that reflection method are 8.2-only, so on 8.1 there was no way to mark a service as safe-to-share.#[ScopeShared]provides that in a version-independent way — and also covers classes that are immutable in practice but not declaredreadonly.Checklist
Review notes
CI still runs on 8.2+ only: Testo does not support 8.1 yet (blocked by php-testo/testo#322). Adding 8.1 to the matrix is tracked separately in #6.