1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Get rid of legacy 7.3 logic

This commit is contained in:
Daniil Gentili 2023-10-26 17:18:33 +02:00
parent 2726ad4d6f
commit 07b45b8116
4 changed files with 6 additions and 74 deletions

View File

@ -72,7 +72,6 @@ use function file_exists;
use function fwrite;
use function implode;
use function in_array;
use function ini_get;
use function is_dir;
use function is_file;
use function microtime;
@ -86,11 +85,8 @@ use function strpos;
use function strtolower;
use function substr;
use function usort;
use function version_compare;
use const PHP_EOL;
use const PHP_OS;
use const PHP_VERSION;
use const PSALM_VERSION;
use const STDERR;
@ -391,21 +387,13 @@ class ProjectAnalyzer
$this->file_reference_provider->loadReferenceCache();
$this->codebase->enterServerMode();
if (ini_get('pcre.jit') === '1'
&& PHP_OS === 'Darwin'
&& version_compare(PHP_VERSION, '7.3.0') >= 0
&& version_compare(PHP_VERSION, '7.4.0') < 0
) {
// do nothing
} else {
$cpu_count = self::getCpuCount();
$cpu_count = self::getCpuCount();
// let's not go crazy
$usable_cpus = $cpu_count - 2;
// let's not go crazy
$usable_cpus = $cpu_count - 2;
if ($usable_cpus > 1) {
$this->threads = $usable_cpus;
}
if ($usable_cpus > 1) {
$this->threads = $usable_cpus;
}
$server->logInfo("Initializing: Initialize Plugins...");
@ -1356,15 +1344,6 @@ class ProjectAnalyzer
return 1;
}
// PHP 7.3 with JIT on OSX is screwed for multi-threads
if (ini_get('pcre.jit') === '1'
&& PHP_OS === 'Darwin'
&& version_compare(PHP_VERSION, '7.3.0') >= 0
&& version_compare(PHP_VERSION, '7.4.0') < 0
) {
return 1;
}
if (!extension_loaded('pcntl')) {
// Psalm requires pcntl for multi-threads support
return 1;

View File

@ -25,9 +25,6 @@ use function array_merge;
use function in_array;
use function is_string;
use function strtolower;
use function version_compare;
use const PHP_VERSION;
/**
* @internal
@ -267,8 +264,7 @@ class TryAnalyzer
$fq_catch_class,
false,
false,
version_compare(PHP_VERSION, '7.0.0dev', '>=')
&& strtolower($fq_catch_class) !== 'throwable'
strtolower($fq_catch_class) !== 'throwable'
&& $codebase->interfaceExists($fq_catch_class)
&& !$codebase->interfaceExtends($fq_catch_class, 'Throwable')
? ['Throwable' => new TNamedObject('Throwable')]

View File

@ -13,7 +13,6 @@ use Psalm\Internal\CliUtils;
use Psalm\Internal\Codebase\ReferenceMapGenerator;
use Psalm\Internal\Composer;
use Psalm\Internal\ErrorHandler;
use Psalm\Internal\Fork\Pool;
use Psalm\Internal\Fork\PsalmRestarter;
use Psalm\Internal\IncludeCollector;
use Psalm\Internal\Provider\ClassLikeStorageCacheProvider;
@ -73,15 +72,12 @@ use function str_replace;
use function strlen;
use function strpos;
use function substr;
use function version_compare;
use const DIRECTORY_SEPARATOR;
use const JSON_THROW_ON_ERROR;
use const LC_CTYPE;
use const PHP_EOL;
use const PHP_OS;
use const PHP_URL_SCHEME;
use const PHP_VERSION;
use const STDERR;
// phpcs:disable PSR1.Files.SideEffects
@ -269,8 +265,6 @@ final class Psalm
$progress = self::initProgress($options, $config);
self::emitMacPcreWarning($options, $threads);
self::restart($options, $threads, $progress);
if (isset($options['debug-emitted-issues'])) {
@ -865,24 +859,6 @@ final class Psalm
return $current_dir;
}
private static function emitMacPcreWarning(array $options, int $threads): void
{
if (!isset($options['threads'])
&& !isset($options['debug'])
&& $threads === 1
&& ini_get('pcre.jit') === '1'
&& PHP_OS === 'Darwin'
&& version_compare(PHP_VERSION, '7.3.0') >= 0
&& version_compare(PHP_VERSION, '7.4.0') < 0
) {
echo(
'If you want to run Psalm as a language server, or run Psalm with' . PHP_EOL
. 'multiple processes (--threads=4), beware:' . PHP_EOL
. Pool::MAC_PCRE_MESSAGE . PHP_EOL . PHP_EOL
);
}
}
private static function restart(array $options, int $threads, Progress $progress): void
{
$ini_handler = new PsalmRestarter('PSALM');

View File

@ -48,11 +48,8 @@ use function strpos;
use function substr;
use function unserialize;
use function usleep;
use function version_compare;
use const PHP_EOL;
use const PHP_OS;
use const PHP_VERSION;
use const SIGALRM;
use const SIGTERM;
use const STREAM_IPPROTO_IP;
@ -88,12 +85,6 @@ class Pool
/** @var ?Closure(mixed): void */
private ?Closure $task_done_closure = null;
public const MAC_PCRE_MESSAGE = 'Mac users: pcre.jit is set to 1 in your PHP config.' . PHP_EOL
. 'The pcre jit is known to cause segfaults in PHP 7.3 on Macs, and Psalm' . PHP_EOL
. 'will not execute in threaded mode to avoid indecipherable errors.' . PHP_EOL
. 'Consider adding pcre.jit=0 to your PHP config, or upgrade to PHP 7.4.' . PHP_EOL
. 'Relevant info: https://bugs.php.net/bug.php?id=77260';
/**
* @param array<int, array<int, mixed>> $process_task_data_iterator
* An array of task data items to be divided up among the
@ -141,16 +132,6 @@ class Pool
exit(1);
}
if (ini_get('pcre.jit') === '1'
&& PHP_OS === 'Darwin'
&& version_compare(PHP_VERSION, '7.3.0') >= 0
&& version_compare(PHP_VERSION, '7.4.0') < 0
) {
die(
self::MAC_PCRE_MESSAGE . PHP_EOL
);
}
// We'll keep track of if this is the parent process
// so that we can tell who will be doing the waiting
$is_parent = false;