Skip to content

refactor: use the 8.3 features that carry weight - #35

Merged
refsz merged 1 commit into
mainfrom
refactor/php-83-features-on-main
Aug 19, 2026
Merged

refactor: use the 8.3 features that carry weight#35
refsz merged 1 commit into
mainfrom
refactor/php-83-features-on-main

Conversation

@refsz

@refsz refsz commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Re-target of #34, whose content never reached main. Its base branch (build/require-php-83) was squashed into main as #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 onto main; #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_SHELL in EnvironmentDetector had 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 via doWrite() directly, bypassing the write() and writeln() 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:

PHP Fatal error: Sputnik\Secret\RedactingConsoleSectionOutput::overwriteTypo()
has #[\Override] attribute, but no matching parent method exists

That is from actually renaming one override and watching the class refuse to load, then reverting.

Deliberately not included

  • Typing every existing constant. PHPStan already infers precise types from literals; a sweep would touch a dozen files for style alone.
  • Rewriting 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 throws Cannot modify readonly property. new self(...) is correct and stays.

Verification

vendor/bin/phpunit          742 tests, 1281 assertions, OK
vendor/bin/phpstan analyse  [OK] No errors

🤖 Generated with Claude Code

https://claude.ai/code/session_018CTvnzcNYmFgm2HQcm821A

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.
@refsz
refsz merged commit c524c43 into main Aug 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant