Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit warning if opcache cannot be enabled #9240

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
use function count;
use function file_exists;
use function file_put_contents;
use function function_exists;
use function fwrite;
use function gc_collect_cycles;
use function gc_disable;
Expand All @@ -63,6 +64,7 @@
use function json_encode;
use function max;
use function microtime;
use function opcache_get_status;
use function parse_url;
use function preg_match;
use function preg_replace;
Expand Down Expand Up @@ -258,9 +260,11 @@ public static function run(array $argv): void

$threads = self::detectThreads($options, $config, $in_ci);

$progress = self::initProgress($options, $config);

self::emitMacPcreWarning($options, $threads);

self::restart($options, $threads);
self::restart($options, $threads, $progress);

if (isset($options['debug-emitted-issues'])) {
$config->debug_emitted_issues = true;
Expand Down Expand Up @@ -317,7 +321,6 @@ public static function run(array $argv): void
self::clearGlobalCache($config);
}

$progress = self::initProgress($options, $config);
$providers = self::initProviders($options, $config, $current_dir);

$stdout_report_options = self::initStdoutReportOptions($options, $show_info, $output_format, $in_ci);
Expand Down Expand Up @@ -879,7 +882,7 @@ private static function emitMacPcreWarning(array $options, int $threads): void
}
}

private static function restart(array $options, int $threads): void
private static function restart(array $options, int $threads, Progress $progress): void
{
$ini_handler = new PsalmRestarter('PSALM');

Expand All @@ -904,6 +907,16 @@ private static function restart(array $options, int $threads): void

// If Xdebug is enabled, restart without it
$ini_handler->check();

if (!function_exists('opcache_get_status')
|| !($opcache_status = opcache_get_status(false))
|| !isset($opcache_status['opcache_enabled'])
|| !$opcache_status['opcache_enabled']
) {
$progress->write(PHP_EOL
. 'Install the opcache extension to make use of JIT on PHP 8.0+ for a 20%+ performance boost!'
. PHP_EOL . PHP_EOL);
}
}

private static function detectThreads(array $options, Config $config, bool $in_ci): int
Expand Down