Skip to content

Optimize cache storage layout for PSR-4/PSR-0 compatibility#574

Merged
lisachenko merged 2 commits into
masterfrom
feature/better-cache-layout
May 13, 2026
Merged

Optimize cache storage layout for PSR-4/PSR-0 compatibility#574
lisachenko merged 2 commits into
masterfrom
feature/better-cache-layout

Conversation

@lisachenko
Copy link
Copy Markdown
Member

@lisachenko lisachenko commented May 13, 2026

Summary

  • Removes the _proxies subdirectory from the cache — proxy class files now reside at their standard PSR-4-compliant path directly in the cache root
  • Transformed source files containing __AopProxied traits are named after the entity they contain (e.g. Foo__AopProxied.php), enabling the cache directory to be registered as a Composer PSR-4/PSR-0 autoload root
  • Simplifies MagicConstantTransformer::resolveFileName() by replacing the old _proxies-stripping logic with a direct cacheDir→appDir remap plus __AopProxied suffix removal
  • CachingTransformer detects woven sources via AOP_PROXIED_SUFFIX presence and adjusts the write path formulaically
  • _functions/ subdirectory is left untouched for a future task
  • Debug weaving command updated to scan cache root (filtering by __AopProxied sibling)

Test plan

  • All 2477 PHPUnit tests pass
  • PHPStan reports no new errors in src/ or tests/
  • Manual: run bin/goaop cache:warmup and verify no _proxies directory created

🤖 Generated with Claude Code

Remove the _proxies subdirectory and flatten the cache layout so proxy
files reside at their PSR-4-compliant path (derived from the original
file location) directly in the cache root. Transformed source files
(containing __AopProxied traits) now use a filename that matches the
entity name, enabling the cache directory to be registered as a
Composer PSR-4/PSR-0 autoload root.

Cache path formulas:
- Proxy: <cacheDir>/<relativePath> (standard, same as original)
- Trait: <cacheDir>/<relativePath>__AopProxied.php (suffix applied
  when transformed source contains AOP_PROXIED_SUFFIX)
- Reverse: strip __AopProxied suffix, remap cacheDir→appDir

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lisachenko lisachenko linked an issue May 13, 2026 that may be closed by this pull request
@lisachenko lisachenko added this to the 4.0.0 milestone May 13, 2026
@lisachenko lisachenko merged commit ee81191 into master May 13, 2026
5 checks passed
@lisachenko lisachenko deleted the feature/better-cache-layout branch May 13, 2026 22: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.

[Improvement] PSR-4 compatible structure of cache files

1 participant