From 4e1a654be70b3ef79f0e33bb05cec0e0f5b2b38c Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Fri, 9 Sep 2022 04:22:54 +0200 Subject: [PATCH] fix psalm-internal risky casts --- src/Psalm/Internal/Cli/LanguageServer.php | 2 +- src/Psalm/Internal/Cli/Psalter.php | 2 +- src/Psalm/Internal/Cli/Refactor.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Cli/LanguageServer.php b/src/Psalm/Internal/Cli/LanguageServer.php index 634cdee16a4..3d24dc52cbd 100644 --- a/src/Psalm/Internal/Cli/LanguageServer.php +++ b/src/Psalm/Internal/Cli/LanguageServer.php @@ -298,7 +298,7 @@ function () use ($current_dir, $options, $vendor_dir): ?\Composer\Autoload\Class $find_unused_code = 'auto'; } - if (isset($options['disable-on-change'])) { + if (isset($options['disable-on-change']) && is_numeric($options['disable-on-change'])) { $project_analyzer->onchange_line_limit = (int) $options['disable-on-change']; } diff --git a/src/Psalm/Internal/Cli/Psalter.php b/src/Psalm/Internal/Cli/Psalter.php index 7db204c5f61..6e42d516859 100644 --- a/src/Psalm/Internal/Cli/Psalter.php +++ b/src/Psalm/Internal/Cli/Psalter.php @@ -230,7 +230,7 @@ function () use ($current_dir, $options, $vendor_dir): ?\Composer\Autoload\Class chdir($current_dir); } - $threads = isset($options['threads']) ? (int)$options['threads'] : 1; + $threads = isset($options['threads']) && is_numeric($options['threads']) ? (int)$options['threads'] : 1; if (isset($options['no-cache'])) { $providers = new Providers( diff --git a/src/Psalm/Internal/Cli/Refactor.php b/src/Psalm/Internal/Cli/Refactor.php index 864e9d4aebd..131d1c5834d 100644 --- a/src/Psalm/Internal/Cli/Refactor.php +++ b/src/Psalm/Internal/Cli/Refactor.php @@ -284,7 +284,7 @@ function () use ($current_dir, $options, $vendor_dir): ?\Composer\Autoload\Class chdir($current_dir); } - $threads = isset($options['threads']) + $threads = isset($options['threads']) && is_numeric($options['threads']) ? (int)$options['threads'] : max(1, ProjectAnalyzer::getCpuCount() - 2);