diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index d19e264e3..b4eee08a6 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -1449,9 +1449,20 @@ class ProjectAnalyzer return 1; } - $has_nproc = trim((string) @shell_exec('command -v nproc')); - if ($has_nproc) { - $ret = @shell_exec('nproc'); + if (\function_exists('shell_exec')) { + $has_nproc = trim((string) @shell_exec('command -v nproc')); + if ($has_nproc) { + $ret = @shell_exec('nproc'); + if (is_string($ret)) { + $ret = trim($ret); + $tmp = filter_var($ret, FILTER_VALIDATE_INT); + if (is_int($tmp)) { + return $tmp; + } + } + } + + $ret = @shell_exec('sysctl -n hw.ncpu'); if (is_string($ret)) { $ret = trim($ret); $tmp = filter_var($ret, FILTER_VALIDATE_INT); @@ -1461,15 +1472,6 @@ class ProjectAnalyzer } } - $ret = @shell_exec('sysctl -n hw.ncpu'); - if (is_string($ret)) { - $ret = trim($ret); - $tmp = filter_var($ret, FILTER_VALIDATE_INT); - if (is_int($tmp)) { - return $tmp; - } - } - if (is_readable('/proc/cpuinfo')) { $cpuinfo = file_get_contents('/proc/cpuinfo'); $count = substr_count($cpuinfo, 'processor');