Skip to content

Commit

Permalink
Emit warning if the opcache cannot be installed or JIT cannot be used
Browse files Browse the repository at this point in the history
  • Loading branch information
danog authored and weirdan committed Feb 13, 2023
1 parent 1be367b commit b54cefe
Showing 1 changed file with 16 additions and 3 deletions.
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

0 comments on commit b54cefe

Please sign in to comment.