From a73cc632d48e7b7cfe1f31f5f2833c0d1e40ac3e Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 16 Aug 2023 14:09:46 +0300 Subject: [PATCH] Making PHPStan happy --- helpers.inc.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/helpers.inc.php b/helpers.inc.php index 92af91e..ba8274b 100644 --- a/helpers.inc.php +++ b/helpers.inc.php @@ -41,8 +41,6 @@ function fatal($msg) function make_tmp_file_name($file_name) { $meta = stream_get_meta_data(tmpfile()); - if(!isset($meta['uri'])) - throw new Exception("Could not get temp directory name"); $tmp_dir = dirname($meta['uri']); $tmp_file = "$tmp_dir/$file_name"; return $tmp_file; @@ -405,10 +403,9 @@ function _execute_proc_cmd($cmd, &$ret, &$out) $proc = popen("$cmd 2>&1", 'r'); $log = ''; - //TODO: how can this be? - if(is_string($proc)) + if(!is_resource($proc)) { - $log = $proc; + $log = ""; _log($log, 1); } else @@ -978,7 +975,7 @@ function run_background_gamectl_workers($task, array $worker_args) { foreach($workers as $item) { - list($in_file, $log_file, $err_file) = $item; + list($in_file, $out_file, $log_file, $err_file) = $item; @ensure_rm($in_file); @ensure_rm($out_file); @ensure_rm($log_file); @@ -1028,7 +1025,7 @@ function watch_running_process($pid, $log_file, $exit_matches = array(), $error_ $throw_fn = function($msg) use (&$warnings_list) { - if(count($warnings_list) > 0) + if(count($warnings_list) > 0) // @phpstan-ignore-line $msg .= "\n\nPossible causes:\n" . implode("\n", $warnings_list) . "\n"; throw new Exception($msg); };