feat: PSR-4 compatible cache structure for generated proxy files#568
Draft
feat: PSR-4 compatible cache structure for generated proxy files#568
Conversation
- WeavingTransformer.saveProxyToCache() now generates proxy files at PSR-4 paths (<cacheDir>/<Namespace/ClassName>.php) instead of the old convoluted <cacheDir>/_proxies/<original-file-path>/<FQCN>.php layout - Each generated proxy file includes a MagicConstantTransformer::registerProxyFile() call at the end so that wrapped ReflectionClass::getFileName() calls in woven sources correctly resolve back to the original source path at runtime - MagicConstantTransformer gains a static $proxyFileMap registry and registerProxyFile() / resolveFileName() updated to use it with portable relative paths - DebugWeavingCommand.getProxies() now scans the full cacheDir instead of the removed _proxies/ subdirectory, filtered by \Go\Aop\Proxy presence - Update woven snapshot files (*-woven.php) with new include_once paths - Update proxy snapshot files (*-proxy.php) with registerProxyFile() footer - ClassWovenConstraint, ClassIsNotWovenConstraint, ProxyClassReflectionHelper already updated to use PSR-4 paths in earlier commits Agent-Logs-Url: https://github.com/goaop/framework/sessions/0600c407-30da-4f37-81df-a43730e6099d Co-authored-by: lisachenko <640114+lisachenko@users.noreply.github.com>
- Normalize both appDir and classFileName to forward slashes in WeavingTransformer::saveProxyToCache() for cross-platform correctness - Normalize rootPath to forward slashes in MagicConstantTransformer::resolveFileName() - Escape literal dot in AOP_CACHE_DIR regex patterns in WeavingTransformerTest Agent-Logs-Url: https://github.com/goaop/framework/sessions/0600c407-30da-4f37-81df-a43730e6099d Co-authored-by: lisachenko <640114+lisachenko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor cache files to adhere to PSR-4 structure
feat: PSR-4 compatible cache structure for generated proxy files
Apr 30, 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.
Cache files were generated under a convoluted
_proxies/<original-relative-path>/<FQCN>.phplayout that encoded the source file path rather than the class identity, making the cache directory unusable as a PSR-4 autoloader root and breaking correctness when classes are renamed or moved.Proxy file path layout
Before:
<cacheDir>/_proxies/src/Application/Main.php/Go/Tests/TestProject/Application/Main.phpAfter:
<cacheDir>/Go/Tests/TestProject/Application/Main.phpEach proxy file now lives at a path derived purely from its FQCN, matching PSR-4 conventions.
ReflectionClass::getFileName()on proxy classesWith PSR-4 paths the proxy location no longer encodes the source path, so
MagicConstantTransformer::resolveFileName()needed a new mechanism. Each generated proxy file now ends with a self-registration call:MagicConstantTransformergains a static$proxyFileMapregistry populated atinclude_oncetime, givingresolveFileName()an O(1) lookup before falling back to the existing cache-dir→app-dir path substitution for woven files.DebugWeavingCommandproxy discoveryReplaced the hardcoded
_proxies/subdirectory scan with a recursive scan of the fullcacheDir, filtering on the presence of\Go\Aop\Proxyin file content. The filter is broadened fromimplements \Go\Aop\Proxyto just\Go\Aop\Proxyto correctly match classes that implement additional interfaces before the proxy marker.Cross-platform path handling
Both
saveProxyToCache()andresolveFileName()normalize paths to forward slashes before computing relative paths so that Windows backslash paths fromReflectionClass::getFileName()are handled correctly.Test/snapshot updates
*-woven.phpsnapshot files updated with newinclude_once AOP_CACHE_DIR . '/Ns/ClassName.php'paths.*-proxy.phpsnapshot files updated with theregisterProxyFile()footer.WeavingTransformerTestfixed to escape the literal PHP concatenation dot (\.).