refactor: use the 8.3 features that carry weight - #34
Merged
Conversation
Restores the typed class constant in EnvironmentDetector that had to be reverted under 8.2, and marks the redacting decorators' overrides with #[Override]. The attribute is not decoration here: a masking leak found earlier today was exactly a method that no longer matched its parent - ConsoleSectionOutput's decorated overwrite() path bypassed write() and writeln(), and nothing failed. With #[Override], a renamed or resignatured Symfony method is a fatal error at load time instead of output that quietly stops being redacted. Verified by renaming one override and watching the class refuse to load. Deliberately not included: typing every existing constant, which would be a style sweep with no analytical gain, and rewriting withFormatter() as a clone - 8.3 permits reinitialising readonly properties only inside __clone(), which cannot receive the new value, so the current constructor call stays correct.
This was referenced Aug 19, 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.
Follow-up to #33, kept separate so the version bump stays mechanical. Merge #33 first; GitHub retargets this to
main.Two changes, both with a reason beyond "8.3 allows it":
The typed class constant comes back.
private const array DEFAULT_SHELLinEnvironmentDetectorhad to lose its type under 8.2, with PHPStan naming the reason.#[Override]on the redacting decorators. This is not decoration. The masking leak found earlier today was exactly a method that no longer matched its parent:ConsoleSectionOutput::overwrite()takes a cursor-rewind path on a decorated terminal that writes viadoWrite()directly, bypassing thewrite()andwriteln()overrides — and nothing failed, output just quietly stopped being redacted. I found it by reading Symfony's source, which is not a strategy.With the attribute, a renamed or resignatured parent method is a fatal error at load time:
That output is from actually renaming one override and watching the class refuse to load, then reverting. It is the cheapest possible guard on the six methods where a silent mismatch means a secret reaches the terminal.
Deliberately not included
withFormatter()as a clone. I claimed in build!: require PHP 8.3 #33 that 8.3 makes this possible and then checked it: readonly properties may be reinitialised only inside__clone(), which cannot receive the new value. Outside it, PHP still throwsCannot modify readonly property. The existingnew self(...)is correct and stays.Verification
🤖 Generated with Claude Code
https://claude.ai/code/session_018CTvnzcNYmFgm2HQcm821A