From 782896fc5f084298f99c22d235bff9567c151939 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Mon, 26 Oct 2026 11:43:52 +0100 Subject: [PATCH] Run the test suite with PHPStan Turbo in CI The tests job loads the PHPStan Turbo extension from php.ini, so the fastunit workers and the processes that the tests start all get it. tests/bootstrap.php activates Turbo before preload.php when the extension is loaded. Without the extension nothing changes. --- .github/workflows/tests.yaml | 8 ++++++++ tests/bootstrap.php | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 58f2834a1f3..e7d050f9d3d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -36,4 +36,12 @@ jobs: - uses: "ramsey/composer-install@v4" + # load PHPStan Turbo from php.ini, so every PHP process of the test suite has it + - + name: Load PHPStan Turbo + run: | + EXTENSION=$(php -r 'require "vendor/autoload.php"; echo PHPStan\Turbo\TurboExtensionSelector::findExtensionForWorkers();') + echo "extension=$EXTENSION" | sudo tee "$(php -r 'echo PHP_CONFIG_FILE_SCAN_DIR;')/99-phpstan-turbo.ini" + php -r 'exit(extension_loaded("phpstan_turbo") ? 0 : 1);' + - run: vendor/bin/fastunit tests rules-tests utils/phpstan/tests diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 800fd015f78..cb7bd710f93 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,6 +2,17 @@ declare(strict_types=1); +use PHPStan\PharAutoloader; +use PHPStan\Turbo\TurboExtensionEnabler; + +// PHPStan Turbo replaces php-parser classes, so it is activated before preload.php declares them +if (extension_loaded('phpstan_turbo')) { + require_once __DIR__ . '/../vendor/autoload.php'; + TurboExtensionEnabler::activateIfCompatible( + dirname((string) new ReflectionClass(PharAutoloader::class)->getFileName()) . '/phpstan.phar' + ); +} + // make local php-parser a priority to avoid conflict require_once __DIR__ . '/../preload.php'; require_once __DIR__ . '/../vendor/autoload.php';