Repository navigation
Conversation
Every object description kept the full syntax tree of its file for the rest of the run, though after describing the object only Blueprint::getUsagePathAndLines() reads it, to locate a violation. The factory now empties stmts, and the violation lookup parses that one file again when a test fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
The red checks here aren't from this change: every job stops at
Either of these should fix it:
|
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.
What:
Description:
Every object description keeps the full php-parser syntax tree of its file (
stmts), andObjectsRepositorykeeps the descriptions until the process ends. Once the description is built, only one place reads the tree:Blueprint::getUsagePathAndLines(), which uses it to find the line of a violation. The tree takes up most of a description's memory. On a Laravel 13 app with 1,609 files underapp/anddatabase/, the descriptions take 198 MB, and 185 MB of that is the trees.With this change,
ObjectDescriptionFactoryemptiesstmtsonce the object is described, asObjectsStoragein ta-tikoma/phpunit-architecture-test already does. When a test fails,getUsagePathAndLines()parses that one file again. Passing runs don't parse anything extra.Numbers come from that app on PHP 8.5.11 with opcache off in the CLI. The single expectation was measured with
memory_get_peak_usage(true). The suite figure is the highest memory PHPUnit's event log reports after a test.expect('App\Providers')->not->toBeUsed()alonephpandsecuritypresetsI added a test that checks a described object no longer holds the tree. The existing
toThrowArchitectureViolationtests, such as the native functions inToBeUsedInNothing, check that a violation still reports the right file and line. The 5 tests that already fail on5.xand Rector's change tosrc/Support/UserDefinedFunctions.phpfail with or without this change.This works separately from #41, which stops the same file from being described once per namespace. This change makes each description small instead. They touch different files and apply cleanly together. With both applied, the suite above peaks at 123 MB.
Related:
pestphp/pest#1947, #41
🤖 Generated with Claude Code