Files
kulakpos_web/vendor/thecodingmachine/safe/generated/8.2/exec.php

121 lines
2.6 KiB
PHP
Raw Normal View History

2026-03-30 14:54:57 +07:00
<?php
namespace Safe;
use Safe\Exceptions\ExecException;
/**
2026-04-18 20:32:18 +07:00
* @param string $command
* @param array|null $output
* @param int|null $result_code
* @return string
2026-03-30 14:54:57 +07:00
* @throws ExecException
*
*/
function exec(string $command, ?array &$output = null, ?int &$result_code = null): string
{
error_clear_last();
$safeResult = \exec($command, $output, $result_code);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
2026-04-18 20:32:18 +07:00
* @param resource $process
* @return int
2026-03-30 14:54:57 +07:00
* @throws ExecException
*
*/
function proc_close($process): int
{
error_clear_last();
$safeResult = \proc_close($process);
if ($safeResult === -1) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
2026-04-18 20:32:18 +07:00
* @param int $priority
2026-03-30 14:54:57 +07:00
* @throws ExecException
*
*/
function proc_nice(int $priority): void
{
error_clear_last();
$safeResult = \proc_nice($priority);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
}
/**
2026-04-18 20:32:18 +07:00
* @param string $command
* @param array $descriptor_spec
* @param null|resource[] $pipes
* @param null|string $cwd
* @param array|null $env_vars
* @param array|null $options
* @return resource
2026-03-30 14:54:57 +07:00
* @throws ExecException
*
*/
function proc_open(string $command, array $descriptor_spec, ?array &$pipes, ?string $cwd = null, ?array $env_vars = null, ?array $options = null)
{
error_clear_last();
if ($options !== null) {
$safeResult = \proc_open($command, $descriptor_spec, $pipes, $cwd, $env_vars, $options);
} elseif ($env_vars !== null) {
$safeResult = \proc_open($command, $descriptor_spec, $pipes, $cwd, $env_vars);
} elseif ($cwd !== null) {
$safeResult = \proc_open($command, $descriptor_spec, $pipes, $cwd);
} else {
$safeResult = \proc_open($command, $descriptor_spec, $pipes);
}
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
2026-04-18 20:32:18 +07:00
* @param string $command
* @return null|string
2026-03-30 14:54:57 +07:00
* @throws ExecException
*
*/
function shell_exec(string $command): ?string
{
error_clear_last();
$safeResult = \shell_exec($command);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
2026-04-18 20:32:18 +07:00
* @param string $command
* @param int|null $result_code
* @return string
2026-03-30 14:54:57 +07:00
* @throws ExecException
*
*/
function system(string $command, ?int &$result_code = null): string
{
error_clear_last();
$safeResult = \system($command, $result_code);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}