Skip to content

Commit 41acef5

Browse files
authored
Merge pull request #10319 from danog/rm_73
Get rid of legacy 7.3 logic
2 parents 722fe6c + 07b45b8 commit 41acef5

File tree

4 files changed

+6
-74
lines changed

4 files changed

+6
-74
lines changed

src/Psalm/Internal/Analyzer/ProjectAnalyzer.php

+5-26
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
use function fwrite;
7373
use function implode;
7474
use function in_array;
75-
use function ini_get;
7675
use function is_dir;
7776
use function is_file;
7877
use function microtime;
@@ -86,11 +85,8 @@
8685
use function strtolower;
8786
use function substr;
8887
use function usort;
89-
use function version_compare;
9088

9189
use const PHP_EOL;
92-
use const PHP_OS;
93-
use const PHP_VERSION;
9490
use const PSALM_VERSION;
9591
use const STDERR;
9692

@@ -391,21 +387,13 @@ public function serverMode(LanguageServer $server): void
391387
$this->file_reference_provider->loadReferenceCache();
392388
$this->codebase->enterServerMode();
393389

394-
if (ini_get('pcre.jit') === '1'
395-
&& PHP_OS === 'Darwin'
396-
&& version_compare(PHP_VERSION, '7.3.0') >= 0
397-
&& version_compare(PHP_VERSION, '7.4.0') < 0
398-
) {
399-
// do nothing
400-
} else {
401-
$cpu_count = self::getCpuCount();
390+
$cpu_count = self::getCpuCount();
402391

403-
// let's not go crazy
404-
$usable_cpus = $cpu_count - 2;
392+
// let's not go crazy
393+
$usable_cpus = $cpu_count - 2;
405394

406-
if ($usable_cpus > 1) {
407-
$this->threads = $usable_cpus;
408-
}
395+
if ($usable_cpus > 1) {
396+
$this->threads = $usable_cpus;
409397
}
410398

411399
$server->logInfo("Initializing: Initialize Plugins...");
@@ -1356,15 +1344,6 @@ public static function getCpuCount(): int
13561344
return 1;
13571345
}
13581346

