Skip to content

Finish audit process cleanup: retire extract() idiom, harden cache flushing - #619

Merged
lisachenko merged 1 commit into
masterfrom
claude/php85-framework-audit-js2kzq
Aug 29, 2026
Merged

Finish audit process cleanup: retire extract() idiom, harden cache flushing#619
lisachenko merged 1 commit into
masterfrom
claude/php85-framework-audit-js2kzq

Conversation

@lisachenko

@lisachenko lisachenko commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

The remaining process-cleanup items from the PHP 8.5 audit (one commit).

  • FilterInjectorTransformer::rewrite(): the static $appDir, $cacheDir, $debug; locals populated via extract(self::$options, EXTR_IF_EXISTS) are replaced with typed array reads of the set-once self::$options (KernelOptions shape guarantees the keys) — analyzable by PHPStan, no variable materialization magic.
  • MagicConstantTransformer: the duplicated constructor / on-demand path bootstrap is deduplicated into one configurePaths() helper; behavior identical (the on-demand path is still required because resolveFileName() runs from woven code where no transformer object exists).
  • CachePathManager: pending cache records are now flushed from a shutdown function registered at construction, which runs while the runtime environment is still fully intact — instead of relying solely on __destruct(), whose ordering during shutdown is unspecified. The destructor remains as a safety net for managers released mid-request, and both teardown paths go through flushSilently(): an exception escaping a destructor or shutdown callback would be fatal, while losing one cache write just means the next request re-weaves. Explicit flushCacheState() calls keep their normal error behavior.
  • SourceTransformingLoader's set-once statics were reviewed and left as-is: a PHP stream filter is instantiated by the engine itself, so static collaborators wired in ensureRegistered() are inherent to the mechanism, and they are already typed and documented.

Issue #618 (lazy-ghost evaluation for constructor interception) is deliberately not part of this PR — it stays open as a decision item with an evaluation plan on the issue.

Test evidence

Gate Result
php8.5 vendor/bin/phpunit OK — 2584 tests, 3147 assertions
php8.4 vendor/bin/phpunit OK — 2584 tests, 10 skipped (8.5-only)
php8.5 / php8.4 vendor/bin/phpstan analyze (level 10) No errors
php8.6 vendor/bin/phpunit (informational, 8.6.0beta2) OK — 2584 tests

Fixes #610

Remaining items from the audit process cleanup:
- FilterInjectorTransformer::rewrite() reads its options through typed
  array access instead of static locals populated via extract()
- MagicConstantTransformer deduplicates the constructor and on-demand
  path bootstrap into one configurePaths() helper
- CachePathManager flushes pending cache records from a shutdown
  function registered at construction, while the runtime environment is
  still intact; the destructor stays as a safety net and neither path
  can propagate an exception out of teardown

Fixes #610

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WFMYyvE4hYRUoMS8mtKrHP
@lisachenko
lisachenko force-pushed the claude/php85-framework-audit-js2kzq branch from 0d7414d to 9f92bc8 Compare August 29, 2026 12:43
@lisachenko lisachenko changed the title Finish audit cleanup: retire extract() idiom, harden cache flushing, document #618 decision Finish audit process cleanup: retire extract() idiom, harden cache flushing Aug 29, 2026
@lisachenko
lisachenko marked this pull request as ready for review August 29, 2026 12:45
@lisachenko
lisachenko merged commit 55b6a98 into master Aug 29, 2026
8 checks passed
@lisachenko
lisachenko deleted the claude/php85-framework-audit-js2kzq branch August 29, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Process/cleanup: dead PARAMETER_WIDENING flag, orphaned test fixtures, lost golden coverage, PHPStan on 8.5 in CI

2 participants