Skip to content

Commit

Permalink
fix psalm-internal risky casts
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Sep 19, 2022
1 parent 7cdad99 commit da68e9d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Psalm/Internal/Cli/LanguageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use function in_array;
use function ini_set;
use function is_array;
use function is_numeric;
use function is_string;
use function preg_replace;
use function realpath;
Expand Down Expand Up @@ -298,7 +299,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'];
}

Expand Down
3 changes: 2 additions & 1 deletion src/Psalm/Internal/Cli/Psalter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use function ini_set;
use function is_array;
use function is_dir;
use function is_numeric;
use function is_string;
use function microtime;
use function pathinfo;
Expand Down Expand Up @@ -230,7 +231,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(
Expand Down
3 changes: 2 additions & 1 deletion src/Psalm/Internal/Cli/Refactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use function in_array;
use function ini_set;
use function is_array;
use function is_numeric;
use function is_string;
use function max;
use function microtime;
Expand Down Expand Up @@ -284,7 +285,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);

Expand Down

0 comments on commit da68e9d

Please sign in to comment.