1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 17:57:37 +01:00

fixed Uncaught Error: Call to undefined function shell_exec()

This commit is contained in:
Thomas Bley 2021-09-20 12:18:49 +02:00
parent b4f4c94f77
commit 449ef0d994

View File

@ -1449,9 +1449,20 @@ class ProjectAnalyzer
return 1; return 1;
} }
$has_nproc = trim((string) @shell_exec('command -v nproc')); if (\function_exists('shell_exec')) {
if ($has_nproc) { $has_nproc = trim((string) @shell_exec('command -v nproc'));
$ret = @shell_exec('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)) { if (is_string($ret)) {
$ret = trim($ret); $ret = trim($ret);
$tmp = filter_var($ret, FILTER_VALIDATE_INT); $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')) { if (is_readable('/proc/cpuinfo')) {
$cpuinfo = file_get_contents('/proc/cpuinfo'); $cpuinfo = file_get_contents('/proc/cpuinfo');
$count = substr_count($cpuinfo, 'processor'); $count = substr_count($cpuinfo, 'processor');