1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Alter order of precedence and upated docs to match

This commit is contained in:
m1ke 2022-01-20 15:24:21 +00:00
parent fb1fd8429f
commit 810880c71b
2 changed files with 22 additions and 2 deletions

View File

@ -416,6 +416,13 @@ Whether or not to allow `require`/`include` calls in your PHP. Defaults to `true
```
Allows you to hard-code a serializer for Psalm to use when caching data. By default, Psalm uses `ext-igbinary` *if* the version is greater than or equal to 2.0.5, otherwise it defaults to PHP's built-in serializer.
#### threads
```xml
<psalm
threads="[int]"
>
```
Allows you to hard-code the number of threads Psalm will use (similar to `--threads` on the command line). This value will be used in place of detecting threads from the host machine, but will be overridden by using `--threads` or `--debug` (which sets threads to 1) on the command line
## Project settings

View File

@ -246,7 +246,7 @@ final class Psalm
$options['long-progress'] = true;
}
$threads = self::detectThreads($options, $in_ci);
$threads = self::useThreads($options, $config, $in_ci);
self::emitMacPcreWarning($options, $threads);
@ -909,12 +909,14 @@ final class Psalm
}
}
private static function detectThreads(array $options, bool $in_ci): int
private static function detectThreads(array $options, Config $config, bool $in_ci): int
{
if (isset($options['threads'])) {
$threads = (int)$options['threads'];
} elseif (isset($options['debug']) || $in_ci) {
$threads = 1;
} elseif ($config->threads) {
$threads = $config->threads;
} else {
$threads = max(1, ProjectAnalyzer::getCpuCount() - 1);
}
@ -1170,4 +1172,15 @@ final class Psalm
);
}
}
private static function useThreads(array $options, bool $in_ci, Config $config): int
{
$threads = self::detectThreads($options, $in_ci);
if ($config->threads && $config->threads<$threads) {
$threads = $config->threads;
}
return $threads;
}
}