|
2 | 2 |
|
3 | 3 | namespace PHPStan\Process\Restart; |
4 | 4 |
|
5 | | -use PHPStan\Php\PhpVersion; |
6 | 5 | use PHPStan\Turbo\TurboExtensionSelector; |
7 | 6 | use function array_key_exists; |
8 | 7 | use function explode; |
|
12 | 11 | use function getenv; |
13 | 12 | use function in_array; |
14 | 13 | use function ini_get; |
| 14 | +use function intdiv; |
15 | 15 | use function phpversion; |
16 | 16 | use function sprintf; |
17 | 17 | use function str_replace; |
@@ -217,7 +217,7 @@ public static function collectReasonsFor( |
217 | 217 | ) { |
218 | 218 | $reasons[] = new RestartReason( |
219 | 219 | 'tideways', |
220 | | - sprintf('crashes the turbo extension on PHP %s, %s', (new PhpVersion($phpVersionId))->getVersionString(), self::TIDEWAYS_FIX_DESCRIPTION), |
| 220 | + sprintf('crashes the turbo extension on PHP %s, %s', self::describePhpVersion($phpVersionId), self::TIDEWAYS_FIX_DESCRIPTION), |
221 | 221 | strippedExtensions: ['tideways'], |
222 | 222 | ); |
223 | 223 | } |
@@ -279,7 +279,7 @@ public static function describeDetectedExtensions(): array |
279 | 279 | ? 'tideways %s (unloaded wherever the turbo extension runs: crashes it on PHP %s, ' . self::TIDEWAYS_FIX_DESCRIPTION . ')' |
280 | 280 | : 'tideways %s (kept next to the turbo extension: PHP %s is not affected by the crash)', |
281 | 281 | self::describeVersion('tideways'), |
282 | | - (new PhpVersion(PHP_VERSION_ID))->getVersionString(), |
| 282 | + self::describePhpVersion(PHP_VERSION_ID), |
283 | 283 | ); |
284 | 284 | } |
285 | 285 |
|
@@ -356,6 +356,15 @@ private static function isAffectedByTidewaysCrash(int $phpVersionId): bool |
356 | 356 | || ($phpVersionId >= 80400 && $phpVersionId < 80403); |
357 | 357 | } |
358 | 358 |
|
| 359 | + /** |
| 360 | + * Formatted here rather than by PhpVersion: this class runs in bin/phpstan |
| 361 | + * before the autoloader is registered. |
| 362 | + */ |
| 363 | + private static function describePhpVersion(int $phpVersionId): string |
| 364 | + { |
| 365 | + return sprintf('%d.%d.%d', intdiv($phpVersionId, 10000), intdiv($phpVersionId, 100) % 100, $phpVersionId % 100); |
| 366 | + } |
| 367 | + |
359 | 368 | private static function isForkCapable(): bool |
360 | 369 | { |
361 | 370 | return function_exists('pcntl_fork') |
|
0 commit comments