Repository navigation
Tell the user when a phar runs without the Turbo extension - #6719
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| * it, on a runtime the extension is built for, and no php.ini loads the | ||
| * extension either. | ||
| */ | ||
| public static function isMissingNextToPhar(): bool |
There was a problem hiding this comment.
I think we should only error for php-runtime-versions which are compatible with turbo
There was a problem hiding this comment.
hmm should it share most logic with findExtension?
There was a problem hiding this comment.
Done in 5a24d48: both methods now share one helper. The note only shows where findExtension() would look for a binary. That means PHP 8.3 or newer, not a debug build, a phar, and a platform with binaries.
There is no upper bound yet, in either method. A bare phar on a future PHP 8.7 would show the note before an 8.7 binary exists. Should I add one?
| $phpstanVersion = ComposerHelper::getPhpStanVersion(); | ||
| $errorOutput->getStyle()->note(sprintf( | ||
| 'PHPStan runs without its Turbo extension.' . "\n" | ||
| . 'With the extension, PHPStan is up to 60%% faster.' . "\n" |
There was a problem hiding this comment.
I don't think we should mention the "60%" here, as this number will likely change in the future again
There was a problem hiding this comment.
Ondřej asked for the number when he suggested this note, so I kept it. I'll drop it if he prefers.
| 'PHPStan runs without its Turbo extension.' . "\n" | ||
| . 'With the extension, PHPStan is up to 60%% faster.' . "\n" | ||
| . 'Install PHPStan with Composer: composer require --dev phpstan/phpstan' . "\n" | ||
| . 'Or install the extension with PIE: pie install %s', |
There was a problem hiding this comment.
at best mention the full "pie install" command for easy copy/paste
There was a problem hiding this comment.
It prints the full command already. A release includes the version, for example pie install phpstan/turbo:2.3.1, so it can be copied as is. Only a dev build gets plain phpstan/turbo, because a version like 2.3.x-dev@df607f6 is not a phpstan/turbo release.
| } elseif (TurboExtensionSelector::isMissingNextToPhar()) { | ||
| $phpstanVersion = ComposerHelper::getPhpStanVersion(); | ||
| $errorOutput->getStyle()->note(sprintf( | ||
| 'PHPStan runs without its Turbo extension.' . "\n" |
There was a problem hiding this comment.
I would try to name it "PHPStan Turbo" which feels to me like the proper product-name
There was a problem hiding this comment.
Done in 827a912: all four lines say PHPStan Turbo now.
|
needs e2e test |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Added in 827a912: the |
| # the compiler-tests job runs the phar on PHP 8.2, where no binary exists | ||
| # and the note is not printed | ||
| - name: "Install PHP" | ||
| uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # 2.40.0 |
There was a problem hiding this comment.
This is the same shivammathur/setup-php action, pinned to the same commit, that phar.yml already uses in 13 other steps. The new job needs PHP 8.3 or newer, so it installs PHP the same way as the other jobs.
|
Thank you! |
When
phpstan.pharruns without theturbo-ext/directory next to it, PHPStan Turbo does not load. Nothing tells the user. This happens when a tool downloads only the phar from the release, for example TomasVotruba/need-for-speed#9 and shivammathur/setup-php#1132.analysenow prints a note right after the existing note about an incompatible extension version:The note appears only when all of these are true:
turbo-ext/directory next to the phar.So a Composer install never shows it, even on a PHP version without a binary yet, and neither does a run from source. On a host without pcntl, the workers still get the extension, and the directory exists, so the note does not show there either. The PIE command includes the PHPStan version, because the extension version must match. A dev build gets plain
phpstan/turbo. The runtime checks are shared withfindExtension(), so the note and the extension lookup agree on which runtimes can have a binary.The new
turbo-missing-notejob inphar.ymlruns the built phar twice on PHP 8.4. Alone, it must print the note. With aturbo-ext/directory next to it, it must not.compiler-testsruns the phar on PHP 8.2, below the minimum, so it cannot cover this. The job's script fails against the 2.3.1 phar, which has no note.I also built a phar from this branch and ran
analysewith it:turbo-ext/of 2.3.1 next to it: no note, anddiagnosesays "Turbo extension: enabled".diagnosesays "Turbo extension: enabled".make testsandmake phpstanpass, and phpcs reports no errors on the two changed files.One thing I found on the way, not changed here. An extension loaded with
php -d extension=...does not survive the OPcache restart inTurboProcessRestarter. The restart passes on only the main php.ini,memory_limitand its own flags. On 2.3.1,php -d extension=<turbo> phpstan.phar diagnosereports "not loaded".🤖 Generated with Claude Code