Keep the pre-autoloader turbo code polyfill-free and skip the extension lookup on PHP < 8.3 - #6319
Merged
Merged
Conversation
…sWithRequiresPhpAttributeRule The rule threw ShouldNotHappenException for any TestCase method whose first statement is an if with a non-comparison binary operator in its condition, such as if ($a || $b). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012bBnhEMLHeUbbAENSRYK6u
ondrejmirtes
force-pushed
the
turbo-restart-php74
branch
from
August 31, 2026 14:36
6229090 to
8e00f4f
Compare
| # the phar boots through the turbo restart code, which bin/phpstan | ||
| # loads before the Composer autoloader - on PHP < 8.0 without the | ||
| # symfony polyfills (https://github.com/phpstan/phpstan/issues/15137). | ||
| uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # v2.37.2 |
…-free bin/phpstan requires TurboExtensionEnabler, TurboExtensionSelector and TurboProcessRestarter and calls restartIfSuitable() before vendor/autoload.php, so the symfony polyfills are not registered yet when they run. The str_contains() in resolveIsMusl() fataled the phar on PHP 7.4 hosts with pcntl - on Linux only, where /proc/self/maps exists. PreAutoloadFilesTest derives the files bin/phpstan loads before the autoloader and the functions vendor/symfony/polyfill-* declares, and fails on any call. The new phar-run job runs the compiled phar on PHP 7.4-8.5 with pcntl available: the phpstan/phpstan e2e jobs use setup-php's ini-file: development, which lists the pcntl functions in disable_functions, so the restarter returned before ever reaching findExtension() there. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012bBnhEMLHeUbbAENSRYK6u
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 <[email protected]> Claude-Session: https://claude.ai/code/session_012bBnhEMLHeUbbAENSRYK6u
ondrejmirtes
force-pushed
the
turbo-restart-php74
branch
from
August 31, 2026 15:05
8e00f4f to
cbc2ff8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bin/phpstanrequires the turbo restart classes and callsTurboProcessRestarter::restartIfSuitable()beforevendor/autoload.php, so the symfony polyfills are not registered yet when they run. 51d272f putstr_contains()intoTurboExtensionSelector::resolveIsMusl(), which fatals the phar on PHP 7.4 hosts with pcntl — reached on Linux only, where/proc/self/mapsexists:Nothing in CI caught it: the phpstan/phpstan e2e jobs that run the phar on 7.4 use setup-php's
ini-file: development, which lists the pcntl functions indisable_functions, so the restarter returned before ever callingfindExtension().TurboExtensionSelector::findExtension()returns early on PHP < 8.3 (MINIMUM_PHP_VERSION_ID, the turbo-compile matrix floor): there is no binary to find, so neither the restart nor worker spawning probes the filesystem there, anddiagnosesays so.resolveIsMusl()usesstrpos();PreAutoloadFilesTestderives the filesbin/phpstanloads before the autoloader and fails on any call to a function declared byvendor/symfony/polyfill-*— the same class of crash would hit PHP 8.3 with the extension loaded for a polyfill-php84/85 function, which no e2e run exercises.phar-runjob in phar.yml runs the compiled phar (--version+analyse -vvvone2e/phar-run) on PHP 7.4–8.5 with pcntl available, assertingpcntl_execexists so it cannot pass vacuously. Reproduced locally in Dockerphp:7.4-cli+ pcntl: the unfixed phar fatals exactly as above; a phar with only the version gate passes, as does the full change.SkipTestsWithRequiresPhpAttributeRulethrewShouldNotHappenExceptionfor a test method whose first statement isif ($a || $b); thePHP_VERSION_IDchecks now precede the operator switch (with a test).Closes phpstan/phpstan#15137
🤖 Generated with Claude Code
https://claude.ai/code/session_012bBnhEMLHeUbbAENSRYK6u