2
2
3
3
namespace PHPStan \Command ;
4
4
5
+ use OndraM \CiDetector \CiDetector ;
5
6
use Symfony \Component \Console \Helper \ProgressBar ;
6
7
use Symfony \Component \Console \Input \InputInterface ;
7
8
use Symfony \Component \Console \Output \OutputInterface ;
@@ -17,12 +18,25 @@ class ErrorsConsoleStyle extends \Symfony\Component\Console\Style\SymfonyStyle
17
18
/** @var \Symfony\Component\Console\Helper\ProgressBar */
18
19
private $ progressBar ;
19
20
21
+ /** @var bool|null */
22
+ private $ isCiDetected ;
23
+
20
24
public function __construct (InputInterface $ input , OutputInterface $ output )
21
25
{
22
26
parent ::__construct ($ input , $ output );
23
27
$ this ->showProgress = $ input ->hasOption (self ::OPTION_NO_PROGRESS ) && !(bool ) $ input ->getOption (self ::OPTION_NO_PROGRESS );
24
28
}
25
29
30
+ private function isCiDetected (): bool
31
+ {
32
+ if ($ this ->isCiDetected === null ) {
33
+ $ ciDetector = new CiDetector ();
34
+ $ this ->isCiDetected = $ ciDetector ->isCiDetected ();
35
+ }
36
+
37
+ return $ this ->isCiDetected ;
38
+ }
39
+
26
40
/**
27
41
* @param string[] $headers
28
42
* @param string[][] $rows
@@ -68,7 +82,7 @@ public function table(array $headers, array $rows): void
68
82
public function createProgressBar ($ max = 0 ): ProgressBar
69
83
{
70
84
$ this ->progressBar = parent ::createProgressBar ($ max );
71
- $ this ->progressBar ->setOverwrite (true );
85
+ $ this ->progressBar ->setOverwrite (! $ this -> isCiDetected () );
72
86
return $ this ->progressBar ;
73
87
}
74
88
@@ -93,7 +107,8 @@ public function progressAdvance($step = 1): void
93
107
if (!$ this ->showProgress ) {
94
108
return ;
95
109
}
96
- if ($ step > 0 ) {
110
+
111
+ if (!$ this ->isCiDetected () && $ step > 0 ) {
97
112
$ stepTime = (time () - $ this ->progressBar ->getStartTime ()) / $ step ;
98
113
if ($ stepTime > 0 && $ stepTime < 1 ) {
99
114
$ this ->progressBar ->setRedrawFrequency ((int ) (1 / $ stepTime ));
@@ -102,7 +117,7 @@ public function progressAdvance($step = 1): void
102
117
}
103
118
}
104
119
105
- $ this -> progressBar -> setProgress ( $ this -> progressBar -> getProgress () + $ step );
120
+ parent :: progressAdvance ( $ step );
106
121
}
107
122
108
123
public function progressFinish (): void
0 commit comments