1359-
// PHP 7.3 with JIT on OSX is screwed for multi-threads
1360-
if (ini_get('pcre.jit') === '1'
1361-
&& PHP_OS === 'Darwin'
1362-
&& version_compare(PHP_VERSION, '7.3.0') >= 0
1363-
&& version_compare(PHP_VERSION, '7.4.0') < 0
1364-
) {
1365-
return 1;
1366-
}
1367-
13681347
if (!extension_loaded('pcntl')) {
13691348
// Psalm requires pcntl for multi-threads support
13701349
return 1;

src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
use function in_array;
2626
use function is_string;
2727
use function strtolower;
28-
use function version_compare;
29-
30-
use const PHP_VERSION;
3128

3229
/**
3330
* @internal
@@ -267,8 +264,7 @@ public static function analyze(
267264
$fq_catch_class,
268265
false,
269266
false,
270-
version_compare(PHP_VERSION, '7.0.0dev', '>=')
271-
&& strtolower($fq_catch_class) !== 'throwable'
267+
strtolower($fq_catch_class) !== 'throwable'
272268
&& $codebase->interfaceExists($fq_catch_class)
273269
&& !$codebase->interfaceExtends($fq_catch_class, 'Throwable')
274270
? ['Throwable' => new TNamedObject('Throwable')]

src/Psalm/Internal/Cli/Psalm.php

-24
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Psalm\Internal\Codebase\ReferenceMapGenerator;
1414
use Psalm\Internal\Composer;
1515
use Psalm\Internal\ErrorHandler;
16-
use Psalm\Internal\Fork\Pool;
1716
use Psalm\Internal\Fork\PsalmRestarter;
1817
use Psalm\Internal\IncludeCollector;
1918
use Psalm\Internal\Provider\ClassLikeStorageCacheProvider;
@@ -73,15 +72,12 @@
7372
use function strlen;
7473
use function strpos;
7574
use function substr;
76-
use function version_compare;
7775

7876
use const DIRECTORY_SEPARATOR;
7977
use const JSON_THROW_ON_ERROR;
8078
use const LC_CTYPE;
8179
use const PHP_EOL;
82-
use const PHP_OS;
8380
use const PHP_URL_SCHEME;
84-
use const PHP_VERSION;
8581
use const STDERR;
8682

8783
// phpcs:disable PSR1.Files.SideEffects
@@ -269,8 +265,6 @@ public static function run(array $argv): void
269265

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

272-
self::emitMacPcreWarning($options, $threads);
273-
274268
self::restart($options, $threads, $progress);
275269

276270
if (isset($options['debug-emitted-issues'])) {
@@ -865,24 +859,6 @@ private static function getCurrentDir(array $options): string
865859
return $current_dir;
866860
}
867861

868-
private static function emitMacPcreWarning(array $options, int $threads): void
869-
{
870-
if (!isset($options['threads'])
871-
&& !isset($options['debug'])
872-
&& $threads === 1
873-
&& ini_get('pcre.jit') === '1'
874-
&& PHP_OS === 'Darwin'
875-
&& version_compare(PHP_VERSION, '7.3.0') >= 0
876-
&& version_compare(PHP_VERSION, '7.4.0') < 0
877-
) {
878-
echo(
879-
'If you want to run Psalm as a language server, or run Psalm with' . PHP_EOL
880-
. 'multiple processes (--threads=4), beware:' . PHP_EOL
881-
. Pool::MAC_PCRE_MESSAGE . PHP_EOL . PHP_EOL
882-
);
883-
}
884-
}
885-
886862
private static function restart(array $options, int $threads, Progress $progress): void
887863
{
888864
$ini_handler = new PsalmRestarter('PSALM');

src/Psalm/Internal/Fork/Pool.php

-19
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@
4848
use function substr;
4949
use function unserialize;
5050
use function usleep;
51-
use function version_compare;
5251

5352
use const PHP_EOL;
54-
use const PHP_OS;
55-
use const PHP_VERSION;
5653
use const SIGALRM;
5754
use const SIGTERM;
5855
use const STREAM_IPPROTO_IP;
@@ -88,12 +85,6 @@ class Pool
8885
/** @var ?Closure(mixed): void */
8986
private ?Closure $task_done_closure = null;
9087

91-
public const MAC_PCRE_MESSAGE = 'Mac users: pcre.jit is set to 1 in your PHP config.' . PHP_EOL
92-
. 'The pcre jit is known to cause segfaults in PHP 7.3 on Macs, and Psalm' . PHP_EOL
93-
. 'will not execute in threaded mode to avoid indecipherable errors.' . PHP_EOL
94-
. 'Consider adding pcre.jit=0 to your PHP config, or upgrade to PHP 7.4.' . PHP_EOL
95-
. 'Relevant info: https://bugs.php.net/bug.php?id=77260';
96-
9788
/**
9889
* @param array<int, array<int, mixed>> $process_task_data_iterator
9990
* An array of task data items to be divided up among the
@@ -141,16 +132,6 @@ public function __construct(
141132
exit(1);
142133
}
143134

144-
if (ini_get('pcre.jit') === '1'
145-
&& PHP_OS === 'Darwin'
146-
&& version_compare(PHP_VERSION, '7.3.0') >= 0
147-
&& version_compare(PHP_VERSION, '7.4.0') < 0
148-
) {
149-
die(
150-
self::MAC_PCRE_MESSAGE . PHP_EOL
151-
);
152-
}
153-
154135
// We'll keep track of if this is the parent process
155136
// so that we can tell who will be doing the waiting
156137
$is_parent = false;

0 commit comments

Comments
 (0)