Skip to content

Commit 9581b01

Browse files
ondrejmirtesclaude
andcommitted
Skip the turbo extension lookup on PHP versions it is not built for
The extension is built for PHP >= 8.3 only (the phar.yml turbo-compile matrix), so on older runtimes findExtension() - the process restart and worker spawning - returns before probing the filesystem and /proc/self/maps, and diagnose says why no binary was found. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bBnhEMLHeUbbAENSRYK6u
1 parent 3d18e4d commit 9581b01

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎src/Turbo/TurboDiagnoseExtension.php‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
use PHPStan\Command\Output;
66
use PHPStan\DependencyInjection\AutowiredService;
77
use PHPStan\Diagnose\DiagnoseExtension;
8+
use PHPStan\Php\PhpVersion;
89
use function php_uname;
910
use function phpversion;
1011
use function sprintf;
1112
use const PHP_DEBUG;
1213
use const PHP_MAJOR_VERSION;
1314
use const PHP_MINOR_VERSION;
1415
use const PHP_OS_FAMILY;
16+
use const PHP_VERSION_ID;
1517
use const PHP_ZTS;
1618

1719
#[AutowiredService]
@@ -48,8 +50,15 @@ public function print(Output $output): void
4850
} else {
4951
$workerBinaryLine = 'loaded via php.ini, workers inherit it';
5052
}
53+
} elseif ($workerBinary !== null) {
54+
$workerBinaryLine = $workerBinary;
55+
} elseif (PHP_VERSION_ID < TurboExtensionSelector::MINIMUM_PHP_VERSION_ID) {
56+
$workerBinaryLine = sprintf(
57+
'none built for PHP < %s',
58+
(new PhpVersion(TurboExtensionSelector::MINIMUM_PHP_VERSION_ID))->getVersionString(),
59+
);
5160
} else {
52-
$workerBinaryLine = $workerBinary ?? 'none found';
61+
$workerBinaryLine = 'none found';
5362
}
5463
$output->writeLineFormatted(sprintf(
5564
'<info>Turbo worker binary:</info> %s',

‎src/Turbo/TurboExtensionSelector.php‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use const PHP_MAJOR_VERSION;
1414
use const PHP_MINOR_VERSION;
1515
use const PHP_OS_FAMILY;
16+
use const PHP_VERSION_ID;
1617
use const PHP_ZTS;
1718

1819
/**
@@ -26,7 +27,8 @@
2627
* Windows) by the phar.yml commit job, so they only exist for phar-based
2728
* installations —
2829
* a source checkout loads its locally built extension through php.ini
29-
* instead. Only non-debug builds are shipped; ZTS variants (-zts filename
30+
* instead. Only non-debug builds for PHP >= MINIMUM_PHP_VERSION_ID are
31+
* shipped; ZTS variants (-zts filename
3032
* suffix) exist for linux-gnu and Windows so hosts with a thread-safe PHP
3133
* (like PMMP's bundled build) are covered too. Workers run the regular
3234
* entrypoint, so TurboExtensionEnabler still gates activation on the
@@ -39,6 +41,13 @@
3941
final class TurboExtensionSelector
4042
{
4143

44+
/**
45+
* The oldest PHP the extension is built for — the phar.yml turbo-compile
46+
* matrix. Older runtimes have no binary to find, so they skip the lookup
47+
* (and with it the process restart) entirely.
48+
*/
49+
public const MINIMUM_PHP_VERSION_ID = 80300;
50+
4251
public static function findExtensionForWorkers(): ?string
4352
{
4453
if (TurboExtensionEnabler::isLoaded()) {
@@ -63,6 +72,9 @@ public static function findExtensionForWorkers(): ?string
6372
*/
6473
public static function findExtension(): ?string
6574
{
75+
if (PHP_VERSION_ID < self::MINIMUM_PHP_VERSION_ID) {
76+
return null;
77+
}
6678
if ((bool) PHP_DEBUG) {
6779
return null;
6880
}

0 commit comments

Comments
 (0)