Repository navigation
Conversation
DeadCodeRule reads its 5 collectors with iterate() instead of get(). iterate() yields the values of one analysed file at a time. The rule no longer holds all collected data as arrays, and it does not merge the usage arrays with array_merge_recursive(). The rule now reads the usages collector by collector, not file by file. The order of the usages does not change the result. iterate() is new in PHPStan 2.3.6 (phpstan/phpstan-src#6963). Co-Authored-By: Claude Code
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.
Uses
CollectedDataNode::iterate()from phpstan/phpstan-src#6963. The method yields the collected data of one analysed file at a time.Do not merge before PHPStan 2.3.6 is tagged. Then change
^2.3.6@devto^2.3.6and update the lock.Until then, 9 e2e jobs fail on install: the projects in them have
minimum-stability: stable, and@devworks only in the root package.What changes
DeadCodeRulereads its 5 collectors withiterate(), notget().array_merge_recursive().phpstan/phpstanis now required at^2.3.6, becauseiterate()does not exist in older versions. UseAnalysisResult::withFileSpecificErrors()instead of constructor #297 also raised the minimum to use a new API.Measurements
A large private codebase (~30k analysed files), run without changed files (a warm result cache). Peak memory of the main process and wall time. Details are in phpstan/phpstan-src#6963.
iterate()offloadCollectorData: falseFor comparison:
offloadCollectorData: true(the default) with PHPStan with #6963 and DCD withoutiterate()used 3.28 GB, 28 s.With
iterate(), keeping the usages in the collected data takes less memory than the offload store does. A full analysis is different: the fresh data from the workers is still in memory in the main process, sofalseused 4.73 GB against 3.98 GB withtrue. This PR does not change the default.Co-Authored-By: Claude Code