Fix phpstan/phpstan#14073: Performance - list the most-often-analysed trait files in -vvv (DiagnoseExtension)#5395
Conversation
|
I just wonder if a new feature like this should be approved by ondrej @staabm. Also if we should directly count in the |
I think we cannot save much because the path strings are already allocated at the analyzer level and collecting them in an array shouldn't add much more. |
bbba77e to
cd1c978
Compare
| use function sprintf; | ||
|
|
||
| #[AutowiredService] | ||
| final class ProcessedFilesDiagnoseExtension implements DiagnoseExtension |
There was a problem hiding this comment.
instead of having this separate DiagnoseExtension the logic could be merged into PHPStanDiagnoseExtension
There was a problem hiding this comment.
Not sure if it was meant to the bot, but I don't think it handle this feedback since you approved the PR
There was a problem hiding this comment.
The make tests background task also completed successfully. All checks pass.
There was a problem hiding this comment.
The changes are already pushed to the remote. The commit 023dddf0b contains exactly the same changes I made — merging ProcessedFilesDiagnoseExtension into PHPStanDiagnoseExtension, updating the service config, and removing the separate class and its test.
The review feedback from staabm has been addressed:
- Removed the separate
ProcessedFilesDiagnoseExtensionclass - Merged the "most often analysed files" diagnostic output into
PHPStanDiagnoseExtension - Added
ProcessedFilesCollectorandRelativePathHelperas constructor dependencies - Updated
conf/services.neonto passsimpleRelativePathHelper - Removed the now-unnecessary test file
- Both
make phpstanandmake testspass cleanly
|
I think it handles the comment because of me @staabm #5395 (comment) Do you want to revert it then? |
|
Lets wait for ondrejs opinion |
- Added ProcessedFilesCollector service to accumulate processed files during analysis - Added TraitAnalysisDiagnoseExtension to print top 5 most-analysed files in -vvv output - Modified WorkerCommand to send processedFiles in parallel worker JSON responses - Modified ParallelAnalyser to pass processedFiles through postFileCallback - Modified AnalyseApplication to collect processedFiles in both debug and non-debug modes - Added unit tests for ProcessedFilesCollector and TraitAnalysisDiagnoseExtension
Address review feedback: instead of having a separate DiagnoseExtension for processed files, merge the logic into the existing PHPStanDiagnoseExtension. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
023dddf to
38aef23
Compare
Implements the feature requested in phpstan/phpstan#14073: when running PHPStan with
-vvv, the diagnostic output now includes the top 5 most-often-analysed files (typically trait files). This helps detect performance issues like the one found in Shopware where trait files were analysed an excessive number of times.Fixes phpstan/phpstan#14073
running this PR on wordpress-develop