chore: Аннотации к типам

This commit is contained in:
origami11@yandex.ru 2025-10-21 12:00:06 +03:00
parent 09a61244ca
commit 1e27648a12
17 changed files with 217 additions and 81 deletions

View file

@ -2,25 +2,39 @@
namespace ctiso;
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fiveMBs = 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
$data = '';
if (is_resource($fp)) {
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, 1000, $delimiter, $enclosure);
fclose($fp);
}
return $data;
}
/**
* str_getcsv
* @param string $input
* @param string $delimiter
* @param string $enclosure
* @param string $escape
* @return array
*/
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
{
$fiveMBs = 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
$data = '';
if (is_resource($fp)) {
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, 1000, $delimiter, $enclosure);
fclose($fp);
}
return $data;
}
function process_exists($pid) {
/**
* process_exists
* @param int $pid
* @return bool
*/
function process_exists($pid)
{
if (PHP_OS == 'WINNT') {
$processes = explode("\n", shell_exec("tasklist.exe /NH /FO CSV"));
foreach($processes as $process) {
foreach ($processes as $process) {
if ($process != "") {
$csv = str_getcsv($process);
if ($pid == $csv[1]) return true;
@ -32,13 +46,19 @@ function process_exists($pid) {
}
}
function create_single_proces($fpid, $fn) {
/**
* create_single_proces
* @param string $fpid
* @param callable $fn
* @return int
*/
function create_single_process($fpid, $fn)
{
if (file_exists($fpid)) {
print_r(realpath($fpid));
if (process_exists(file_get_contents($fpid))) {
return 1;
if (process_exists((int)file_get_contents($fpid))) {
return 1;
}
}
}
call_user_func($fn);
return 0;
}