Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,16 @@ jobs:
exit 1
fi

# another program that loads PHPStan restarts through
# TurboProcessRestarter, and can leave OPcache dormant: the same
# single restart disarms pcov, and no process turns OPcache on
- operating-system: "ubuntu-latest"
coverage: "pcov"
extensions: ""
script: |
php restart-without-opcache.php analyse --no-progress
php check.php restarted-for=pcov pcov-armed=no opcache-cli-on=no processes=2+ starts=2

# --debug restarts like any other run - it only makes the analysis
# serial, --xdebug is what keeps xdebug
- operating-system: "ubuntu-latest"
Expand Down
22 changes: 22 additions & 0 deletions e2e/restart-manager/restart-without-opcache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types = 1);

use PHPStan\Turbo\TurboProcessRestarter;

// Restarts the way another program that loads PHPStan does, Rector for
// example, but without OPcache. bin/phpstan then sees the marker and does not
// restart a second time. The restart classes are loaded by file like in
// bin/phpstan, which needs to be the first to require vendor/autoload.php.
$src = __DIR__ . '/../../src';
require_once $src . '/Turbo/TurboExtensionEnabler.php';
require_once $src . '/Turbo/TurboExtensionSelector.php';
require_once $src . '/Process/Restart/RestartReason.php';
require_once $src . '/Process/Restart/OpcacheSettings.php';
require_once $src . '/Process/Restart/RestartExtensionRegistry.php';
require_once $src . '/Process/Restart/IniComposer.php';
require_once $src . '/Process/Restart/RestartExecutor.php';
require_once $src . '/Process/Restart/RestartManager.php';
require_once $src . '/Turbo/TurboProcessRestarter.php';

TurboProcessRestarter::restartIfSuitable($_SERVER['argv'], null, 'phpstan', false);

require __DIR__ . '/../../bin/phpstan';
23 changes: 22 additions & 1 deletion src/Turbo/TurboProcessRestarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,32 @@ final class TurboProcessRestarter
* in $argv or <APP>_ALLOW_XDEBUG is set - the variable composer/xdebug-handler
* reads for that application, so a caller can drop its own xdebug restart.
*
* With $withOpcache false, the restart does not turn on OPcache. A run
* that mostly reads the result cache is then faster, and a full analysis
* uses a little more CPU.
*
* @api
* @param list<string> $argv
*/
public static function restartIfSuitable(array $argv, ?string $pharPath = null, ?string $appName = null): void
public static function restartIfSuitable(array $argv, ?string $pharPath = null, ?string $appName = null, bool $withOpcache = true): void
{
if (!$withOpcache) {
$extensions = $appName === null
? [
'phpstan_turbo',
'tideways',
]
: [
'xdebug',
'pcov',
'uopz',
'phpstan_turbo',
'tideways',
];
RestartManager::run($argv, $pharPath, $extensions, $appName ?? 'phpstan');
return;
}

if ($appName === null) {
RestartManager::run($argv, $pharPath, ['phpstan_turbo', 'tideways', 'opcache']);
return;
Expand Down
Loading