@@ -70,6 +70,7 @@ class AnalyseCommand extends Command
70
70
*/
71
71
public function __construct (
72
72
private array $ composerAutoloaderProjectPaths ,
73
+ private float $ analysisStartTime ,
73
74
)
74
75
{
75
76
parent ::__construct ();
@@ -171,7 +172,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
171
172
172
173
if ($ generateBaselineFile === null && $ allowEmptyBaseline ) {
173
174
$ inceptionResult ->getStdOutput ()->getStyle ()->error ('You must pass the --generate-baseline option alongside --allow-empty-baseline. ' );
174
- return $ inceptionResult ->handleReturn (1 , null );
175
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
175
176
}
176
177
177
178
$ errorOutput = $ inceptionResult ->getErrorOutput ();
@@ -214,13 +215,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
214
215
$ baselineExtension = pathinfo ($ generateBaselineFile , PATHINFO_EXTENSION );
215
216
if ($ baselineExtension === '' ) {
216
217
$ inceptionResult ->getStdOutput ()->getStyle ()->error (sprintf ('Baseline filename must have an extension, %s provided instead. ' , pathinfo ($ generateBaselineFile , PATHINFO_BASENAME )));
217
- return $ inceptionResult ->handleReturn (1 , null );
218
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
218
219
}
219
220
220
221
if (!in_array ($ baselineExtension , ['neon ' , 'php ' ], true )) {
221
222
$ inceptionResult ->getStdOutput ()->getStyle ()->error (sprintf ('Baseline filename extension must be .neon or .php, .%s was used instead. ' , $ baselineExtension ));
222
223
223
- return $ inceptionResult ->handleReturn (1 , null );
224
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
224
225
}
225
226
}
226
227
@@ -244,12 +245,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
244
245
$ inceptionResult ->getErrorOutput ()->getStyle ()->note ('No files found to analyse. ' );
245
246
$ inceptionResult ->getErrorOutput ()->getStyle ()->warning ('This will cause a non-zero exit code in PHPStan 2.0. ' );
246
247
247
- return $ inceptionResult ->handleReturn (0 , null );
248
+ return $ inceptionResult ->handleReturn (0 , null , $ this -> analysisStartTime );
248
249
}
249
250
250
251
$ inceptionResult ->getErrorOutput ()->getStyle ()->error ('No files found to analyse. ' );
251
252
252
- return $ inceptionResult ->handleReturn (1 , null );
253
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
253
254
}
254
255
255
256
$ analysedConfigFiles = array_intersect ($ files , $ container ->getParameter ('allConfigFiles ' ));
@@ -275,7 +276,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
275
276
if ($ fix ) {
276
277
if ($ generateBaselineFile !== null ) {
277
278
$ inceptionResult ->getStdOutput ()->getStyle ()->error ('You cannot pass the --generate-baseline option when running PHPStan Pro. ' );
278
- return $ inceptionResult ->handleReturn (1 , null );
279
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
279
280
}
280
281
281
282
return $ this ->runFixer ($ inceptionResult , $ container , $ onlyFiles , $ input , $ output , $ files );
@@ -331,7 +332,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
331
332
$ previous = $ previous ->getPrevious ();
332
333
}
333
334
334
- return $ inceptionResult ->handleReturn (1 , null );
335
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
335
336
}
336
337
337
338
throw $ t ;
@@ -441,7 +442,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
441
442
count ($ internalErrors ) === 1 ? 'An internal error ' : 'Internal errors ' ,
442
443
));
443
444
444
- return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes ());
445
+ return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes (), $ this -> analysisStartTime );
445
446
}
446
447
447
448
return $ this ->generateBaseline ($ generateBaselineFile , $ inceptionResult , $ analysisResult , $ output , $ allowEmptyBaseline , $ baselineExtension , $ failWithoutResultCache );
@@ -477,6 +478,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
477
478
return $ inceptionResult ->handleReturn (
478
479
$ exitCode ,
479
480
$ analysisResult ->getPeakMemoryUsageBytes (),
481
+ $ this ->analysisStartTime ,
480
482
);
481
483
}
482
484
@@ -528,7 +530,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
528
530
529
531
$ bleedingEdge = (bool ) $ container ->getParameter ('featureToggles ' )['projectServicesNotInAnalysedPaths ' ];
530
532
if ($ bleedingEdge ) {
531
- return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes ());
533
+ return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes (), $ this -> analysisStartTime );
532
534
}
533
535
534
536
$ errorOutput ->getStyle ()->warning ('This will cause a non-zero exit code in PHPStan 2.0. ' );
@@ -540,6 +542,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
540
542
return $ inceptionResult ->handleReturn (
541
543
$ exitCode ,
542
544
$ analysisResult ->getPeakMemoryUsageBytes (),
545
+ $ this ->analysisStartTime ,
543
546
);
544
547
}
545
548
@@ -558,7 +561,7 @@ private function generateBaseline(string $generateBaselineFile, InceptionResult
558
561
$ inceptionResult ->getStdOutput ()->getStyle ()->error ('No errors were found during the analysis. Baseline could not be generated. ' );
559
562
$ inceptionResult ->getStdOutput ()->writeLineFormatted ('To allow generating empty baselines, pass <fg=cyan>--allow-empty-baseline</> option. ' );
560
563
561
- return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes ());
564
+ return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes (), $ this -> analysisStartTime );
562
565
}
563
566
564
567
$ streamOutput = $ this ->createStreamOutput ();
@@ -588,15 +591,15 @@ private function generateBaseline(string $generateBaselineFile, InceptionResult
588
591
} catch (DirectoryCreatorException $ e ) {
589
592
$ inceptionResult ->getStdOutput ()->writeLineFormatted ($ e ->getMessage ());
590
593
591
- return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes ());
594
+ return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes (), $ this -> analysisStartTime );
592
595
}
593
596
594
597
try {
595
598
FileWriter::write ($ generateBaselineFile , $ baselineContents );
596
599
} catch (CouldNotWriteFileException $ e ) {
597
600
$ inceptionResult ->getStdOutput ()->writeLineFormatted ($ e ->getMessage ());
598
601
599
- return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes ());
602
+ return $ inceptionResult ->handleReturn (1 , $ analysisResult ->getPeakMemoryUsageBytes (), $ this -> analysisStartTime );
600
603
}
601
604
602
605
$ errorsCount = 0 ;
@@ -636,7 +639,7 @@ private function generateBaseline(string $generateBaselineFile, InceptionResult
636
639
$ exitCode = 2 ;
637
640
}
638
641
639
- return $ inceptionResult ->handleReturn ($ exitCode , $ analysisResult ->getPeakMemoryUsageBytes ());
642
+ return $ inceptionResult ->handleReturn ($ exitCode , $ analysisResult ->getPeakMemoryUsageBytes (), $ this -> analysisStartTime );
640
643
}
641
644
642
645
/**
@@ -648,7 +651,7 @@ private function runFixer(InceptionResult $inceptionResult, Container $container
648
651
if ($ ciDetector ->isCiDetected ()) {
649
652
$ inceptionResult ->getStdOutput ()->writeLineFormatted ('PHPStan Pro can \'t run in CI environment yet. Stay tuned! ' );
650
653
651
- return $ inceptionResult ->handleReturn (1 , null );
654
+ return $ inceptionResult ->handleReturn (1 , null , $ this -> analysisStartTime );
652
655
}
653
656
654
657
/** @var FixerApplication $fixerApplication */
0 commit comments