46
46
* file_references_to_missing_class_members: array<string, array<string,bool>>,
47
47
* mixed_counts: array<string, array{0: int, 1: int}>,
48
48
* mixed_member_names: array<string, array<string, bool>>,
49
+ * function_timings: array<string, float>,
49
50
* file_manipulations: array<string, FileManipulation[]>,
50
51
* method_references_to_class_members: array<string, array<string,bool>>,
51
52
* method_references_to_missing_class_members: array<string, array<string,bool>>,
@@ -108,6 +109,13 @@ class Analyzer
108
109
*/
109
110
private $ count_mixed = true ;
110
111
112
+ /**
113
+ * Used to store debug performance data
114
+ *
115
+ * @var array<string, float>
116
+ */
117
+ private $ function_timings = [];
118
+
111
119
/**
112
120
* We analyze more files than we necessarily report errors in
113
121
*
@@ -316,7 +324,7 @@ function (string $file_path) : bool {
316
324
}
317
325
}
318
326
319
- private function doAnalysis (ProjectAnalyzer $ project_analyzer , int $ pool_size, bool $ rerun = false ) : void
327
+ private function doAnalysis (ProjectAnalyzer $ project_analyzer , int $ pool_size ) : void
320
328
{
321
329
$ this ->progress ->start (count ($ this ->files_to_analyze ));
322
330
@@ -426,7 +434,7 @@ function () {
426
434
},
427
435
$ analysis_worker ,
428
436
/** @return WorkerData */
429
- function () use ( $ rerun ) {
437
+ function () {
430
438
$ project_analyzer = ProjectAnalyzer::getInstance ();
431
439
$ codebase = $ project_analyzer ->getCodebase ();
432
440
$ analyzer = $ codebase ->analyzer ;
@@ -438,22 +446,23 @@ function () use ($rerun) {
438
446
return [
439
447
'issues ' => IssueBuffer::getIssuesData (),
440
448
'fixable_issue_counts ' => IssueBuffer::getFixableIssues (),
441
- 'nonmethod_references_to_classes ' => $ rerun ? [] : $ file_reference_provider ->getAllNonMethodReferencesToClasses (),
442
- 'method_references_to_classes ' => $ rerun ? [] : $ file_reference_provider ->getAllMethodReferencesToClasses (),
443
- 'file_references_to_class_members ' => $ rerun ? [] : $ file_reference_provider ->getAllFileReferencesToClassMembers (),
444
- 'method_references_to_class_members ' => $ rerun ? [] : $ file_reference_provider ->getAllMethodReferencesToClassMembers (),
445
- 'file_references_to_missing_class_members ' => $ rerun ? [] : $ file_reference_provider ->getAllFileReferencesToMissingClassMembers (),
446
- 'method_references_to_missing_class_members ' => $ rerun ? [] : $ file_reference_provider ->getAllMethodReferencesToMissingClassMembers (),
447
- 'method_param_uses ' => $ rerun ? [] : $ file_reference_provider ->getAllMethodParamUses (),
448
- 'mixed_member_names ' => $ rerun ? [] : $ analyzer ->getMixedMemberNames (),
449
- 'file_manipulations ' => $ rerun ? [] : FileManipulationBuffer::getAll (),
450
- 'mixed_counts ' => $ rerun ? [] : $ analyzer ->getMixedCounts (),
451
- 'analyzed_methods ' => $ rerun ? [] : $ analyzer ->getAnalyzedMethods (),
452
- 'file_maps ' => $ rerun ? [] : $ analyzer ->getFileMaps (),
453
- 'class_locations ' => $ rerun ? [] : $ file_reference_provider ->getAllClassLocations (),
454
- 'class_method_locations ' => $ rerun ? [] : $ file_reference_provider ->getAllClassMethodLocations (),
455
- 'class_property_locations ' => $ rerun ? [] : $ file_reference_provider ->getAllClassPropertyLocations (),
456
- 'possible_method_param_types ' => $ rerun ? [] : $ analyzer ->getPossibleMethodParamTypes (),
449
+ 'nonmethod_references_to_classes ' => $ file_reference_provider ->getAllNonMethodReferencesToClasses (),
450
+ 'method_references_to_classes ' => $ file_reference_provider ->getAllMethodReferencesToClasses (),
451
+ 'file_references_to_class_members ' => $ file_reference_provider ->getAllFileReferencesToClassMembers (),
452
+ 'method_references_to_class_members ' => $ file_reference_provider ->getAllMethodReferencesToClassMembers (),
453
+ 'file_references_to_missing_class_members ' => $ file_reference_provider ->getAllFileReferencesToMissingClassMembers (),
454
+ 'method_references_to_missing_class_members ' => $ file_reference_provider ->getAllMethodReferencesToMissingClassMembers (),
455
+ 'method_param_uses ' => $ file_reference_provider ->getAllMethodParamUses (),
456
+ 'mixed_member_names ' => $ analyzer ->getMixedMemberNames (),
457
+ 'file_manipulations ' => FileManipulationBuffer::getAll (),
458
+ 'mixed_counts ' => $ analyzer ->getMixedCounts (),
459
+ 'function_timings ' => $ analyzer ->getFunctionTimings (),
460
+ 'analyzed_methods ' => $ analyzer ->getAnalyzedMethods (),
461
+ 'file_maps ' => $ analyzer ->getFileMaps (),
462
+ 'class_locations ' => $ file_reference_provider ->getAllClassLocations (),
463
+ 'class_method_locations ' => $ file_reference_provider ->getAllClassMethodLocations (),
464
+ 'class_property_locations ' => $ file_reference_provider ->getAllClassPropertyLocations (),
465
+ 'possible_method_param_types ' => $ analyzer ->getPossibleMethodParamTypes (),
457
466
'taint_data ' => $ codebase ->taint ,
458
467
'unused_suppressions ' => $ codebase ->track_unused_suppressions ? IssueBuffer::getUnusedSuppressions () : [],
459
468
'used_suppressions ' => $ codebase ->track_unused_suppressions ? IssueBuffer::getUsedSuppressions () : [],
@@ -486,10 +495,6 @@ function () use ($rerun) {
486
495
$ codebase ->taint ->addThreadData ($ pool_data ['taint_data ' ]);
487
496
}
488
497
489
- if ($ rerun ) {
490
- continue ;
491
- }
492
-
493
498
$ codebase ->file_reference_provider ->addNonMethodReferencesToClasses (
494
499
$ pool_data ['nonmethod_references_to_classes ' ]
495
500
);
@@ -514,6 +519,7 @@ function () use ($rerun) {
514
519
$ this ->addMixedMemberNames (
515
520
$ pool_data ['mixed_member_names ' ]
516
521
);
522
+ $ this ->function_timings += $ pool_data ['function_timings ' ];
517
523
$ codebase ->file_reference_provider ->addClassLocations (
518
524
$ pool_data ['class_locations ' ]
519
525
);
@@ -1145,6 +1151,19 @@ public function getMixedCounts()
1145
1151
return array_intersect_key ($ this ->mixed_counts , $ all_deep_scanned_files );
1146
1152
}
1147
1153
1154
+ /**
1155
+ * @return array<string, float>
1156
+ */
1157
+ public function getFunctionTimings ()
1158
+ {
1159
+ return $ this ->function_timings ;
1160
+ }
1161
+
1162
+ public function addFunctionTiming (string $ function_id , float $ time_per_node ) : void
1163
+ {
1164
+ $ this ->function_timings [$ function_id ] = $ time_per_node ;
1165
+ }
1166
+
1148
1167
/**
1149
1168
* @return void
1150
1169
*/
0 commit comments