refactor: use the 8.3 features that carry weight - #35
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 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.
Re-target of #34, whose content never reached
main. Its base branch (build/require-php-83) was squashed intomainas #33, so merging #34 merged it into a branch that no longer feeds anywhere — the same mistake as #31 earlier today, and mine for stacking a second time instead of waiting for the base. Same commit, cherry-picked ontomain; #34 needs no further action.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. The masking leak found earlier today was exactly a method that no longer matched its parent:ConsoleSectionOutput::overwrite()takes a path 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 is from actually renaming one override and watching the class refuse to load, then reverting.
Deliberately not included
withFormatter()as a clone. I claimed in build!: require PHP 8.3 #33 that 8.3 makes this possible, then checked: readonly properties may be reinitialised only inside__clone(), which cannot receive the new value. Outside it PHP still throwsCannot modify readonly property.new self(...)is correct and stays.Verification
🤖 Generated with Claude Code
https://claude.ai/code/session_018CTvnzcNYmFgm2HQcm821A