Stand: SMTP-Test, Admin-Mail-Tab, Notifiable-Fix, Lazy-Quill

- Fix: Notifiable-Trait zum User-Model hinzugefuegt (behebt notify()-500er)
- Installer: SMTP-Verbindungstest mit EsmtpTransport + Ueberspringen-Link
- Admin: Neuer E-Mail-Tab mit SMTP-Konfiguration + Verbindungstest
- Admin: Lazy Quill-Initialisierung (nur sichtbare Locale wird geladen)
- Uebersetzungen: 17 neue Mail-Keys in allen 6 Sprachen

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rhino
2026-03-02 07:30:37 +01:00
commit 2e24a40d68
9633 changed files with 1300799 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
<?php
namespace Safe;
use Safe\Exceptions\ArrayException;
/**
* @param array $keys
* @param array $values
* @return array
*
*/
function array_combine(array $keys, array $values): array
{
error_clear_last();
$safeResult = \array_combine($keys, $values);
return $safeResult;
}
/**
* @param array $array
* @return array
*
*/
function array_flip(array $array): array
{
error_clear_last();
$safeResult = \array_flip($array);
return $safeResult;
}
/**
* @param array $array
* @param array $replacements
* @return array
*
*/
function array_replace_recursive(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$safeResult = \array_replace_recursive($array, ...$replacements);
} else {
$safeResult = \array_replace_recursive($array);
}
return $safeResult;
}
/**
* @param array $array
* @param array $replacements
* @return array
*
*/
function array_replace(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$safeResult = \array_replace($array, ...$replacements);
} else {
$safeResult = \array_replace($array);
}
return $safeResult;
}
/**
* @param array|object $array
* @param callable $callback
* @param mixed $arg
* @throws ArrayException
*
*/
function array_walk_recursive(&$array, callable $callback, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$safeResult = \array_walk_recursive($array, $callback, $arg);
} else {
$safeResult = \array_walk_recursive($array, $callback);
}
if ($safeResult === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* @param array $array
* @throws ArrayException
*
*/
function shuffle(array &$array): void
{
error_clear_last();
$safeResult = \shuffle($array);
if ($safeResult === false) {
throw ArrayException::createFromPhpError();
}
}

View File

@@ -0,0 +1,234 @@
<?php
namespace Safe;
use Safe\Exceptions\CurlException;
/**
* @param \CurlHandle $handle
* @return \CurlHandle
* @throws CurlException
*
*/
function curl_copy_handle(\CurlHandle $handle): \CurlHandle
{
error_clear_last();
$safeResult = \curl_copy_handle($handle);
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
return $safeResult;
}
/**
* @param \CurlHandle $handle
* @param string $string
* @return string
* @throws CurlException
*
*/
function curl_escape(\CurlHandle $handle, string $string): string
{
error_clear_last();
$safeResult = \curl_escape($handle, $string);
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
return $safeResult;
}
/**
* @param \CurlHandle $handle
* @return bool|string
* @throws CurlException
*
*/
function curl_exec(\CurlHandle $handle)
{
error_clear_last();
$safeResult = \curl_exec($handle);
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
return $safeResult;
}
/**
* @param \CurlHandle $handle
* @param int|null $option
* @return mixed
* @throws CurlException
*
*/
function curl_getinfo(\CurlHandle $handle, ?int $option = null)
{
error_clear_last();
if ($option !== null) {
$safeResult = \curl_getinfo($handle, $option);
} else {
$safeResult = \curl_getinfo($handle);
}
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
return $safeResult;
}
/**
* @param null|string $url
* @return \CurlHandle
* @throws CurlException
*
*/
function curl_init(?string $url = null): \CurlHandle
{
error_clear_last();
if ($url !== null) {
$safeResult = \curl_init($url);
} else {
$safeResult = \curl_init();
}
if ($safeResult === false) {
throw CurlException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \CurlMultiHandle $multi_handle
* @param int|null $queued_messages
* @return array
* @throws CurlException
*
*/
function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_messages = null): array
{
error_clear_last();
$safeResult = \curl_multi_info_read($multi_handle, $queued_messages);
if ($safeResult === false) {
throw CurlException::createFromPhpError($multi_handle);
}
return $safeResult;
}
/**
* @return \CurlMultiHandle
* @throws CurlException
*
*/
function curl_multi_init(): \CurlMultiHandle
{
error_clear_last();
$safeResult = \curl_multi_init();
if ($safeResult === false) {
throw CurlException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \CurlMultiHandle $multi_handle
* @param int $option
* @param mixed $value
* @throws CurlException
*
*/
function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): void
{
error_clear_last();
$safeResult = \curl_multi_setopt($multi_handle, $option, $value);
if ($safeResult === false) {
throw CurlException::createFromPhpError($multi_handle);
}
}
/**
* @param \CurlHandle $handle
* @param int $option
* @param mixed $value
* @throws CurlException
*
*/
function curl_setopt(\CurlHandle $handle, int $option, $value): void
{
error_clear_last();
$safeResult = \curl_setopt($handle, $option, $value);
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
}
/**
* @param \CurlShareHandle $share_handle
* @return int
* @throws CurlException
*
*/
function curl_share_errno(\CurlShareHandle $share_handle): int
{
error_clear_last();
$safeResult = \curl_share_errno($share_handle);
if ($safeResult === false) {
throw CurlException::createFromPhpError($share_handle);
}
return $safeResult;
}
/**
* @param \CurlShareHandle $share_handle
* @param int $option
* @param mixed $value
* @throws CurlException
*
*/
function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value): void
{
error_clear_last();
$safeResult = \curl_share_setopt($share_handle, $option, $value);
if ($safeResult === false) {
throw CurlException::createFromPhpError($share_handle);
}
}
/**
* @param \CurlHandle $handle
* @param string $string
* @return string
* @throws CurlException
*
*/
function curl_unescape(\CurlHandle $handle, string $string): string
{
error_clear_last();
$safeResult = \curl_unescape($handle, $string);
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
return $safeResult;
}
/**
* @param \CurlHandle $handle
* @throws CurlException
*
*/
function curl_upkeep(\CurlHandle $handle): void
{
error_clear_last();
$safeResult = \curl_upkeep($handle);
if ($safeResult === false) {
throw CurlException::createFromPhpError($handle);
}
}

View File

@@ -0,0 +1,359 @@
<?php
namespace Safe;
use Safe\Exceptions\DatetimeException;
/**
* @param null|string $datetime
* @param \DateTimeZone|null $timezone
* @return \DateTime
* @throws DatetimeException
*
*/
function date_create(?string $datetime = "now", ?\DateTimeZone $timezone = null): \DateTime
{
error_clear_last();
if ($timezone !== null) {
$safeResult = \date_create($datetime, $timezone);
} else {
$safeResult = \date_create($datetime);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $format
* @param string $datetime
* @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null
* @throws DatetimeException
*
*/
function date_parse_from_format(string $format, string $datetime): ?array
{
error_clear_last();
$safeResult = \date_parse_from_format($format, $datetime);
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $datetime
* @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null
* @throws DatetimeException
*
*/
function date_parse(string $datetime): ?array
{
error_clear_last();
$safeResult = \date_parse($datetime);
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $timestamp
* @param float $latitude
* @param float $longitude
* @return array{sunrise: int|bool,sunset: int|bool,transit: int|bool,civil_twilight_begin: int|bool,civil_twilight_end: int|bool,nautical_twilight_begin: int|bool,nautical_twilight_end: int|bool,astronomical_twilight_begin: int|bool,astronomical_twilight_end: int|bool}
* @throws DatetimeException
*
*/
function date_sun_info(int $timestamp, float $latitude, float $longitude): array
{
error_clear_last();
$safeResult = \date_sun_info($timestamp, $latitude, $longitude);
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $timestamp
* @param int $returnFormat
* @param float|null $latitude
* @param float|null $longitude
* @param float|null $zenith
* @param float|null $utcOffset
* @return mixed
* @throws DatetimeException
*
*/
function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude = null, ?float $longitude = null, ?float $zenith = null, ?float $utcOffset = null)
{
error_clear_last();
if ($utcOffset !== null) {
$safeResult = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset);
} elseif ($zenith !== null) {
$safeResult = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith);
} elseif ($longitude !== null) {
$safeResult = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude);
} elseif ($latitude !== null) {
$safeResult = \date_sunrise($timestamp, $returnFormat, $latitude);
} else {
$safeResult = \date_sunrise($timestamp, $returnFormat);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $timestamp
* @param int $returnFormat
* @param float|null $latitude
* @param float|null $longitude
* @param float|null $zenith
* @param float|null $utcOffset
* @return mixed
* @throws DatetimeException
*
*/
function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude = null, ?float $longitude = null, ?float $zenith = null, ?float $utcOffset = null)
{
error_clear_last();
if ($utcOffset !== null) {
$safeResult = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset);
} elseif ($zenith !== null) {
$safeResult = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith);
} elseif ($longitude !== null) {
$safeResult = \date_sunset($timestamp, $returnFormat, $latitude, $longitude);
} elseif ($latitude !== null) {
$safeResult = \date_sunset($timestamp, $returnFormat, $latitude);
} else {
$safeResult = \date_sunset($timestamp, $returnFormat);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $format
* @param int|null $timestamp
* @return string
* @throws DatetimeException
*
*/
function date(string $format, ?int $timestamp = null): string
{
error_clear_last();
if ($timestamp !== null) {
$safeResult = \date($format, $timestamp);
} else {
$safeResult = \date($format);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $hour
* @param int|null $minute
* @param int|null $second
* @param int|null $month
* @param int|null $day
* @param int|null $year
* @return int
* @throws DatetimeException
*
*/
function gmmktime(int $hour, ?int $minute = null, ?int $second = null, ?int $month = null, ?int $day = null, ?int $year = null): int
{
error_clear_last();
if ($year !== null) {
$safeResult = \gmmktime($hour, $minute, $second, $month, $day, $year);
} elseif ($day !== null) {
$safeResult = \gmmktime($hour, $minute, $second, $month, $day);
} elseif ($month !== null) {
$safeResult = \gmmktime($hour, $minute, $second, $month);
} elseif ($second !== null) {
$safeResult = \gmmktime($hour, $minute, $second);
} elseif ($minute !== null) {
$safeResult = \gmmktime($hour, $minute);
} else {
$safeResult = \gmmktime($hour);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $format
* @param int|null $timestamp
* @return string
* @throws DatetimeException
*
*/
function gmstrftime(string $format, ?int $timestamp = null): string
{
error_clear_last();
if ($timestamp !== null) {
$safeResult = \gmstrftime($format, $timestamp);
} else {
$safeResult = \gmstrftime($format);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $format
* @param int|null $timestamp
* @return int
* @throws DatetimeException
*
*/
function idate(string $format, ?int $timestamp = null): int
{
error_clear_last();
if ($timestamp !== null) {
$safeResult = \idate($format, $timestamp);
} else {
$safeResult = \idate($format);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $hour
* @param int|null $minute
* @param int|null $second
* @param int|null $month
* @param int|null $day
* @param int|null $year
* @return int
* @throws DatetimeException
*
*/
function mktime(int $hour, ?int $minute = null, ?int $second = null, ?int $month = null, ?int $day = null, ?int $year = null): int
{
error_clear_last();
if ($year !== null) {
$safeResult = \mktime($hour, $minute, $second, $month, $day, $year);
} elseif ($day !== null) {
$safeResult = \mktime($hour, $minute, $second, $month, $day);
} elseif ($month !== null) {
$safeResult = \mktime($hour, $minute, $second, $month);
} elseif ($second !== null) {
$safeResult = \mktime($hour, $minute, $second);
} elseif ($minute !== null) {
$safeResult = \mktime($hour, $minute);
} else {
$safeResult = \mktime($hour);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $format
* @param int|null $timestamp
* @return string
* @throws DatetimeException
*
*/
function strftime(string $format, ?int $timestamp = null): string
{
error_clear_last();
if ($timestamp !== null) {
$safeResult = \strftime($format, $timestamp);
} else {
$safeResult = \strftime($format);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $timestamp
* @param string $format
* @return array
* @throws DatetimeException
*
*/
function strptime(string $timestamp, string $format): array
{
error_clear_last();
$safeResult = \strptime($timestamp, $format);
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $datetime
* @param int|null $baseTimestamp
* @return int
* @throws DatetimeException
*
*/
function strtotime(string $datetime, ?int $baseTimestamp = null): int
{
error_clear_last();
if ($baseTimestamp !== null) {
$safeResult = \strtotime($datetime, $baseTimestamp);
} else {
$safeResult = \strtotime($datetime);
}
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $abbr
* @param int $utcOffset
* @param int $isDST
* @return string
* @throws DatetimeException
*
*/
function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string
{
error_clear_last();
$safeResult = \timezone_name_from_abbr($abbr, $utcOffset, $isDST);
if ($safeResult === false) {
throw DatetimeException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Safe;
use Safe\Exceptions\ErrorfuncException;
/**
* @param string $message
* @param 0|1|2|3|4 $message_type
* @param null|string $destination
* @param null|string $additional_headers
* @throws ErrorfuncException
*
*/
function error_log(string $message, int $message_type = 0, ?string $destination = null, ?string $additional_headers = null): void
{
error_clear_last();
if ($additional_headers !== null) {
$safeResult = \error_log($message, $message_type, $destination, $additional_headers);
} elseif ($destination !== null) {
$safeResult = \error_log($message, $message_type, $destination);
} else {
$safeResult = \error_log($message, $message_type);
}
if ($safeResult === false) {
throw ErrorfuncException::createFromPhpError();
}
}

View File

@@ -0,0 +1,120 @@
<?php
namespace Safe;
use Safe\Exceptions\ExecException;
/**
* @param string $command
* @param array|null $output
* @param int|null $result_code
* @return string
* @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;
}
/**
* @param resource $process
* @return int
* @throws ExecException
*
*/
function proc_close($process): int
{
error_clear_last();
$safeResult = \proc_close($process);
if ($safeResult === -1) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $priority
* @throws ExecException
*
*/
function proc_nice(int $priority): void
{
error_clear_last();
$safeResult = \proc_nice($priority);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
}
/**
* @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
* @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;
}
/**
* @param string $command
* @return null|string
* @throws ExecException
*
*/
function shell_exec(string $command): ?string
{
error_clear_last();
$safeResult = \shell_exec($command);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $command
* @param int|null $result_code
* @return string
* @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;
}

View File

@@ -0,0 +1,895 @@
<?php
namespace Safe;
use Safe\Exceptions\FilesystemException;
/**
* @param string $filename
* @param int|string $group
* @throws FilesystemException
*
*/
function chgrp(string $filename, $group): void
{
error_clear_last();
$safeResult = \chgrp($filename, $group);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param int $permissions
* @throws FilesystemException
*
*/
function chmod(string $filename, int $permissions): void
{
error_clear_last();
$safeResult = \chmod($filename, $permissions);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param int|string $user
* @throws FilesystemException
*
*/
function chown(string $filename, $user): void
{
error_clear_last();
$safeResult = \chown($filename, $user);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $from
* @param string $to
* @param null|resource $context
* @throws FilesystemException
*
*/
function copy(string $from, string $to, $context = null): void
{
error_clear_last();
if ($context !== null) {
$safeResult = \copy($from, $to, $context);
} else {
$safeResult = \copy($from, $to);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $directory
* @return float
* @throws FilesystemException
*
*/
function disk_free_space(string $directory): float
{
error_clear_last();
$safeResult = \disk_free_space($directory);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $directory
* @return float
* @throws FilesystemException
*
*/
function disk_total_space(string $directory): float
{
error_clear_last();
$safeResult = \disk_total_space($directory);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @throws FilesystemException
*
*/
function fclose($stream): void
{
error_clear_last();
$safeResult = \fclose($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param resource $stream
* @throws FilesystemException
*
*/
function fdatasync($stream): void
{
error_clear_last();
$safeResult = \fdatasync($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param resource $stream
* @throws FilesystemException
*
*/
function fflush($stream): void
{
error_clear_last();
$safeResult = \fflush($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param bool $use_include_path
* @param null|resource $context
* @param int $offset
* @param 0|null|positive-int $length
* @return string
* @throws FilesystemException
*
*/
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, ?int $length = null): string
{
error_clear_last();
if ($length !== null) {
$safeResult = \file_get_contents($filename, $use_include_path, $context, $offset, $length);
} elseif ($offset !== 0) {
$safeResult = \file_get_contents($filename, $use_include_path, $context, $offset);
} elseif ($context !== null) {
$safeResult = \file_get_contents($filename, $use_include_path, $context);
} else {
$safeResult = \file_get_contents($filename, $use_include_path);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @param mixed $data
* @param int $flags
* @param null|resource $context
* @return 0|positive-int
* @throws FilesystemException
*
*/
function file_put_contents(string $filename, $data, int $flags = 0, $context = null): int
{
error_clear_last();
if ($context !== null) {
$safeResult = \file_put_contents($filename, $data, $flags, $context);
} else {
$safeResult = \file_put_contents($filename, $data, $flags);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @param int-mask $flags
* @param null|resource $context
* @return list
* @throws FilesystemException
*
*/
function file(string $filename, int $flags = 0, $context = null): array
{
error_clear_last();
if ($context !== null) {
$safeResult = \file($filename, $flags, $context);
} else {
$safeResult = \file($filename, $flags);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return int
* @throws FilesystemException
*
*/
function fileatime(string $filename): int
{
error_clear_last();
$safeResult = \fileatime($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return int
* @throws FilesystemException
*
*/
function filectime(string $filename): int
{
error_clear_last();
$safeResult = \filectime($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return int
* @throws FilesystemException
*
*/
function fileinode(string $filename): int
{
error_clear_last();
$safeResult = \fileinode($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return int
* @throws FilesystemException
*
*/
function filemtime(string $filename): int
{
error_clear_last();
$safeResult = \filemtime($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return int
* @throws FilesystemException
*
*/
function fileowner(string $filename): int
{
error_clear_last();
$safeResult = \fileowner($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return int
* @throws FilesystemException
*
*/
function fileperms(string $filename): int
{
error_clear_last();
$safeResult = \fileperms($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return 0|positive-int
* @throws FilesystemException
*
*/
function filesize(string $filename): int
{
error_clear_last();
$safeResult = \filesize($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @return string
* @throws FilesystemException
*
*/
function filetype(string $filename): string
{
error_clear_last();
$safeResult = \filetype($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param int-mask $operation
* @param 0|1|null $would_block
* @throws FilesystemException
*
*/
function flock($stream, int $operation, ?int &$would_block = null): void
{
error_clear_last();
$safeResult = \flock($stream, $operation, $would_block);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param string $mode
* @param bool $use_include_path
* @param null|resource $context
* @return resource
* @throws FilesystemException
*
*/
function fopen(string $filename, string $mode, bool $use_include_path = false, $context = null)
{
error_clear_last();
if ($context !== null) {
$safeResult = \fopen($filename, $mode, $use_include_path, $context);
} else {
$safeResult = \fopen($filename, $mode, $use_include_path);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param positive-int $length
* @return string
* @throws FilesystemException
*
*/
function fread($stream, int $length): string
{
error_clear_last();
$safeResult = \fread($stream, $length);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @return array
* @throws FilesystemException
*
*/
function fstat($stream): array
{
error_clear_last();
$safeResult = \fstat($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @throws FilesystemException
*
*/
function fsync($stream): void
{
error_clear_last();
$safeResult = \fsync($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param resource $stream
* @return int
* @throws FilesystemException
*
*/
function ftell($stream): int
{
error_clear_last();
$safeResult = \ftell($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param 0|positive-int $size
* @throws FilesystemException
*
*/
function ftruncate($stream, int $size): void
{
error_clear_last();
$safeResult = \ftruncate($stream, $size);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param resource $stream
* @param string $data
* @param 0|null|positive-int $length
* @return 0|positive-int
* @throws FilesystemException
*
*/
function fwrite($stream, string $data, ?int $length = null): int
{
error_clear_last();
if ($length !== null) {
$safeResult = \fwrite($stream, $data, $length);
} else {
$safeResult = \fwrite($stream, $data);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $pattern
* @param int $flags
* @return list
* @throws FilesystemException
*
*/
function glob(string $pattern, int $flags = 0): array
{
error_clear_last();
$safeResult = \glob($pattern, $flags);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @param int|string $group
* @throws FilesystemException
*
*/
function lchgrp(string $filename, $group): void
{
error_clear_last();
$safeResult = \lchgrp($filename, $group);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param int|string $user
* @throws FilesystemException
*
*/
function lchown(string $filename, $user): void
{
error_clear_last();
$safeResult = \lchown($filename, $user);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $target
* @param string $link
* @throws FilesystemException
*
*/
function link(string $target, string $link): void
{
error_clear_last();
$safeResult = \link($target, $link);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @return array
* @throws FilesystemException
*
*/
function lstat(string $filename): array
{
error_clear_last();
$safeResult = \lstat($filename);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $directory
* @param int $permissions
* @param bool $recursive
* @param null|resource $context
* @throws FilesystemException
*
*/
function mkdir(string $directory, int $permissions = 0777, bool $recursive = false, $context = null): void
{
error_clear_last();
if ($context !== null) {
$safeResult = \mkdir($directory, $permissions, $recursive, $context);
} else {
$safeResult = \mkdir($directory, $permissions, $recursive);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param bool $process_sections
* @param int $scanner_mode
* @return array
* @throws FilesystemException
*
*/
function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array
{
error_clear_last();
$safeResult = \parse_ini_file($filename, $process_sections, $scanner_mode);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $ini_string
* @param bool $process_sections
* @param int $scanner_mode
* @return array
* @throws FilesystemException
*
*/
function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array
{
error_clear_last();
$safeResult = \parse_ini_string($ini_string, $process_sections, $scanner_mode);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $handle
* @return int
* @throws FilesystemException
*
*/
function pclose($handle): int
{
error_clear_last();
$safeResult = \pclose($handle);
if ($safeResult === -1) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $command
* @param string $mode
* @return resource
* @throws FilesystemException
*
*/
function popen(string $command, string $mode)
{
error_clear_last();
$safeResult = \popen($command, $mode);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @param bool $use_include_path
* @param null|resource $context
* @return 0|positive-int
* @throws FilesystemException
*
*/
function readfile(string $filename, bool $use_include_path = false, $context = null): int
{
error_clear_last();
if ($context !== null) {
$safeResult = \readfile($filename, $use_include_path, $context);
} else {
$safeResult = \readfile($filename, $use_include_path);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $path
* @return string
* @throws FilesystemException
*
*/
function readlink(string $path): string
{
error_clear_last();
$safeResult = \readlink($path);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $path
* @return non-empty-string
* @throws FilesystemException
*
*/
function realpath(string $path): string
{
error_clear_last();
$safeResult = \realpath($path);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $from
* @param string $to
* @param null|resource $context
* @throws FilesystemException
*
*/
function rename(string $from, string $to, $context = null): void
{
error_clear_last();
if ($context !== null) {
$safeResult = \rename($from, $to, $context);
} else {
$safeResult = \rename($from, $to);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param resource $stream
* @throws FilesystemException
*
*/
function rewind($stream): void
{
error_clear_last();
$safeResult = \rewind($stream);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $directory
* @param null|resource $context
* @throws FilesystemException
*
*/
function rmdir(string $directory, $context = null): void
{
error_clear_last();
if ($context !== null) {
$safeResult = \rmdir($directory, $context);
} else {
$safeResult = \rmdir($directory);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $target
* @param string $link
* @throws FilesystemException
*
*/
function symlink(string $target, string $link): void
{
error_clear_last();
$safeResult = \symlink($target, $link);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $directory
* @param string $prefix
* @return non-falsy-string
* @throws FilesystemException
*
*/
function tempnam(string $directory, string $prefix): string
{
error_clear_last();
$safeResult = \tempnam($directory, $prefix);
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @return resource
* @throws FilesystemException
*
*/
function tmpfile()
{
error_clear_last();
$safeResult = \tmpfile();
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filename
* @param int|null $mtime
* @param int|null $atime
* @throws FilesystemException
*
*/
function touch(string $filename, ?int $mtime = null, ?int $atime = null): void
{
error_clear_last();
if ($atime !== null) {
$safeResult = \touch($filename, $mtime, $atime);
} elseif ($mtime !== null) {
$safeResult = \touch($filename, $mtime);
} else {
$safeResult = \touch($filename);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}
/**
* @param string $filename
* @param null|resource $context
* @throws FilesystemException
*
*/
function unlink(string $filename, $context = null): void
{
error_clear_last();
if ($context !== null) {
$safeResult = \unlink($filename, $context);
} else {
$safeResult = \unlink($filename);
}
if ($safeResult === false) {
throw FilesystemException::createFromPhpError();
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Safe;
use Safe\Exceptions\FpmException;
/**
* @throws FpmException
*
*/
function fastcgi_finish_request(): void
{
error_clear_last();
$safeResult = \fastcgi_finish_request();
if ($safeResult === false) {
throw FpmException::createFromPhpError();
}
}
/**
* @return array{pool: string, process-manager: 'dynamic'|'ondemand'|'static', start-time: int, start-since: int, accepted-conn: int, listen-queue: int, max-listen-queue: int, listen-queue-len: int, idle-processes: int, active-processes: int, total-processes: int, max-active-processes: int, max-children-reached: 0|1, slow-requests: int, procs: array}
* @throws FpmException
*
*/
function fpm_get_status(): array
{
error_clear_last();
$safeResult = \fpm_get_status();
if ($safeResult === false) {
throw FpmException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
<?php
namespace Safe;
use Safe\Exceptions\GmpException;
/**
* @param \GMP|int|string $seed
*
*/
function gmp_random_seed($seed): void
{
error_clear_last();
$safeResult = \gmp_random_seed($seed);
}

View File

@@ -0,0 +1,152 @@
<?php
namespace Safe;
use Safe\Exceptions\GnupgException;
/**
* @param resource $identifier
* @param string $fingerprint
* @param string $passphrase
* @throws GnupgException
*
*/
function gnupg_adddecryptkey($identifier, string $fingerprint, string $passphrase): void
{
error_clear_last();
$safeResult = \gnupg_adddecryptkey($identifier, $fingerprint, $passphrase);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @param string $fingerprint
* @throws GnupgException
*
*/
function gnupg_addencryptkey($identifier, string $fingerprint): void
{
error_clear_last();
$safeResult = \gnupg_addencryptkey($identifier, $fingerprint);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @param string $fingerprint
* @param string $passphrase
* @throws GnupgException
*
*/
function gnupg_addsignkey($identifier, string $fingerprint, ?string $passphrase = null): void
{
error_clear_last();
if ($passphrase !== null) {
$safeResult = \gnupg_addsignkey($identifier, $fingerprint, $passphrase);
} else {
$safeResult = \gnupg_addsignkey($identifier, $fingerprint);
}
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @throws GnupgException
*
*/
function gnupg_cleardecryptkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_cleardecryptkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @throws GnupgException
*
*/
function gnupg_clearencryptkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_clearencryptkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @throws GnupgException
*
*/
function gnupg_clearsignkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_clearsignkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @param string $key
* @param bool $allow_secret
* @throws GnupgException
*
*/
function gnupg_deletekey($identifier, string $key, bool $allow_secret): void
{
error_clear_last();
$safeResult = \gnupg_deletekey($identifier, $key, $allow_secret);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @param int $armor
* @throws GnupgException
*
*/
function gnupg_setarmor($identifier, int $armor): void
{
error_clear_last();
$safeResult = \gnupg_setarmor($identifier, $armor);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* @param resource $identifier
* @param int $signmode
* @throws GnupgException
*
*/
function gnupg_setsignmode($identifier, int $signmode): void
{
error_clear_last();
$safeResult = \gnupg_setsignmode($identifier, $signmode);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Safe;
use Safe\Exceptions\HashException;
/**
* @param string $algo
* @param string $key
* @param int $length
* @param string $info
* @param string $salt
* @return false|non-falsy-string
*
*/
function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "", string $salt = "")
{
error_clear_last();
$safeResult = \hash_hkdf($algo, $key, $length, $info, $salt);
return $safeResult;
}
/**
* @param \HashContext $context
* @param string $filename
* @param \HashContext|null $stream_context
* @throws HashException
*
*/
function hash_update_file(\HashContext $context, string $filename, ?\HashContext $stream_context = null): void
{
error_clear_last();
if ($stream_context !== null) {
$safeResult = \hash_update_file($context, $filename, $stream_context);
} else {
$safeResult = \hash_update_file($context, $filename);
}
if ($safeResult === false) {
throw HashException::createFromPhpError();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,895 @@
<?php
namespace Safe;
use Safe\Exceptions\ImapException;
/**
* @param string $string
* @return string
* @throws ImapException
*
*/
function imap_8bit(string $string): string
{
error_clear_last();
$safeResult = \imap_8bit($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $folder
* @param string $message
* @param null|string $options
* @param null|string $internal_date
* @throws ImapException
*
*/
function imap_append(\IMAP\Connection $imap, string $folder, string $message, ?string $options = null, ?string $internal_date = null): void
{
error_clear_last();
if ($internal_date !== null) {
$safeResult = \imap_append($imap, $folder, $message, $options, $internal_date);
} elseif ($options !== null) {
$safeResult = \imap_append($imap, $folder, $message, $options);
} else {
$safeResult = \imap_append($imap, $folder, $message);
}
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param string $string
* @return string
* @throws ImapException
*
*/
function imap_base64(string $string): string
{
error_clear_last();
$safeResult = \imap_base64($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $string
* @return string
* @throws ImapException
*
*/
function imap_binary(string $string): string
{
error_clear_last();
$safeResult = \imap_binary($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param int $flags
* @return string
* @throws ImapException
*
*/
function imap_body(\IMAP\Connection $imap, int $message_num, int $flags = 0): string
{
error_clear_last();
$safeResult = \imap_body($imap, $message_num, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param string $section
* @return \stdClass
* @throws ImapException
*
*/
function imap_bodystruct(\IMAP\Connection $imap, int $message_num, string $section): \stdClass
{
error_clear_last();
$safeResult = \imap_bodystruct($imap, $message_num, $section);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @return \stdClass
* @throws ImapException
*
*/
function imap_check(\IMAP\Connection $imap): \stdClass
{
error_clear_last();
$safeResult = \imap_check($imap);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $sequence
* @param string $flag
* @param int $options
* @throws ImapException
*
*/
function imap_clearflag_full(\IMAP\Connection $imap, string $sequence, string $flag, int $options = 0): void
{
error_clear_last();
$safeResult = \imap_clearflag_full($imap, $sequence, $flag, $options);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param int $flags
* @throws ImapException
*
*/
function imap_close(\IMAP\Connection $imap, int $flags = 0): void
{
error_clear_last();
$safeResult = \imap_close($imap, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @throws ImapException
*
*/
function imap_createmailbox(\IMAP\Connection $imap, string $mailbox): void
{
error_clear_last();
$safeResult = \imap_createmailbox($imap, $mailbox);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @throws ImapException
*
*/
function imap_deletemailbox(\IMAP\Connection $imap, string $mailbox): void
{
error_clear_last();
$safeResult = \imap_deletemailbox($imap, $mailbox);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $sequence
* @param int $flags
* @return array
* @throws ImapException
*
*/
function imap_fetch_overview(\IMAP\Connection $imap, string $sequence, int $flags = 0): array
{
error_clear_last();
$safeResult = \imap_fetch_overview($imap, $sequence, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param string $section
* @param int $flags
* @return string
* @throws ImapException
*
*/
function imap_fetchbody(\IMAP\Connection $imap, int $message_num, string $section, int $flags = 0): string
{
error_clear_last();
$safeResult = \imap_fetchbody($imap, $message_num, $section, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param int $flags
* @return string
* @throws ImapException
*
*/
function imap_fetchheader(\IMAP\Connection $imap, int $message_num, int $flags = 0): string
{
error_clear_last();
$safeResult = \imap_fetchheader($imap, $message_num, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param string $section
* @param int $flags
* @return string
* @throws ImapException
*
*/
function imap_fetchmime(\IMAP\Connection $imap, int $message_num, string $section, int $flags = 0): string
{
error_clear_last();
$safeResult = \imap_fetchmime($imap, $message_num, $section, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param int $flags
* @return \stdClass
* @throws ImapException
*
*/
function imap_fetchstructure(\IMAP\Connection $imap, int $message_num, int $flags = 0): \stdClass
{
error_clear_last();
$safeResult = \imap_fetchstructure($imap, $message_num, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $flags
* @throws ImapException
*
*/
function imap_gc(\IMAP\Connection $imap, int $flags): void
{
error_clear_last();
$safeResult = \imap_gc($imap, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @return array
* @throws ImapException
*
*/
function imap_getacl(\IMAP\Connection $imap, string $mailbox): array
{
error_clear_last();
$safeResult = \imap_getacl($imap, $mailbox);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $reference
* @param string $pattern
* @return array
* @throws ImapException
*
*/
function imap_getmailboxes(\IMAP\Connection $imap, string $reference, string $pattern): array
{
error_clear_last();
$safeResult = \imap_getmailboxes($imap, $reference, $pattern);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $reference
* @param string $pattern
* @return array
* @throws ImapException
*
*/
function imap_getsubscribed(\IMAP\Connection $imap, string $reference, string $pattern): array
{
error_clear_last();
$safeResult = \imap_getsubscribed($imap, $reference, $pattern);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int $message_num
* @param int $from_length
* @param int $subject_length
* @return \stdClass
* @throws ImapException
*
*/
function imap_headerinfo(\IMAP\Connection $imap, int $message_num, int $from_length = 0, int $subject_length = 0): \stdClass
{
error_clear_last();
$safeResult = \imap_headerinfo($imap, $message_num, $from_length, $subject_length);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @return array
* @throws ImapException
*
*/
function imap_headers(\IMAP\Connection $imap): array
{
error_clear_last();
$safeResult = \imap_headers($imap);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $reference
* @param string $pattern
* @param string $content
* @return array
* @throws ImapException
*
*/
function imap_listscan(\IMAP\Connection $imap, string $reference, string $pattern, string $content): array
{
error_clear_last();
$safeResult = \imap_listscan($imap, $reference, $pattern, $content);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $reference
* @param string $pattern
* @return array
* @throws ImapException
*
*/
function imap_lsub(\IMAP\Connection $imap, string $reference, string $pattern): array
{
error_clear_last();
$safeResult = \imap_lsub($imap, $reference, $pattern);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param array $envelope
* @param array $bodies
* @return string
* @throws ImapException
*
*/
function imap_mail_compose(array $envelope, array $bodies): string
{
error_clear_last();
$safeResult = \imap_mail_compose($envelope, $bodies);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $message_nums
* @param string $mailbox
* @param int $flags
* @throws ImapException
*
*/
function imap_mail_copy(\IMAP\Connection $imap, string $message_nums, string $mailbox, int $flags = 0): void
{
error_clear_last();
$safeResult = \imap_mail_copy($imap, $message_nums, $mailbox, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $message_nums
* @param string $mailbox
* @param int $flags
* @throws ImapException
*
*/
function imap_mail_move(\IMAP\Connection $imap, string $message_nums, string $mailbox, int $flags = 0): void
{
error_clear_last();
$safeResult = \imap_mail_move($imap, $message_nums, $mailbox, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param string $to
* @param string $subject
* @param string $message
* @param null|string $additional_headers
* @param null|string $cc
* @param null|string $bcc
* @param null|string $return_path
* @throws ImapException
*
*/
function imap_mail(string $to, string $subject, string $message, ?string $additional_headers = null, ?string $cc = null, ?string $bcc = null, ?string $return_path = null): void
{
error_clear_last();
if ($return_path !== null) {
$safeResult = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc, $return_path);
} elseif ($bcc !== null) {
$safeResult = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc);
} elseif ($cc !== null) {
$safeResult = \imap_mail($to, $subject, $message, $additional_headers, $cc);
} elseif ($additional_headers !== null) {
$safeResult = \imap_mail($to, $subject, $message, $additional_headers);
} else {
$safeResult = \imap_mail($to, $subject, $message);
}
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @return \stdClass
* @throws ImapException
*
*/
function imap_mailboxmsginfo(\IMAP\Connection $imap): \stdClass
{
error_clear_last();
$safeResult = \imap_mailboxmsginfo($imap);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $string
* @return array
* @throws ImapException
*
*/
function imap_mime_header_decode(string $string): array
{
error_clear_last();
$safeResult = \imap_mime_header_decode($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $string
* @return string
* @throws ImapException
*
*/
function imap_mutf7_to_utf8(string $string): string
{
error_clear_last();
$safeResult = \imap_mutf7_to_utf8($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @return int
* @throws ImapException
*
*/
function imap_num_msg(\IMAP\Connection $imap): int
{
error_clear_last();
$safeResult = \imap_num_msg($imap);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $mailbox
* @param string $user
* @param string $password
* @param int $flags
* @param int $retries
* @param array $options
* @return \IMAP\Connection
* @throws ImapException
*
*/
function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = []): \IMAP\Connection
{
error_clear_last();
$safeResult = \imap_open($mailbox, $user, $password, $flags, $retries, $options);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $string
* @return string
* @throws ImapException
*
*/
function imap_qprint(string $string): string
{
error_clear_last();
$safeResult = \imap_qprint($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $from
* @param string $to
* @throws ImapException
*
*/
function imap_renamemailbox(\IMAP\Connection $imap, string $from, string $to): void
{
error_clear_last();
$safeResult = \imap_renamemailbox($imap, $from, $to);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param null|string $mailbox
* @param null|string $hostname
* @param null|string $personal
* @return string
* @throws ImapException
*
*/
function imap_rfc822_write_address(?string $mailbox, ?string $hostname, ?string $personal): string
{
error_clear_last();
$safeResult = \imap_rfc822_write_address($mailbox, $hostname, $personal);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param int|resource|string $file
* @param int $message_num
* @param string $section
* @param int $flags
* @throws ImapException
*
*/
function imap_savebody(\IMAP\Connection $imap, $file, int $message_num, string $section = "", int $flags = 0): void
{
error_clear_last();
$safeResult = \imap_savebody($imap, $file, $message_num, $section, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $quota_root
* @param int $mailbox_size
* @throws ImapException
*
*/
function imap_set_quota(\IMAP\Connection $imap, string $quota_root, int $mailbox_size): void
{
error_clear_last();
$safeResult = \imap_set_quota($imap, $quota_root, $mailbox_size);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @param string $user_id
* @param string $rights
* @throws ImapException
*
*/
function imap_setacl(\IMAP\Connection $imap, string $mailbox, string $user_id, string $rights): void
{
error_clear_last();
$safeResult = \imap_setacl($imap, $mailbox, $user_id, $rights);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $sequence
* @param string $flag
* @param int $options
* @throws ImapException
*
*/
function imap_setflag_full(\IMAP\Connection $imap, string $sequence, string $flag, int $options = 0): void
{
error_clear_last();
$safeResult = \imap_setflag_full($imap, $sequence, $flag, $options);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param int $criteria
* @param int $reverse
* @param int $flags
* @param null|string $search_criteria
* @param null|string $charset
* @return array
* @throws ImapException
*
*/
function imap_sort(\IMAP\Connection $imap, int $criteria, int $reverse, int $flags = 0, ?string $search_criteria = null, ?string $charset = null): array
{
error_clear_last();
if ($charset !== null) {
$safeResult = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria, $charset);
} elseif ($search_criteria !== null) {
$safeResult = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria);
} else {
$safeResult = \imap_sort($imap, $criteria, $reverse, $flags);
}
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @param int $flags
* @return \stdClass
* @throws ImapException
*
*/
function imap_status(\IMAP\Connection $imap, string $mailbox, int $flags): \stdClass
{
error_clear_last();
$safeResult = \imap_status($imap, $mailbox, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @throws ImapException
*
*/
function imap_subscribe(\IMAP\Connection $imap, string $mailbox): void
{
error_clear_last();
$safeResult = \imap_subscribe($imap, $mailbox);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param int $flags
* @return array
* @throws ImapException
*
*/
function imap_thread(\IMAP\Connection $imap, int $flags = SE_FREE): array
{
error_clear_last();
$safeResult = \imap_thread($imap, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $timeout_type
* @param int $timeout
* @return mixed
* @throws ImapException
*
*/
function imap_timeout(int $timeout_type, int $timeout = -1)
{
error_clear_last();
$safeResult = \imap_timeout($timeout_type, $timeout);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \IMAP\Connection $imap
* @param string $message_nums
* @param int $flags
* @throws ImapException
*
*/
function imap_undelete(\IMAP\Connection $imap, string $message_nums, int $flags = 0): void
{
error_clear_last();
$safeResult = \imap_undelete($imap, $message_nums, $flags);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param \IMAP\Connection $imap
* @param string $mailbox
* @throws ImapException
*
*/
function imap_unsubscribe(\IMAP\Connection $imap, string $mailbox): void
{
error_clear_last();
$safeResult = \imap_unsubscribe($imap, $mailbox);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
}
/**
* @param string $string
* @return string
* @throws ImapException
*
*/
function imap_utf8_to_mutf7(string $string): string
{
error_clear_last();
$safeResult = \imap_utf8_to_mutf7($string);
if ($safeResult === false) {
throw ImapException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,670 @@
<?php
namespace Safe;
use Safe\Exceptions\LdapException;
/**
* @param string $value
* @return string
* @throws LdapException
*
*/
function ldap_8859_to_t61(string $value): string
{
error_clear_last();
$safeResult = \ldap_8859_to_t61($value);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param array $entry
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_add(\LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_add($ldap, $dn, $entry, $controls);
} else {
$safeResult = \ldap_add($ldap, $dn, $entry);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param null|string $dn
* @param null|string $password
* @throws LdapException
*
*/
function ldap_bind(\LDAP\Connection $ldap, ?string $dn = null, ?string $password = null): void
{
error_clear_last();
if ($password !== null) {
$safeResult = \ldap_bind($ldap, $dn, $password);
} elseif ($dn !== null) {
$safeResult = \ldap_bind($ldap, $dn);
} else {
$safeResult = \ldap_bind($ldap);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param string $attribute
* @param string $value
* @param array|null $controls
* @return bool
* @throws LdapException
*
*/
function ldap_compare(\LDAP\Connection $ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_compare($ldap, $dn, $attribute, $value, $controls);
} else {
$safeResult = \ldap_compare($ldap, $dn, $attribute, $value);
}
if ($safeResult === -1) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $link
* @param resource $result
* @param null|string $cookie
* @param int|null $estimated
* @throws LdapException
*
*/
function ldap_control_paged_result_response($link, $result, ?string &$cookie = null, ?int &$estimated = null): void
{
error_clear_last();
$safeResult = \ldap_control_paged_result_response($link, $result, $cookie, $estimated);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param resource $link
* @param int $pagesize
* @param bool $iscritical
* @param string $cookie
* @throws LdapException
*
*/
function ldap_control_paged_result($link, int $pagesize, bool $iscritical = false, string $cookie = ""): void
{
error_clear_last();
$safeResult = \ldap_control_paged_result($link, $pagesize, $iscritical, $cookie);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\Result $result
* @return int
* @throws LdapException
*
*/
function ldap_count_entries(\LDAP\Connection $ldap, \LDAP\Result $result): int
{
error_clear_last();
$safeResult = \ldap_count_entries($ldap, $result);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_delete(\LDAP\Connection $ldap, string $dn, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_delete($ldap, $dn, $controls);
} else {
$safeResult = \ldap_delete($ldap, $dn);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param string $dn
* @return string
* @throws LdapException
*
*/
function ldap_dn2ufn(string $dn): string
{
error_clear_last();
$safeResult = \ldap_dn2ufn($dn);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param string $user
* @param string $old_password
* @param string $new_password
* @param array|null $controls
* @return bool|string
* @throws LdapException
*
*/
function ldap_exop_passwd(\LDAP\Connection $ldap, string $user = "", string $old_password = "", string $new_password = "", ?array &$controls = null)
{
error_clear_last();
$safeResult = \ldap_exop_passwd($ldap, $user, $old_password, $new_password, $controls);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @return bool|string
* @throws LdapException
*
*/
function ldap_exop_whoami(\LDAP\Connection $ldap)
{
error_clear_last();
$safeResult = \ldap_exop_whoami($ldap);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param string $request_oid
* @param null|string $request_data
* @param array|null $controls
* @param null|string $response_data
* @param null|string $response_oid
* @return bool|resource
* @throws LdapException
*
*/
function ldap_exop(\LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = null, ?string &$response_data = null, ?string &$response_oid = null)
{
error_clear_last();
if ($response_oid !== null) {
$safeResult = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data, $response_oid);
} elseif ($response_data !== null) {
$safeResult = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data);
} elseif ($controls !== null) {
$safeResult = \ldap_exop($ldap, $request_oid, $request_data, $controls);
} elseif ($request_data !== null) {
$safeResult = \ldap_exop($ldap, $request_oid, $request_data);
} else {
$safeResult = \ldap_exop($ldap, $request_oid);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $dn
* @param int $with_attrib
* @return array
* @throws LdapException
*
*/
function ldap_explode_dn(string $dn, int $with_attrib): array
{
error_clear_last();
$safeResult = \ldap_explode_dn($dn, $with_attrib);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\ResultEntry $entry
* @return string
* @throws LdapException
*
*/
function ldap_first_attribute(\LDAP\Connection $ldap, \LDAP\ResultEntry $entry): string
{
error_clear_last();
$safeResult = \ldap_first_attribute($ldap, $entry);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\Result $result
* @return \LDAP\ResultEntry
* @throws LdapException
*
*/
function ldap_first_entry(\LDAP\Connection $ldap, \LDAP\Result $result): \LDAP\ResultEntry
{
error_clear_last();
$safeResult = \ldap_first_entry($ldap, $result);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Result $result
* @throws LdapException
*
*/
function ldap_free_result(\LDAP\Result $result): void
{
error_clear_last();
$safeResult = \ldap_free_result($result);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\ResultEntry $entry
* @return array
* @throws LdapException
*
*/
function ldap_get_attributes(\LDAP\Connection $ldap, \LDAP\ResultEntry $entry): array
{
error_clear_last();
$safeResult = \ldap_get_attributes($ldap, $entry);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\ResultEntry $entry
* @return string
* @throws LdapException
*
*/
function ldap_get_dn(\LDAP\Connection $ldap, \LDAP\ResultEntry $entry): string
{
error_clear_last();
$safeResult = \ldap_get_dn($ldap, $entry);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\Result $result
* @return array
* @throws LdapException
*
*/
function ldap_get_entries(\LDAP\Connection $ldap, \LDAP\Result $result): array
{
error_clear_last();
$safeResult = \ldap_get_entries($ldap, $result);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param int $option
* @param mixed $value
* @throws LdapException
*
*/
function ldap_get_option(\LDAP\Connection $ldap, int $option, &$value = null): void
{
error_clear_last();
$safeResult = \ldap_get_option($ldap, $option, $value);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\ResultEntry $entry
* @param string $attribute
* @return array
* @throws LdapException
*
*/
function ldap_get_values_len(\LDAP\Connection $ldap, \LDAP\ResultEntry $entry, string $attribute): array
{
error_clear_last();
$safeResult = \ldap_get_values_len($ldap, $entry, $attribute);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\ResultEntry $entry
* @param string $attribute
* @return array
* @throws LdapException
*
*/
function ldap_get_values(\LDAP\Connection $ldap, \LDAP\ResultEntry $entry, string $attribute): array
{
error_clear_last();
$safeResult = \ldap_get_values($ldap, $entry, $attribute);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param array $entry
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_mod_add(\LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_mod_add($ldap, $dn, $entry, $controls);
} else {
$safeResult = \ldap_mod_add($ldap, $dn, $entry);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param array $entry
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_mod_del(\LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_mod_del($ldap, $dn, $entry, $controls);
} else {
$safeResult = \ldap_mod_del($ldap, $dn, $entry);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param array $entry
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_mod_replace(\LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_mod_replace($ldap, $dn, $entry, $controls);
} else {
$safeResult = \ldap_mod_replace($ldap, $dn, $entry);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param array $modifications_info
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_modify_batch(\LDAP\Connection $ldap, string $dn, array $modifications_info, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_modify_batch($ldap, $dn, $modifications_info, $controls);
} else {
$safeResult = \ldap_modify_batch($ldap, $dn, $modifications_info);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\ResultEntry $entry
* @return string
* @throws LdapException
*
*/
function ldap_next_attribute(\LDAP\Connection $ldap, \LDAP\ResultEntry $entry): string
{
error_clear_last();
$safeResult = \ldap_next_attribute($ldap, $entry);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\Result $result
* @param null|string $response_data
* @param null|string $response_oid
* @throws LdapException
*
*/
function ldap_parse_exop(\LDAP\Connection $ldap, \LDAP\Result $result, ?string &$response_data = null, ?string &$response_oid = null): void
{
error_clear_last();
$safeResult = \ldap_parse_exop($ldap, $result, $response_data, $response_oid);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param \LDAP\Result $result
* @param int|null $error_code
* @param null|string $matched_dn
* @param null|string $error_message
* @param array|null $referrals
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_parse_result(\LDAP\Connection $ldap, \LDAP\Result $result, ?int &$error_code, ?string &$matched_dn = null, ?string &$error_message = null, ?array &$referrals = null, ?array &$controls = null): void
{
error_clear_last();
$safeResult = \ldap_parse_result($ldap, $result, $error_code, $matched_dn, $error_message, $referrals, $controls);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param string $dn
* @param string $new_rdn
* @param string $new_parent
* @param bool $delete_old_rdn
* @param array|null $controls
* @throws LdapException
*
*/
function ldap_rename(\LDAP\Connection $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): void
{
error_clear_last();
if ($controls !== null) {
$safeResult = \ldap_rename($ldap, $dn, $new_rdn, $new_parent, $delete_old_rdn, $controls);
} else {
$safeResult = \ldap_rename($ldap, $dn, $new_rdn, $new_parent, $delete_old_rdn);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @param null|string $dn
* @param null|string $password
* @param null|string $mech
* @param null|string $realm
* @param null|string $authc_id
* @param null|string $authz_id
* @param null|string $props
* @throws LdapException
*
*/
function ldap_sasl_bind(\LDAP\Connection $ldap, ?string $dn = null, ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authc_id = null, ?string $authz_id = null, ?string $props = null): void
{
error_clear_last();
if ($props !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id, $authz_id, $props);
} elseif ($authz_id !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id, $authz_id);
} elseif ($authc_id !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id);
} elseif ($realm !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm);
} elseif ($mech !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn, $password, $mech);
} elseif ($password !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn, $password);
} elseif ($dn !== null) {
$safeResult = \ldap_sasl_bind($ldap, $dn);
} else {
$safeResult = \ldap_sasl_bind($ldap);
}
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param null|resource $ldap
* @param int $option
* @param mixed $value
* @throws LdapException
*
*/
function ldap_set_option($ldap, int $option, $value): void
{
error_clear_last();
$safeResult = \ldap_set_option($ldap, $option, $value);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}
/**
* @param \LDAP\Connection $ldap
* @throws LdapException
*
*/
function ldap_unbind(\LDAP\Connection $ldap): void
{
error_clear_last();
$safeResult = \ldap_unbind($ldap);
if ($safeResult === false) {
throw LdapException::createFromPhpError();
}
}

View File

@@ -0,0 +1,247 @@
<?php
namespace Safe;
use Safe\Exceptions\MiscException;
/**
* @param string $constant_name
* @param mixed $value
* @param bool $case_insensitive
* @throws MiscException
*
*/
function define(string $constant_name, $value, bool $case_insensitive = false): void
{
error_clear_last();
$safeResult = \define($constant_name, $value, $case_insensitive);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
}
/**
* @param string $filename
* @param bool $return
* @return bool|string
* @throws MiscException
*
*/
function highlight_file(string $filename, bool $return = false)
{
error_clear_last();
$safeResult = \highlight_file($filename, $return);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $string
* @param bool $return
* @return bool|string
* @throws MiscException
*
*/
function highlight_string(string $string, bool $return = false)
{
error_clear_last();
$safeResult = \highlight_string($string, $return);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
/**
* @param bool $as_number
* @return array{0:int,1:int}|float|int
* @throws MiscException
*
*/
function hrtime(bool $as_number = false)
{
error_clear_last();
$safeResult = \hrtime($as_number);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $format
* @param mixed $values
* @return string
* @throws MiscException
*
*/
function pack(string $format, ...$values): string
{
error_clear_last();
if ($values !== []) {
$safeResult = \pack($format, ...$values);
} else {
$safeResult = \pack($format);
}
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int|string $in_codepage
* @param int|string $out_codepage
* @param string $subject
* @return string
* @throws MiscException
*
*/
function sapi_windows_cp_conv($in_codepage, $out_codepage, string $subject): string
{
error_clear_last();
$safeResult = \sapi_windows_cp_conv($in_codepage, $out_codepage, $subject);
if ($safeResult === null) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $codepage
* @throws MiscException
*
*/
function sapi_windows_cp_set(int $codepage): void
{
error_clear_last();
$safeResult = \sapi_windows_cp_set($codepage);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
}
/**
* @param int $event
* @param int $pid
* @throws MiscException
*
*/
function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): void
{
error_clear_last();
$safeResult = \sapi_windows_generate_ctrl_event($event, $pid);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
}
/**
* @param callable|null $handler
* @param bool $add
* @throws MiscException
*
*/
function sapi_windows_set_ctrl_handler(?callable $handler, bool $add = true): void
{
error_clear_last();
$safeResult = \sapi_windows_set_ctrl_handler($handler, $add);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
}
/**
* @param resource $stream
* @param bool|null $enable
* @throws MiscException
*
*/
function sapi_windows_vt100_support($stream, ?bool $enable = null): void
{
error_clear_last();
if ($enable !== null) {
$safeResult = \sapi_windows_vt100_support($stream, $enable);
} else {
$safeResult = \sapi_windows_vt100_support($stream);
}
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
}
/**
* @param int $seconds
* @return false|int
*
*/
function sleep(int $seconds)
{
error_clear_last();
$safeResult = \sleep($seconds);
return $safeResult;
}
/**
* @param int $seconds
* @param int $nanoseconds
* @return array{seconds:0|positive-int,nanoseconds:0|positive-int}|bool
* @throws MiscException
*
*/
function time_nanosleep(int $seconds, int $nanoseconds)
{
error_clear_last();
$safeResult = \time_nanosleep($seconds, $nanoseconds);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
/**
* @param float $timestamp
* @throws MiscException
*
*/
function time_sleep_until(float $timestamp): void
{
error_clear_last();
$safeResult = \time_sleep_until($timestamp);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
}
/**
* @param string $format
* @param string $string
* @param int $offset
* @return array
* @throws MiscException
*
*/
function unpack(string $format, string $string, int $offset = 0): array
{
error_clear_last();
$safeResult = \unpack($format, $string, $offset);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Safe;
use Safe\Exceptions\MysqliException;
/**
* @return array|false
*
*/
function mysqli_get_client_stats()
{
error_clear_last();
$safeResult = \mysqli_get_client_stats();
return $safeResult;
}

View File

@@ -0,0 +1,272 @@
<?php
namespace Safe;
use Safe\Exceptions\NetworkException;
/**
* @throws NetworkException
*
*/
function closelog(): void
{
error_clear_last();
$safeResult = \closelog();
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
}
/**
* @param string $hostname
* @param int $type
* @param array|null $authoritative_name_servers
* @param array|null $additional_records
* @param bool $raw
* @return list
* @throws NetworkException
*
*/
function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authoritative_name_servers = null, ?array &$additional_records = null, bool $raw = false): array
{
error_clear_last();
$safeResult = \dns_get_record($hostname, $type, $authoritative_name_servers, $additional_records, $raw);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $hostname
* @param int $port
* @param int|null $error_code
* @param null|string $error_message
* @param float|null $timeout
* @return resource
* @throws NetworkException
*
*/
function fsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ?string &$error_message = null, ?float $timeout = null)
{
error_clear_last();
if ($timeout !== null) {
$safeResult = \fsockopen($hostname, $port, $error_code, $error_message, $timeout);
} else {
$safeResult = \fsockopen($hostname, $port, $error_code, $error_message);
}
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @return string
* @throws NetworkException
*
*/
function gethostname(): string
{
error_clear_last();
$safeResult = \gethostname();
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $protocol
* @return int
* @throws NetworkException
*
*/
function getprotobyname(string $protocol): int
{
error_clear_last();
$safeResult = \getprotobyname($protocol);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $protocol
* @return string
* @throws NetworkException
*
*/
function getprotobynumber(int $protocol): string
{
error_clear_last();
$safeResult = \getprotobynumber($protocol);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $port
* @param string $protocol
* @return string
* @throws NetworkException
*
*/
function getservbyport(int $port, string $protocol): string
{
error_clear_last();
$safeResult = \getservbyport($port, $protocol);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param callable $callback
* @throws NetworkException
*
*/
function header_register_callback(callable $callback): void
{
error_clear_last();
$safeResult = \header_register_callback($callback);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
}
/**
* @param string $ip
* @return string
* @throws NetworkException
*
*/
function inet_ntop(string $ip): string
{
error_clear_last();
$safeResult = \inet_ntop($ip);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $ip
* @return string
* @throws NetworkException
*
*/
function inet_pton(string $ip): string
{
error_clear_last();
$safeResult = \inet_pton($ip);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $ip
* @return string
* @throws NetworkException
*
*/
function long2ip(int $ip): string
{
error_clear_last();
$safeResult = \long2ip($ip);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @return array
* @throws NetworkException
*
*/
function net_get_interfaces(): array
{
error_clear_last();
$safeResult = \net_get_interfaces();
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $prefix
* @param int $flags
* @param int $facility
* @throws NetworkException
*
*/
function openlog(string $prefix, int $flags, int $facility): void
{
error_clear_last();
$safeResult = \openlog($prefix, $flags, $facility);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
}
/**
* @param string $hostname
* @param int $port
* @param int|null $error_code
* @param null|string $error_message
* @param float|null $timeout
* @return resource
* @throws NetworkException
*
*/
function pfsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ?string &$error_message = null, ?float $timeout = null)
{
error_clear_last();
if ($timeout !== null) {
$safeResult = \pfsockopen($hostname, $port, $error_code, $error_message, $timeout);
} else {
$safeResult = \pfsockopen($hostname, $port, $error_code, $error_message);
}
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $priority
* @param string $message
* @throws NetworkException
*
*/
function syslog(int $priority, string $message): void
{
error_clear_last();
$safeResult = \syslog($priority, $message);
if ($safeResult === false) {
throw NetworkException::createFromPhpError();
}
}

View File

@@ -0,0 +1,666 @@
<?php
namespace Safe;
use Safe\Exceptions\Oci8Exception;
/**
* @param resource $statement
* @param string $param
* @param array $var
* @param int $max_array_length
* @param int $max_item_length
* @param int $type
* @throws Oci8Exception
*
*/
function oci_bind_array_by_name($statement, string $param, array &$var, int $max_array_length, int $max_item_length = -1, int $type = SQLT_AFC): void
{
error_clear_last();
$safeResult = \oci_bind_array_by_name($statement, $param, $var, $max_array_length, $max_item_length, $type);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @param string $param
* @param mixed $var
* @param int $max_length
* @param int $type
* @throws Oci8Exception
*
*/
function oci_bind_by_name($statement, string $param, &$var, int $max_length = -1, int $type = 0): void
{
error_clear_last();
$safeResult = \oci_bind_by_name($statement, $param, $var, $max_length, $type);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @throws Oci8Exception
*
*/
function oci_cancel($statement): void
{
error_clear_last();
$safeResult = \oci_cancel($statement);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @throws Oci8Exception
*
*/
function oci_commit($connection): void
{
error_clear_last();
$safeResult = \oci_commit($connection);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param string $username
* @param string $password
* @param null|string $connection_string
* @param string $encoding
* @param int $session_mode
* @return resource
* @throws Oci8Exception
*
*/
function oci_connect(string $username, string $password, ?string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT)
{
error_clear_last();
if ($session_mode !== OCI_DEFAULT) {
$safeResult = \oci_connect($username, $password, $connection_string, $encoding, $session_mode);
} elseif ($encoding !== "") {
$safeResult = \oci_connect($username, $password, $connection_string, $encoding);
} elseif ($connection_string !== null) {
$safeResult = \oci_connect($username, $password, $connection_string);
} else {
$safeResult = \oci_connect($username, $password);
}
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @param string $column
* @param mixed $var
* @param int $type
* @throws Oci8Exception
*
*/
function oci_define_by_name($statement, string $column, &$var, int $type = 0): void
{
error_clear_last();
$safeResult = \oci_define_by_name($statement, $column, $var, $type);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @param int $mode
* @throws Oci8Exception
*
*/
function oci_execute($statement, int $mode = OCI_COMMIT_ON_SUCCESS): void
{
error_clear_last();
$safeResult = \oci_execute($statement, $mode);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @param mixed $column
* @return string
* @throws Oci8Exception
*
*/
function oci_field_name($statement, $column): string
{
error_clear_last();
$safeResult = \oci_field_name($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @param mixed $column
* @return int
* @throws Oci8Exception
*
*/
function oci_field_precision($statement, $column): int
{
error_clear_last();
$safeResult = \oci_field_precision($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @param mixed $column
* @return int
* @throws Oci8Exception
*
*/
function oci_field_scale($statement, $column): int
{
error_clear_last();
$safeResult = \oci_field_scale($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @param mixed $column
* @return int
* @throws Oci8Exception
*
*/
function oci_field_size($statement, $column): int
{
error_clear_last();
$safeResult = \oci_field_size($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @param mixed $column
* @return int
* @throws Oci8Exception
*
*/
function oci_field_type_raw($statement, $column): int
{
error_clear_last();
$safeResult = \oci_field_type_raw($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @param mixed $column
* @return mixed
* @throws Oci8Exception
*
*/
function oci_field_type($statement, $column)
{
error_clear_last();
$safeResult = \oci_field_type($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param \OCILob $lob
* @throws Oci8Exception
*
*/
function oci_free_descriptor(\OCILob $lob): void
{
error_clear_last();
$safeResult = \oci_free_descriptor($lob);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @throws Oci8Exception
*
*/
function oci_free_statement($statement): void
{
error_clear_last();
$safeResult = \oci_free_statement($statement);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @param string $type_name
* @param null|string $schema
* @return \OCI-Collection
* @throws Oci8Exception
*
*/
function oci_new_collection($connection, string $type_name, ?string $schema = null)
{
error_clear_last();
if ($schema !== null) {
$safeResult = \oci_new_collection($connection, $type_name, $schema);
} else {
$safeResult = \oci_new_collection($connection, $type_name);
}
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $username
* @param string $password
* @param null|string $connection_string
* @param string $encoding
* @param int $session_mode
* @return resource
* @throws Oci8Exception
*
*/
function oci_new_connect(string $username, string $password, ?string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT)
{
error_clear_last();
if ($session_mode !== OCI_DEFAULT) {
$safeResult = \oci_new_connect($username, $password, $connection_string, $encoding, $session_mode);
} elseif ($encoding !== "") {
$safeResult = \oci_new_connect($username, $password, $connection_string, $encoding);
} elseif ($connection_string !== null) {
$safeResult = \oci_new_connect($username, $password, $connection_string);
} else {
$safeResult = \oci_new_connect($username, $password);
}
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @return resource
* @throws Oci8Exception
*
*/
function oci_new_cursor($connection)
{
error_clear_last();
$safeResult = \oci_new_cursor($connection);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @param int $type
* @return \OCI-Lob|false
* @throws Oci8Exception
*
*/
function oci_new_descriptor($connection, int $type = OCI_DTYPE_LOB)
{
error_clear_last();
$safeResult = \oci_new_descriptor($connection, $type);
if ($safeResult === null) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $statement
* @return 0|positive-int
* @throws Oci8Exception
*
*/
function oci_num_rows($statement): int
{
error_clear_last();
$safeResult = \oci_num_rows($statement);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @param string $sql
* @return resource
* @throws Oci8Exception
*
*/
function oci_parse($connection, string $sql)
{
error_clear_last();
$safeResult = \oci_parse($connection, $sql);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $username
* @param string $password
* @param null|string $connection_string
* @param string $encoding
* @param int $session_mode
* @return resource
* @throws Oci8Exception
*
*/
function oci_pconnect(string $username, string $password, ?string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT)
{
error_clear_last();
if ($session_mode !== OCI_DEFAULT) {
$safeResult = \oci_pconnect($username, $password, $connection_string, $encoding, $session_mode);
} elseif ($encoding !== "") {
$safeResult = \oci_pconnect($username, $password, $connection_string, $encoding);
} elseif ($connection_string !== null) {
$safeResult = \oci_pconnect($username, $password, $connection_string);
} else {
$safeResult = \oci_pconnect($username, $password);
}
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @param callable $callback
* @throws Oci8Exception
*
*/
function oci_register_taf_callback($connection, callable $callback): void
{
error_clear_last();
$safeResult = \oci_register_taf_callback($connection, $callback);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @param mixed $column
* @return string
* @throws Oci8Exception
*
*/
function oci_result($statement, $column): string
{
error_clear_last();
$safeResult = \oci_result($statement, $column);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @throws Oci8Exception
*
*/
function oci_rollback($connection): void
{
error_clear_last();
$safeResult = \oci_rollback($connection);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @return string
* @throws Oci8Exception
*
*/
function oci_server_version($connection): string
{
error_clear_last();
$safeResult = \oci_server_version($connection);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @param string $action
* @throws Oci8Exception
*
*/
function oci_set_action($connection, string $action): void
{
error_clear_last();
$safeResult = \oci_set_action($connection, $action);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @param int $timeout
* @throws Oci8Exception
*
*/
function oci_set_call_timeout($connection, int $timeout): void
{
error_clear_last();
$safeResult = \oci_set_call_timeout($connection, $timeout);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @param string $client_id
* @throws Oci8Exception
*
*/
function oci_set_client_identifier($connection, string $client_id): void
{
error_clear_last();
$safeResult = \oci_set_client_identifier($connection, $client_id);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @param string $client_info
* @throws Oci8Exception
*
*/
function oci_set_client_info($connection, string $client_info): void
{
error_clear_last();
$safeResult = \oci_set_client_info($connection, $client_info);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @param string $action
* @throws Oci8Exception
*
*/
function oci_set_db_operation($connection, string $action): void
{
error_clear_last();
$safeResult = \oci_set_db_operation($connection, $action);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param string $edition
* @throws Oci8Exception
*
*/
function oci_set_edition(string $edition): void
{
error_clear_last();
$safeResult = \oci_set_edition($edition);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $connection
* @param string $name
* @throws Oci8Exception
*
*/
function oci_set_module_name($connection, string $name): void
{
error_clear_last();
$safeResult = \oci_set_module_name($connection, $name);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @param int $prefetch_lob_size
* @throws Oci8Exception
*
*/
function oci_set_prefetch_lob($statement, int $prefetch_lob_size): void
{
error_clear_last();
$safeResult = \oci_set_prefetch_lob($statement, $prefetch_lob_size);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @param int $rows
* @throws Oci8Exception
*
*/
function oci_set_prefetch($statement, int $rows): void
{
error_clear_last();
$safeResult = \oci_set_prefetch($statement, $rows);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}
/**
* @param resource $statement
* @return string
* @throws Oci8Exception
*
*/
function oci_statement_type($statement): string
{
error_clear_last();
$safeResult = \oci_statement_type($statement);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $connection
* @throws Oci8Exception
*
*/
function oci_unregister_taf_callback($connection): void
{
error_clear_last();
$safeResult = \oci_unregister_taf_callback($connection);
if ($safeResult === false) {
throw Oci8Exception::createFromPhpError();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,537 @@
<?php
namespace Safe;
use Safe\Exceptions\RnpException;
/**
* @param \RnpFFI $ffi
* @param string $input
* @return string
* @throws RnpException
*
*/
function rnp_decrypt(\RnpFFI $ffi, string $input): string
{
error_clear_last();
$safeResult = \rnp_decrypt($ffi, $input);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $input
* @param int $flags
* @return string
* @throws RnpException
*
*/
function rnp_dump_packets_to_json(string $input, int $flags): string
{
error_clear_last();
$safeResult = \rnp_dump_packets_to_json($input, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $input
* @param int $flags
* @return string
* @throws RnpException
*
*/
function rnp_dump_packets(string $input, int $flags): string
{
error_clear_last();
$safeResult = \rnp_dump_packets($input, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $pub_format
* @param string $sec_format
* @return \RnpFFI
* @throws RnpException
*
*/
function rnp_ffi_create(string $pub_format, string $sec_format): \RnpFFI
{
error_clear_last();
$safeResult = \rnp_ffi_create($pub_format, $sec_format);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param callable $password_callback
* @throws RnpException
*
*/
function rnp_ffi_set_pass_provider(\RnpFFI $ffi, callable $password_callback): void
{
error_clear_last();
$safeResult = \rnp_ffi_set_pass_provider($ffi, $password_callback);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param \RnpFFI $ffi
* @param string $input
* @param int $flags
* @return string
* @throws RnpException
*
*/
function rnp_import_keys(\RnpFFI $ffi, string $input, int $flags): string
{
error_clear_last();
$safeResult = \rnp_import_keys($ffi, $input, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $input
* @param int $flags
* @return string
* @throws RnpException
*
*/
function rnp_import_signatures(\RnpFFI $ffi, string $input, int $flags): string
{
error_clear_last();
$safeResult = \rnp_import_signatures($ffi, $input, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $key_fp
* @param string $subkey_fp
* @param string $uid
* @param int $flags
* @return string
* @throws RnpException
*
*/
function rnp_key_export_autocrypt(\RnpFFI $ffi, string $key_fp, string $subkey_fp, string $uid, int $flags): string
{
error_clear_last();
$safeResult = \rnp_key_export_autocrypt($ffi, $key_fp, $subkey_fp, $uid, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $key_fp
* @param int $flags
* @param array $options
* @return string
* @throws RnpException
*
*/
function rnp_key_export_revocation(\RnpFFI $ffi, string $key_fp, int $flags, ?array $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_key_export_revocation($ffi, $key_fp, $flags, $options);
} else {
$safeResult = \rnp_key_export_revocation($ffi, $key_fp, $flags);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $key_fp
* @param int $flags
* @return string
* @throws RnpException
*
*/
function rnp_key_export(\RnpFFI $ffi, string $key_fp, int $flags): string
{
error_clear_last();
$safeResult = \rnp_key_export($ffi, $key_fp, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $key_fp
* @return array
* @throws RnpException
*
*/
function rnp_key_get_info(\RnpFFI $ffi, string $key_fp): array
{
error_clear_last();
$safeResult = \rnp_key_get_info($ffi, $key_fp);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $key_fp
* @param int $flags
* @throws RnpException
*
*/
function rnp_key_remove(\RnpFFI $ffi, string $key_fp, int $flags): void
{
error_clear_last();
$safeResult = \rnp_key_remove($ffi, $key_fp, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param \RnpFFI $ffi
* @param string $key_fp
* @param int $flags
* @param array $options
* @throws RnpException
*
*/
function rnp_key_revoke(\RnpFFI $ffi, string $key_fp, int $flags, ?array $options = null): void
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_key_revoke($ffi, $key_fp, $flags, $options);
} else {
$safeResult = \rnp_key_revoke($ffi, $key_fp, $flags);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param \RnpFFI $ffi
* @param string $identifier_type
* @return array
* @throws RnpException
*
*/
function rnp_list_keys(\RnpFFI $ffi, string $identifier_type): array
{
error_clear_last();
$safeResult = \rnp_list_keys($ffi, $identifier_type);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $format
* @param string $input_path
* @param int $flags
* @throws RnpException
*
*/
function rnp_load_keys_from_path(\RnpFFI $ffi, string $format, string $input_path, int $flags): void
{
error_clear_last();
$safeResult = \rnp_load_keys_from_path($ffi, $format, $input_path, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param \RnpFFI $ffi
* @param string $format
* @param string $input
* @param int $flags
* @throws RnpException
*
*/
function rnp_load_keys(\RnpFFI $ffi, string $format, string $input, int $flags): void
{
error_clear_last();
$safeResult = \rnp_load_keys($ffi, $format, $input, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param \RnpFFI $ffi
* @param string $identifier_type
* @param string $identifier
* @return string
* @throws RnpException
*
*/
function rnp_locate_key(\RnpFFI $ffi, string $identifier_type, string $identifier): string
{
error_clear_last();
$safeResult = \rnp_locate_key($ffi, $identifier_type, $identifier);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $message
* @param array $recipient_keys_fp
* @param array $options
* @return string
* @throws RnpException
*
*/
function rnp_op_encrypt(\RnpFFI $ffi, string $message, array $recipient_keys_fp, ?array $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_op_encrypt($ffi, $message, $recipient_keys_fp, $options);
} else {
$safeResult = \rnp_op_encrypt($ffi, $message, $recipient_keys_fp);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $userid
* @param string $key_alg
* @param string $sub_alg
* @param array $options
* @return string
* @throws RnpException
*
*/
function rnp_op_generate_key(\RnpFFI $ffi, string $userid, string $key_alg, ?string $sub_alg = null, ?array $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_op_generate_key($ffi, $userid, $key_alg, $sub_alg, $options);
} elseif ($sub_alg !== null) {
$safeResult = \rnp_op_generate_key($ffi, $userid, $key_alg, $sub_alg);
} else {
$safeResult = \rnp_op_generate_key($ffi, $userid, $key_alg);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $data
* @param array $keys_fp
* @param array $options
* @return string
* @throws RnpException
*
*/
function rnp_op_sign_cleartext(\RnpFFI $ffi, string $data, array $keys_fp, ?array $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_op_sign_cleartext($ffi, $data, $keys_fp, $options);
} else {
$safeResult = \rnp_op_sign_cleartext($ffi, $data, $keys_fp);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $data
* @param array $keys_fp
* @param array $options
* @return string
* @throws RnpException
*
*/
function rnp_op_sign_detached(\RnpFFI $ffi, string $data, array $keys_fp, ?array $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_op_sign_detached($ffi, $data, $keys_fp, $options);
} else {
$safeResult = \rnp_op_sign_detached($ffi, $data, $keys_fp);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $data
* @param array $keys_fp
* @param array $options
* @return string
* @throws RnpException
*
*/
function rnp_op_sign(\RnpFFI $ffi, string $data, array $keys_fp, ?array $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \rnp_op_sign($ffi, $data, $keys_fp, $options);
} else {
$safeResult = \rnp_op_sign($ffi, $data, $keys_fp);
}
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $data
* @param string $signature
* @return array
* @throws RnpException
*
*/
function rnp_op_verify_detached(\RnpFFI $ffi, string $data, string $signature): array
{
error_clear_last();
$safeResult = \rnp_op_verify_detached($ffi, $data, $signature);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $data
* @return array
* @throws RnpException
*
*/
function rnp_op_verify(\RnpFFI $ffi, string $data): array
{
error_clear_last();
$safeResult = \rnp_op_verify($ffi, $data);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}
/**
* @param \RnpFFI $ffi
* @param string $format
* @param string $output_path
* @param int $flags
* @throws RnpException
*
*/
function rnp_save_keys_to_path(\RnpFFI $ffi, string $format, string $output_path, int $flags): void
{
error_clear_last();
$safeResult = \rnp_save_keys_to_path($ffi, $format, $output_path, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param \RnpFFI $ffi
* @param string $format
* @param string $output
* @param int $flags
* @throws RnpException
*
*/
function rnp_save_keys(\RnpFFI $ffi, string $format, string &$output, int $flags): void
{
error_clear_last();
$safeResult = \rnp_save_keys($ffi, $format, $output, $flags);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
}
/**
* @param string $type
* @return string
* @throws RnpException
*
*/
function rnp_supported_features(string $type): string
{
error_clear_last();
$safeResult = \rnp_supported_features($type);
if ($safeResult === false) {
throw RnpException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,288 @@
<?php
namespace Safe;
use Safe\Exceptions\SodiumException;
/**
* @param string $ciphertext
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_aes256gcm_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $ciphertext
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_chacha20poly1305_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_chacha20poly1305_decrypt($ciphertext, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $message
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_chacha20poly1305_encrypt(string $message, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_chacha20poly1305_encrypt($message, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $ciphertext
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_chacha20poly1305_ietf_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_chacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $message
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_chacha20poly1305_ietf_encrypt(string $message, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $ciphertext
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $message
* @param string $additional_data
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(string $message, string $additional_data, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $mac
* @param string $message
* @param string $key
* @throws SodiumException
*
*/
function sodium_crypto_auth_verify(string $mac, string $message, string $key): void
{
error_clear_last();
$safeResult = \sodium_crypto_auth_verify($mac, $message, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
}
/**
* @param string $ciphertext
* @param string $nonce
* @param string $key_pair
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_box_open(string $ciphertext, string $nonce, string $key_pair): string
{
error_clear_last();
$safeResult = \sodium_crypto_box_open($ciphertext, $nonce, $key_pair);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $ciphertext
* @param string $key_pair
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_box_seal_open(string $ciphertext, string $key_pair): string
{
error_clear_last();
$safeResult = \sodium_crypto_box_seal_open($ciphertext, $key_pair);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param non-empty-string $state
* @param string $message
* @throws SodiumException
*
*/
function sodium_crypto_generichash_update(string &$state, string $message): void
{
error_clear_last();
$safeResult = \sodium_crypto_generichash_update($state, $message);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
}
/**
* @param string $ciphertext
* @param string $nonce
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_secretbox_open(string $ciphertext, string $nonce, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $signed_message
* @param non-empty-string $public_key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_sign_open(string $signed_message, string $public_key): string
{
error_clear_last();
$safeResult = \sodium_crypto_sign_open($signed_message, $public_key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}
/**
* @param non-empty-string $signature
* @param string $message
* @param non-empty-string $public_key
* @throws SodiumException
*
*/
function sodium_crypto_sign_verify_detached(string $signature, string $message, string $public_key): void
{
error_clear_last();
$safeResult = \sodium_crypto_sign_verify_detached($signature, $message, $public_key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
}
/**
* @param string $message
* @param string $nonce
* @param int $counter
* @param string $key
* @return string
* @throws SodiumException
*
*/
function sodium_crypto_stream_xchacha20_xor_ic(string $message, string $nonce, int $counter, string $key): string
{
error_clear_last();
$safeResult = \sodium_crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key);
if ($safeResult === false) {
throw SodiumException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,463 @@
<?php
namespace Safe;
use Safe\Exceptions\Ssh2Exception;
/**
* @param resource $session
* @param string $username
* @throws Ssh2Exception
*
*/
function ssh2_auth_agent($session, string $username): void
{
error_clear_last();
$safeResult = \ssh2_auth_agent($session, $username);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @param string $username
* @param string $hostname
* @param string $pubkeyfile
* @param string $privkeyfile
* @param string $passphrase
* @param string $local_username
* @throws Ssh2Exception
*
*/
function ssh2_auth_hostbased_file($session, string $username, string $hostname, string $pubkeyfile, string $privkeyfile, ?string $passphrase = null, ?string $local_username = null): void
{
error_clear_last();
if ($local_username !== null) {
$safeResult = \ssh2_auth_hostbased_file($session, $username, $hostname, $pubkeyfile, $privkeyfile, $passphrase, $local_username);
} elseif ($passphrase !== null) {
$safeResult = \ssh2_auth_hostbased_file($session, $username, $hostname, $pubkeyfile, $privkeyfile, $passphrase);
} else {
$safeResult = \ssh2_auth_hostbased_file($session, $username, $hostname, $pubkeyfile, $privkeyfile);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @param string $username
* @param string $password
* @throws Ssh2Exception
*
*/
function ssh2_auth_password($session, string $username, string $password): void
{
error_clear_last();
$safeResult = \ssh2_auth_password($session, $username, $password);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @param string $username
* @param string $pubkeyfile
* @param string $privkeyfile
* @param string $passphrase
* @throws Ssh2Exception
*
*/
function ssh2_auth_pubkey_file($session, string $username, string $pubkeyfile, string $privkeyfile, ?string $passphrase = null): void
{
error_clear_last();
if ($passphrase !== null) {
$safeResult = \ssh2_auth_pubkey_file($session, $username, $pubkeyfile, $privkeyfile, $passphrase);
} else {
$safeResult = \ssh2_auth_pubkey_file($session, $username, $pubkeyfile, $privkeyfile);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param string $host
* @param int $port
* @param array $methods
* @param array $callbacks
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_connect(string $host, int $port = 22, ?array $methods = null, ?array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$safeResult = \ssh2_connect($host, $port, $methods, $callbacks);
} elseif ($methods !== null) {
$safeResult = \ssh2_connect($host, $port, $methods);
} else {
$safeResult = \ssh2_connect($host, $port);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $session
* @throws Ssh2Exception
*
*/
function ssh2_disconnect($session): void
{
error_clear_last();
$safeResult = \ssh2_disconnect($session);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @param string $command
* @param string $pty
* @param array $env
* @param int $width
* @param int $height
* @param int $width_height_type
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_exec($session, string $command, ?string $pty = null, ?array $env = null, int $width = 80, int $height = 25, int $width_height_type = SSH2_TERM_UNIT_CHARS)
{
error_clear_last();
if ($width_height_type !== SSH2_TERM_UNIT_CHARS) {
$safeResult = \ssh2_exec($session, $command, $pty, $env, $width, $height, $width_height_type);
} elseif ($height !== 25) {
$safeResult = \ssh2_exec($session, $command, $pty, $env, $width, $height);
} elseif ($width !== 80) {
$safeResult = \ssh2_exec($session, $command, $pty, $env, $width);
} elseif ($env !== null) {
$safeResult = \ssh2_exec($session, $command, $pty, $env);
} elseif ($pty !== null) {
$safeResult = \ssh2_exec($session, $command, $pty);
} else {
$safeResult = \ssh2_exec($session, $command);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $listener
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_forward_accept($listener)
{
error_clear_last();
$safeResult = \ssh2_forward_accept($listener);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $session
* @param int $port
* @param string $host
* @param int $max_connections
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_forward_listen($session, int $port, ?string $host = null, int $max_connections = 16)
{
error_clear_last();
if ($max_connections !== 16) {
$safeResult = \ssh2_forward_listen($session, $port, $host, $max_connections);
} elseif ($host !== null) {
$safeResult = \ssh2_forward_listen($session, $port, $host);
} else {
$safeResult = \ssh2_forward_listen($session, $port);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $pkey
* @param string $algoname
* @param string $blob
* @param bool $overwrite
* @param array $attributes
* @throws Ssh2Exception
*
*/
function ssh2_publickey_add($pkey, string $algoname, string $blob, bool $overwrite = false, ?array $attributes = null): void
{
error_clear_last();
if ($attributes !== null) {
$safeResult = \ssh2_publickey_add($pkey, $algoname, $blob, $overwrite, $attributes);
} else {
$safeResult = \ssh2_publickey_add($pkey, $algoname, $blob, $overwrite);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_publickey_init($session)
{
error_clear_last();
$safeResult = \ssh2_publickey_init($session);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $pkey
* @param string $algoname
* @param string $blob
* @throws Ssh2Exception
*
*/
function ssh2_publickey_remove($pkey, string $algoname, string $blob): void
{
error_clear_last();
$safeResult = \ssh2_publickey_remove($pkey, $algoname, $blob);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @param string $remote_file
* @param string $local_file
* @throws Ssh2Exception
*
*/
function ssh2_scp_recv($session, string $remote_file, string $local_file): void
{
error_clear_last();
$safeResult = \ssh2_scp_recv($session, $remote_file, $local_file);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @param string $local_file
* @param string $remote_file
* @param int $create_mode
* @throws Ssh2Exception
*
*/
function ssh2_scp_send($session, string $local_file, string $remote_file, int $create_mode = 0644): void
{
error_clear_last();
$safeResult = \ssh2_scp_send($session, $local_file, $remote_file, $create_mode);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $channel
* @throws Ssh2Exception
*
*/
function ssh2_send_eof($channel): void
{
error_clear_last();
$safeResult = \ssh2_send_eof($channel);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $sftp
* @param string $filename
* @param int $mode
* @throws Ssh2Exception
*
*/
function ssh2_sftp_chmod($sftp, string $filename, int $mode): void
{
error_clear_last();
$safeResult = \ssh2_sftp_chmod($sftp, $filename, $mode);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $sftp
* @param string $dirname
* @param int $mode
* @param bool $recursive
* @throws Ssh2Exception
*
*/
function ssh2_sftp_mkdir($sftp, string $dirname, int $mode = 0777, bool $recursive = false): void
{
error_clear_last();
$safeResult = \ssh2_sftp_mkdir($sftp, $dirname, $mode, $recursive);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $sftp
* @param string $from
* @param string $to
* @throws Ssh2Exception
*
*/
function ssh2_sftp_rename($sftp, string $from, string $to): void
{
error_clear_last();
$safeResult = \ssh2_sftp_rename($sftp, $from, $to);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $sftp
* @param string $dirname
* @throws Ssh2Exception
*
*/
function ssh2_sftp_rmdir($sftp, string $dirname): void
{
error_clear_last();
$safeResult = \ssh2_sftp_rmdir($sftp, $dirname);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $sftp
* @param string $target
* @param string $link
* @throws Ssh2Exception
*
*/
function ssh2_sftp_symlink($sftp, string $target, string $link): void
{
error_clear_last();
$safeResult = \ssh2_sftp_symlink($sftp, $target, $link);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $sftp
* @param string $filename
* @throws Ssh2Exception
*
*/
function ssh2_sftp_unlink($sftp, string $filename): void
{
error_clear_last();
$safeResult = \ssh2_sftp_unlink($sftp, $filename);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* @param resource $session
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_sftp($session)
{
error_clear_last();
$safeResult = \ssh2_sftp($session);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $session
* @param string $termtype
* @param array|null $env
* @param int $width
* @param int $height
* @param int $width_height_type
* @return resource
* @throws Ssh2Exception
*
*/
function ssh2_shell($session, string $termtype = "vanilla", ?array $env = null, int $width = 80, int $height = 25, int $width_height_type = SSH2_TERM_UNIT_CHARS)
{
error_clear_last();
if ($width_height_type !== SSH2_TERM_UNIT_CHARS) {
$safeResult = \ssh2_shell($session, $termtype, $env, $width, $height, $width_height_type);
} elseif ($height !== 25) {
$safeResult = \ssh2_shell($session, $termtype, $env, $width, $height);
} elseif ($width !== 80) {
$safeResult = \ssh2_shell($session, $termtype, $env, $width);
} elseif ($env !== null) {
$safeResult = \ssh2_shell($session, $termtype, $env);
} else {
$safeResult = \ssh2_shell($session, $termtype);
}
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,473 @@
<?php
namespace Safe;
use Safe\Exceptions\StreamException;
/**
* @param resource $context
* @param array $params
* @throws StreamException
*
*/
function stream_context_set_params($context, array $params): void
{
error_clear_last();
$safeResult = \stream_context_set_params($context, $params);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param resource $from
* @param resource $to
* @param int|null $length
* @param int $offset
* @return int
* @throws StreamException
*
*/
function stream_copy_to_stream($from, $to, ?int $length = null, int $offset = 0): int
{
error_clear_last();
if ($offset !== 0) {
$safeResult = \stream_copy_to_stream($from, $to, $length, $offset);
} elseif ($length !== null) {
$safeResult = \stream_copy_to_stream($from, $to, $length);
} else {
$safeResult = \stream_copy_to_stream($from, $to);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param string $filtername
* @param int $read_write
* @param mixed $params
* @return resource
* @throws StreamException
*
*/
function stream_filter_append($stream, string $filtername, ?int $read_write = null, $params = null)
{
error_clear_last();
if ($params !== null) {
$safeResult = \stream_filter_append($stream, $filtername, $read_write, $params);
} elseif ($read_write !== null) {
$safeResult = \stream_filter_append($stream, $filtername, $read_write);
} else {
$safeResult = \stream_filter_append($stream, $filtername);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param string $filtername
* @param int $read_write
* @param mixed $params
* @return resource
* @throws StreamException
*
*/
function stream_filter_prepend($stream, string $filtername, ?int $read_write = null, $params = null)
{
error_clear_last();
if ($params !== null) {
$safeResult = \stream_filter_prepend($stream, $filtername, $read_write, $params);
} elseif ($read_write !== null) {
$safeResult = \stream_filter_prepend($stream, $filtername, $read_write);
} else {
$safeResult = \stream_filter_prepend($stream, $filtername);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $filter_name
* @param string $class
* @throws StreamException
*
*/
function stream_filter_register(string $filter_name, string $class): void
{
error_clear_last();
$safeResult = \stream_filter_register($filter_name, $class);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param resource $stream_filter
* @throws StreamException
*
*/
function stream_filter_remove($stream_filter): void
{
error_clear_last();
$safeResult = \stream_filter_remove($stream_filter);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param resource $stream
* @param int|null $length
* @param int $offset
* @return string
* @throws StreamException
*
*/
function stream_get_contents($stream, ?int $length = null, int $offset = -1): string
{
error_clear_last();
if ($offset !== -1) {
$safeResult = \stream_get_contents($stream, $length, $offset);
} elseif ($length !== null) {
$safeResult = \stream_get_contents($stream, $length);
} else {
$safeResult = \stream_get_contents($stream);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param int $length
* @param string $ending
* @return string
* @throws StreamException
*
*/
function stream_get_line($stream, int $length, string $ending = ""): string
{
error_clear_last();
$safeResult = \stream_get_line($stream, $length, $ending);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @throws StreamException
*
*/
function stream_isatty($stream): void
{
error_clear_last();
$safeResult = \stream_isatty($stream);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param string $filename
* @return string
* @throws StreamException
*
*/
function stream_resolve_include_path(string $filename): string
{
error_clear_last();
$safeResult = \stream_resolve_include_path($filename);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param bool $enable
* @throws StreamException
*
*/
function stream_set_blocking($stream, bool $enable): void
{
error_clear_last();
$safeResult = \stream_set_blocking($stream, $enable);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param resource $stream
* @param int $seconds
* @param int $microseconds
* @throws StreamException
*
*/
function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void
{
error_clear_last();
$safeResult = \stream_set_timeout($stream, $seconds, $microseconds);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param resource $socket
* @param float|null $timeout
* @param null|string $peer_name
* @return resource
* @throws StreamException
*
*/
function stream_socket_accept($socket, ?float $timeout = null, ?string &$peer_name = null)
{
error_clear_last();
if ($peer_name !== null) {
$safeResult = \stream_socket_accept($socket, $timeout, $peer_name);
} elseif ($timeout !== null) {
$safeResult = \stream_socket_accept($socket, $timeout);
} else {
$safeResult = \stream_socket_accept($socket);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $address
* @param int|null $error_code
* @param null|string $error_message
* @param float|null $timeout
* @param int-mask $flags
* @param null|resource $context
* @return resource
* @throws StreamException
*
*/
function stream_socket_client(string $address, ?int &$error_code = null, ?string &$error_message = null, ?float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null)
{
error_clear_last();
if ($context !== null) {
$safeResult = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags, $context);
} elseif ($flags !== STREAM_CLIENT_CONNECT) {
$safeResult = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags);
} elseif ($timeout !== null) {
$safeResult = \stream_socket_client($address, $error_code, $error_message, $timeout);
} else {
$safeResult = \stream_socket_client($address, $error_code, $error_message);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $socket
* @param bool $remote
* @return string
* @throws StreamException
*
*/
function stream_socket_get_name($socket, bool $remote): string
{
error_clear_last();
$safeResult = \stream_socket_get_name($socket, $remote);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param int $domain
* @param int $type
* @param int $protocol
* @return resource[]
* @throws StreamException
*
*/
function stream_socket_pair(int $domain, int $type, int $protocol): array
{
error_clear_last();
$safeResult = \stream_socket_pair($domain, $type, $protocol);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $socket
* @param int $length
* @param int $flags
* @param null|string $address
* @return string
* @throws StreamException
*
*/
function stream_socket_recvfrom($socket, int $length, int $flags = 0, ?string &$address = null): string
{
error_clear_last();
$safeResult = \stream_socket_recvfrom($socket, $length, $flags, $address);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $socket
* @param string $data
* @param int $flags
* @param string $address
* @return int
* @throws StreamException
*
*/
function stream_socket_sendto($socket, string $data, int $flags = 0, string $address = ""): int
{
error_clear_last();
$safeResult = \stream_socket_sendto($socket, $data, $flags, $address);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param string $address
* @param int|null $error_code
* @param null|string $error_message
* @param int $flags
* @param null|resource $context
* @return resource
* @throws StreamException
*
*/
function stream_socket_server(string $address, ?int &$error_code = null, ?string &$error_message = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context = null)
{
error_clear_last();
if ($context !== null) {
$safeResult = \stream_socket_server($address, $error_code, $error_message, $flags, $context);
} else {
$safeResult = \stream_socket_server($address, $error_code, $error_message, $flags);
}
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
return $safeResult;
}
/**
* @param resource $stream
* @param int $mode
* @throws StreamException
*
*/
function stream_socket_shutdown($stream, int $mode): void
{
error_clear_last();
$safeResult = \stream_socket_shutdown($stream, $mode);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param resource $stream
* @throws StreamException
*
*/
function stream_supports_lock($stream): void
{
error_clear_last();
$safeResult = \stream_supports_lock($stream);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param string $protocol
* @param string $class
* @param int $flags
* @throws StreamException
*
*/
function stream_wrapper_register(string $protocol, string $class, int $flags = 0): void
{
error_clear_last();
$safeResult = \stream_wrapper_register($protocol, $class, $flags);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param string $protocol
* @throws StreamException
*
*/
function stream_wrapper_restore(string $protocol): void
{
error_clear_last();
$safeResult = \stream_wrapper_restore($protocol);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}
/**
* @param string $protocol
* @throws StreamException
*
*/
function stream_wrapper_unregister(string $protocol): void
{
error_clear_last();
$safeResult = \stream_wrapper_unregister($protocol);
if ($safeResult === false) {
throw StreamException::createFromPhpError();
}
}