|
5 | 5 | use PHPStan\DependencyInjection\Container;
|
6 | 6 | use PHPStan\File\PathNotFoundException;
|
7 | 7 | use PHPStan\Internal\BytesHelper;
|
| 8 | +use function floor; |
| 9 | +use function implode; |
8 | 10 | use function max;
|
9 | 11 | use function memory_get_peak_usage;
|
10 | 12 | use function microtime;
|
@@ -97,12 +99,29 @@ public function handleReturn(int $exitCode, ?int $peakMemoryUsageBytes, float $a
|
97 | 99 |
|
98 | 100 | if ($this->getErrorOutput()->isDebug()) {
|
99 | 101 | $this->getErrorOutput()->writeLineFormatted(sprintf(
|
100 | | - 'Analysis time: %0.1f seconds', |
101 | | - round(microtime(true) - $analysisStartTime, 1), |
| 102 | + 'Analysis time: %s', |
| 103 | + $this->formatDuration((int) round(microtime(true) - $analysisStartTime)), |
102 | 104 | ));
|
103 | 105 | }
|
104 | 106 |
|
105 | 107 | return $exitCode;
|
106 | 108 | }
|
107 | 109 |
|
| 110 | + private function formatDuration(int $seconds): string |
| 111 | + { |
| 112 | + $minutes = (int) floor($seconds / 60); |
| 113 | + $remainingSeconds = $seconds % 60; |
| 114 | + |
| 115 | + $result = []; |
| 116 | + if ($minutes > 0) { |
| 117 | + $result[] = $minutes . ' minute' . ($minutes > 1 ? 's' : ''); |
| 118 | + } |
| 119 | + |
| 120 | + if ($remainingSeconds > 0) { |
| 121 | + $result[] = $remainingSeconds . ' second' . ($remainingSeconds > 1 ? 's' : ''); |
| 122 | + } |
| 123 | + |
| 124 | + return implode('', $result); |
| 125 | + } |
| 126 | + |
108 | 127 | }
|
0 commit comments