harga pada beranda terhubung ke manage plans di dashboard admin
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m27s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 31s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
triagungbiantoro
2026-04-25 21:57:25 +07:00
parent f25542ea0d
commit 417b7b7453
21707 changed files with 179493 additions and 328 deletions

0
vendor/thecodingmachine/safe/generated/8.4/apache.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,112 @@
<?php
namespace Safe;
use Safe\Exceptions\ApcuException;
/**
* Retrieves cached information and meta-data from APC's data store.
*
* @param bool $limited If limited is TRUE, the
* return value will exclude the individual list of cache entries. This
* is useful when trying to optimize calls for statistics gathering.
* @return array Array of cached data (and meta-data)
* @throws ApcuException
*
*/
function apcu_cache_info(bool $limited = false): array
{
error_clear_last();
$safeResult = \apcu_cache_info($limited);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}
/**
* apcu_cas updates an already existing integer value if the
* old parameter matches the currently stored value
* with the value of the new parameter.
*
* @param string $key The key of the value being updated.
* @param int $old The old value (the value currently stored).
* @param int $new The new value to update to.
* @throws ApcuException
*
*/
function apcu_cas(string $key, int $old, int $new): void
{
error_clear_last();
$safeResult = \apcu_cas($key, $old, $new);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
}
/**
* Decreases a stored integer value.
*
* @param string $key The key of the value being decreased.
* @param int $step The step, or value to decrease.
* @param bool|null $success Optionally pass the success or fail boolean value to
* this referenced variable.
* @param int $ttl TTL to use if the operation inserts a new value (rather than decrementing an existing one).
* @return int Returns the current value of key's value on success
* @throws ApcuException
*
*/
function apcu_dec(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int
{
error_clear_last();
$safeResult = \apcu_dec($key, $step, $success, $ttl);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}
/**
* Increases a stored number.
*
* @param string $key The key of the value being increased.
* @param int $step The step, or value to increase.
* @param bool|null $success Optionally pass the success or fail boolean value to
* this referenced variable.
* @param int $ttl TTL to use if the operation inserts a new value (rather than incrementing an existing one).
* @return int Returns the current value of key's value on success
* @throws ApcuException
*
*/
function apcu_inc(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int
{
error_clear_last();
$safeResult = \apcu_inc($key, $step, $success, $ttl);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves APCu Shared Memory Allocation information.
*
* @param bool $limited When set to FALSE (default) apcu_sma_info will
* return a detailed information about each segment.
* @return array Array of Shared Memory Allocation data; FALSE on failure.
* @throws ApcuException
*
*/
function apcu_sma_info(bool $limited = false): array
{
error_clear_last();
$safeResult = \apcu_sma_info($limited);
if ($safeResult === false) {
throw ApcuException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/array.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,120 @@
<?php
namespace Safe;
use Safe\Exceptions\Bzip2Exception;
/**
* Closes the given bzip2 file pointer.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @throws Bzip2Exception
*
*/
function bzclose($bz): void
{
error_clear_last();
$safeResult = \bzclose($bz);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
}
/**
* This function is supposed to force a write of all buffered bzip2 data for the file pointer
* bz,
* but is implemented as null function in libbz2, and as such does nothing.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @throws Bzip2Exception
*
*/
function bzflush($bz): void
{
error_clear_last();
$safeResult = \bzflush($bz);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
}
/**
* bzopen opens a bzip2 (.bz2) file for reading or
* writing.
*
* @param resource|string $file The name of the file to open, or an existing stream resource.
* @param string $mode The modes 'r' (read), and 'w' (write) are supported.
* Everything else will cause bzopen to return FALSE.
* @return resource If the open fails, bzopen returns FALSE, otherwise
* it returns a pointer to the newly opened file.
* @throws Bzip2Exception
*
*/
function bzopen($file, string $mode)
{
error_clear_last();
$safeResult = \bzopen($file, $mode);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* bzread reads from the given bzip2 file pointer.
*
* Reading stops when length (uncompressed) bytes have
* been read or EOF is reached, whichever comes first.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @param int $length If not specified, bzread will read 1024
* (uncompressed) bytes at a time. A maximum of 8192
* uncompressed bytes will be read at a time.
* @return string Returns the uncompressed data.
* @throws Bzip2Exception
*
*/
function bzread($bz, int $length = 1024): string
{
error_clear_last();
$safeResult = \bzread($bz, $length);
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* bzwrite writes a string into the given bzip2 file
* stream.
*
* @param resource $bz The file pointer. It must be valid and must point to a file
* successfully opened by bzopen.
* @param string $data The written data.
* @param int|null $length If supplied, writing will stop after length
* (uncompressed) bytes have been written or the end of
* data is reached, whichever comes first.
* @return int Returns the number of bytes written.
* @throws Bzip2Exception
*
*/
function bzwrite($bz, string $data, ?int $length = null): int
{
error_clear_last();
if ($length !== null) {
$safeResult = \bzwrite($bz, $data, $length);
} else {
$safeResult = \bzwrite($bz, $data);
}
if ($safeResult === false) {
throw Bzip2Exception::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Safe;
use Safe\Exceptions\CalendarException;
/**
* Return the Julian Day for a Unix timestamp
* (seconds since 1.1.1970), or for the current day if no
* timestamp is given. Either way, the time is regarded
* as local time (not UTC).
*
* @param int|null $timestamp A unix timestamp to convert.
* @return int A julian day number as integer.
* @throws CalendarException
*
*/
function unixtojd(?int $timestamp = null): int
{
error_clear_last();
if ($timestamp !== null) {
$safeResult = \unixtojd($timestamp);
} else {
$safeResult = \unixtojd();
}
if ($safeResult === false) {
throw CalendarException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Safe;
use Safe\Exceptions\ClassobjException;
/**
* Creates an alias named alias
* based on the user defined class class.
* The aliased class is exactly the same as the original class.
*
* @param string $class The original class.
* @param string $alias The alias name for the class.
* @param bool $autoload Whether to autoload
* if the original class is not found.
* @throws ClassobjException
*
*/
function class_alias(string $class, string $alias, bool $autoload = true): void
{
error_clear_last();
$safeResult = \class_alias($class, $alias, $autoload);
if ($safeResult === false) {
throw ClassobjException::createFromPhpError();
}
}

View File

@@ -0,0 +1,196 @@
<?php
namespace Safe;
use Safe\Exceptions\ComException;
/**
* Generates a Globally Unique Identifier (GUID).
*
* A GUID is generated in the same way as DCE UUID's, except that the
* Microsoft convention is to enclose a GUID in curly braces.
*
* @return string Returns the GUID as a string.
* @throws ComException
*
*/
function com_create_guid(): string
{
error_clear_last();
$safeResult = \com_create_guid();
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
return $safeResult;
}
/**
* Instructs COM to sink events generated by
* variant into the PHP object
* sink_object.
*
* Be careful how you use this feature; if you are doing something similar
* to the example below, then it doesn't really make sense to run it in a
* web server context.
*
* @param object $variant
* @param object $sink_object sink_object should be an instance of a class with
* methods named after those of the desired dispinterface; you may use
* com_print_typeinfo to help generate a template class
* for this purpose.
* @param mixed $sink_interface PHP will attempt to use the default dispinterface type specified by
* the typelibrary associated with variant, but
* you may override this choice by setting
* sink_interface to the name of the dispinterface
* that you want to use.
* @throws ComException
*
*/
function com_event_sink(object $variant, object $sink_object, $sink_interface = null): void
{
error_clear_last();
if ($sink_interface !== null) {
$safeResult = \com_event_sink($variant, $sink_object, $sink_interface);
} else {
$safeResult = \com_event_sink($variant, $sink_object);
}
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
}
/**
* Loads a type-library and registers its constants in the engine, as though
* they were defined using define.
*
* Note that it is much more efficient to use the com.typelib-file php.ini setting to pre-load and
* register the constants, although not so flexible.
*
* If com.autoregister-typelib is turned on, then
* PHP will attempt to automatically register the constants associated with a
* COM object when you instantiate it. This depends on the interfaces
* provided by the COM object itself, and may not always be possible.
*
* @param string $typelib typelib can be one of the following:
*
*
*
* The filename of a .tlb file or the executable module
* that contains the type library.
*
*
*
*
* The type library GUID, followed by its version number, for example
* {00000200-0000-0010-8000-00AA006D2EA4},2,0.
*
*
*
*
* The type library name, e.g. Microsoft OLE DB ActiveX Data
* Objects 1.0 Library.
*
*
*
* PHP will attempt to resolve the type library in this order, as the
* process gets more and more expensive as you progress down the list;
* searching for the type library by name is handled by physically
* enumerating the registry until we find a match.
*
* The filename of a .tlb file or the executable module
* that contains the type library.
*
* The type library GUID, followed by its version number, for example
* {00000200-0000-0010-8000-00AA006D2EA4},2,0.
*
* The type library name, e.g. Microsoft OLE DB ActiveX Data
* Objects 1.0 Library.
* @param bool $case_insensitive The case_insensitive behaves inversely to
* the parameter $case_insensitive in the define
* function.
* @throws ComException
*
*/
function com_load_typelib(string $typelib, bool $case_insensitive = true): void
{
error_clear_last();
$safeResult = \com_load_typelib($typelib, $case_insensitive);
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
}
/**
* The purpose of this function is to help generate a skeleton class for use
* as an event sink. You may also use it to generate a dump of any COM
* object, provided that it supports enough of the introspection interfaces,
* and that you know the name of the interface you want to display.
*
* @param object $variant variant should be either an instance of a COM
* object, or be the name of a typelibrary (which will be resolved according
* to the rules set out in com_load_typelib).
* @param null|string $dispatch_interface The name of an IDispatch descendant interface that you want to display.
* @param bool $display_sink If set to TRUE, the corresponding sink interface will be displayed
* instead.
* @throws ComException
*
*/
function com_print_typeinfo(object $variant, ?string $dispatch_interface = null, bool $display_sink = false): void
{
error_clear_last();
if ($display_sink !== false) {
$safeResult = \com_print_typeinfo($variant, $dispatch_interface, $display_sink);
} elseif ($dispatch_interface !== null) {
$safeResult = \com_print_typeinfo($variant, $dispatch_interface);
} else {
$safeResult = \com_print_typeinfo($variant);
}
if ($safeResult === false) {
throw ComException::createFromPhpError();
}
}
/**
* Converts variant from a VT_DATE
* (or similar) value into a Unix timestamp. This allows easier
* interopability between the Unix-ish parts of PHP and COM.
*
* @param object $variant The variant.
* @return int Returns a unix timestamp.
* @throws ComException
*
*/
function variant_date_to_timestamp(object $variant): int
{
error_clear_last();
$safeResult = \variant_date_to_timestamp($variant);
if ($safeResult === null) {
throw ComException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the value of value rounded to
* decimals decimal places.
*
* @param mixed $value The variant.
* @param int $decimals Number of decimal places.
* @return mixed Returns the rounded value.
* @throws ComException
*
*/
function variant_round($value, int $decimals)
{
error_clear_last();
$safeResult = \variant_round($value, $decimals);
if ($safeResult === null) {
throw ComException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load Diff

0
vendor/thecodingmachine/safe/generated/8.4/curl.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/datetime.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,160 @@
<?php
namespace Safe;
use Safe\Exceptions\DirException;
/**
* Changes PHP's current directory to
* directory.
*
* @param string $directory The new current directory
* @throws DirException
*
*/
function chdir(string $directory): void
{
error_clear_last();
$safeResult = \chdir($directory);
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
}
/**
* Changes the root directory of the current process to
* directory, and changes the current
* working directory to "/".
*
* This function is only available to GNU and BSD systems, and
* only when using the CLI, CGI or Embed SAPI. Also, this function
* requires root privileges.
*
* Calling this function does not change the values of the __DIR__
* and __FILE__ magic constants.
*
* @param string $directory The path to change the root directory to.
* @throws DirException
*
*/
function chroot(string $directory): void
{
error_clear_last();
$safeResult = \chroot($directory);
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
}
/**
* A pseudo-object-oriented mechanism for reading a directory. The
* given directory is opened.
*
* @param string $directory Directory to open
* @param null|resource $context A context stream
* resource.
* @return \Directory Returns an instance of Directory, or FALSE in case of error.
* @throws DirException
*
*/
function dir(string $directory, $context = null): \Directory
{
error_clear_last();
if ($context !== null) {
$safeResult = \dir($directory, $context);
} else {
$safeResult = \dir($directory);
}
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets the current working directory.
*
* @return non-empty-string Returns the current working directory on success.
*
* On some Unix variants, getcwd will return
* FALSE if any one of the parent directories does not have the
* readable or search mode set, even if the current directory
* does. See chmod for more information on
* modes and permissions.
* @throws DirException
*
*/
function getcwd(): string
{
error_clear_last();
$safeResult = \getcwd();
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}
/**
* Opens up a directory handle to be used in subsequent
* closedir, readdir, and
* rewinddir calls.
*
* @param string $directory The directory path that is to be opened
* @param null|resource $context For a description of the context parameter,
* refer to the streams section of
* the manual.
* @return resource Returns a directory handle resource on success
* @throws DirException
*
*/
function opendir(string $directory, $context = null)
{
error_clear_last();
if ($context !== null) {
$safeResult = \opendir($directory, $context);
} else {
$safeResult = \opendir($directory);
}
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns an array of files and directories from the
* directory.
*
* @param string $directory The directory that will be scanned.
* @param SCANDIR_SORT_ASCENDING|SCANDIR_SORT_DESCENDING|SCANDIR_SORT_NONE $sorting_order By default, the sorted order is alphabetical in ascending order. If
* the optional sorting_order is set to
* SCANDIR_SORT_DESCENDING, then the sort order is
* alphabetical in descending order. If it is set to
* SCANDIR_SORT_NONE then the result is unsorted.
* @param null|resource $context For a description of the context parameter,
* refer to the streams section of
* the manual.
* @return list Returns an array of filenames on success. If directory is not a directory, then
* boolean FALSE is returned, and an error of level
* E_WARNING is generated.
* @throws DirException
*
*/
function scandir(string $directory, int $sorting_order = SCANDIR_SORT_ASCENDING, $context = null): array
{
error_clear_last();
if ($context !== null) {
$safeResult = \scandir($directory, $sorting_order, $context);
} else {
$safeResult = \scandir($directory, $sorting_order);
}
if ($safeResult === false) {
throw DirException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,82 @@
<?php
namespace Safe;
use Safe\Exceptions\ErrorfuncException;
/**
* Sends an error message to the web server's error log or to a file.
*
* @param string $message The error message that should be logged.
* @param 0|1|2|3|4 $message_type Says where the error should go. The possible message types are as
* follows:
*
*
* error_log log types
*
*
*
* 0
*
* message is sent to PHP's system logger, using
* the Operating System's system logging mechanism or a file, depending
* on what the error_log
* configuration directive is set to. This is the default option.
*
*
*
* 1
*
* message is sent by email to the address in
* the destination parameter. This is the only
* message type where the fourth parameter,
* additional_headers is used.
*
*
*
* 2
*
* No longer an option.
*
*
*
* 3
*
* message is appended to the file
* destination. A newline is not automatically
* added to the end of the message string.
*
*
*
* 4
*
* message is sent directly to the SAPI logging
* handler.
*
*
*
*
*
* @param null|string $destination The destination. Its meaning depends on the
* message_type parameter as described above.
* @param null|string $additional_headers The extra headers. It's used when the message_type
* parameter is set to 1.
* This message type uses the same internal function as
* mail does.
* @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,278 @@
<?php
namespace Safe;
use Safe\Exceptions\ExecException;
/**
* exec executes the given
* command.
*
* @param string $command The command that will be executed.
* @param array|null $output If the output argument is present, then the
* specified array will be filled with every line of output from the
* command. Trailing whitespace, such as \n, is not
* included in this array. Note that if the array already contains some
* elements, exec will append to the end of the array.
* If you do not want the function to append elements, call
* unset on the array before passing it to
* exec.
* @param int|null $result_code If the result_code argument is present
* along with the output argument, then the
* return status of the executed command will be written to this
* variable.
* @return string The last line from the result of the command. If you need to execute a
* command and have all the data from the command passed directly back without
* any interference, use the passthru function.
*
* Returns FALSE on failure.
*
* To get the output of the executed command, be sure to set and use the
* output parameter.
* @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;
}
/**
* The passthru function is similar to the
* exec function in that it executes a
* command. This function
* should be used in place of exec or
* system when the output from the Unix command
* is binary data which needs to be passed directly back to the
* browser. A common use for this is to execute something like the
* pbmplus utilities that can output an image stream directly. By
* setting the Content-type to image/gif and
* then calling a pbmplus program to output a gif, you can create
* PHP scripts that output images directly.
*
* @param string $command The command that will be executed.
* @param int|null $result_code If the result_code argument is present, the
* return status of the Unix command will be placed here.
* @throws ExecException
*
*/
function passthru(string $command, ?int &$result_code = null): void
{
error_clear_last();
$safeResult = \passthru($command, $result_code);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
}
/**
* proc_close is similar to pclose
* except that it only works on processes opened by
* proc_open.
* proc_close waits for the process to terminate, and
* returns its exit code. Open pipes to that process are closed
* when this function is called, in
* order to avoid a deadlock - the child process may not be able to exit
* while the pipes are open.
*
* @param resource $process The proc_open resource that will
* be closed.
* @return int Returns the termination status of the process that was run.
* @throws ExecException
*
*/
function proc_close($process): int
{
error_clear_last();
$safeResult = \proc_close($process);
if ($safeResult === -1) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
* proc_nice changes the priority of the current
* process by the amount specified in priority. A
* positive priority will lower the priority of the
* current process, whereas a negative priority
* will raise the priority.
*
* proc_nice is not related to
* proc_open and its associated functions in any way.
*
* @param int $priority The new priority value, the value of this may differ on platforms.
*
* On Unix, a low value, such as -20 means high priority
* whereas positive values have a lower priority.
*
* For Windows the priority parameter has the
* following meaning:
* @throws ExecException
*
*/
function proc_nice(int $priority): void
{
error_clear_last();
$safeResult = \proc_nice($priority);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
}
/**
* proc_open is similar to popen
* but provides a much greater degree of control over the program execution.
*
* @param string $command The commandline to execute as string. Special characters have to be properly escaped,
* and proper quoting has to be applied.
*
* As of PHP 7.4.0, command may be passed as array of command parameters.
* In this case the process will be opened directly (without going through a shell)
* and PHP will take care of any necessary argument escaping.
*
* On Windows, the argument escaping of the array elements assumes that the
* command line parsing of the executed command is compatible with the parsing
* of command line arguments done by the VC runtime.
* @param array $descriptor_spec An indexed array where the key represents the descriptor number and the
* value represents how PHP will pass that descriptor to the child
* process. 0 is stdin, 1 is stdout, while 2 is stderr.
*
* Each element can be:
*
* An array describing the pipe to pass to the process. The first
* element is the descriptor type and the second element is an option for
* the given type. Valid types are pipe (the second
* element is either r to pass the read end of the pipe
* to the process, or w to pass the write end) and
* file (the second element is a filename).
* Note that anything else than w is treated like r.
*
*
* A stream resource representing a real file descriptor (e.g. opened file,
* a socket, STDIN).
*
*
*
* The file descriptor numbers are not limited to 0, 1 and 2 - you may
* specify any valid file descriptor number and it will be passed to the
* child process. This allows your script to interoperate with other
* scripts that run as "co-processes". In particular, this is useful for
* passing passphrases to programs like PGP, GPG and openssl in a more
* secure manner. It is also useful for reading status information
* provided by those programs on auxiliary file descriptors.
* @param null|resource[] $pipes Will be set to an indexed array of file pointers that correspond to
* PHP's end of any pipes that are created.
* @param null|string $cwd The initial working dir for the command. This must be an
* absolute directory path, or NULL
* if you want to use the default value (the working dir of the current
* PHP process)
* @param array|null $env_vars An array with the environment variables for the command that will be
* run, or NULL to use the same environment as the current PHP process
* @param array|null $options Allows you to specify additional options. Currently supported options
* include:
*
*
* suppress_errors (windows only): suppresses errors
* generated by this function when it's set to TRUE
*
*
* bypass_shell (windows only): bypass
* cmd.exe shell when set to TRUE
*
*
* blocking_pipes (windows only): force
* blocking pipes when set to TRUE
*
*
* create_process_group (windows only): allow the
* child process to handle CTRL events when set to TRUE
*
*
* create_new_console (windows only): the new process
* has a new console, instead of inheriting its parent's console
*
*
* @return resource Returns a resource representing the process, which should be freed using
* proc_close when you are finished with it. On failure
* returns FALSE.
* @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;
}
/**
* This function is identical to the backtick operator.
*
* @param string $command The command that will be executed.
* @return null|string A string containing the output from the executed command or NULL if an error occurs or the command produces no output.
* @throws ExecException
*
*/
function shell_exec(string $command): ?string
{
error_clear_last();
$safeResult = \shell_exec($command);
if ($safeResult === false) {
throw ExecException::createFromPhpError();
}
return $safeResult;
}
/**
* system is just like the C version of the
* function in that it executes the given
* command and outputs the result.
*
* The system call also tries to automatically
* flush the web server's output buffer after each line of output if
* PHP is running as a server module.
*
* If you need to execute a command and have all the data from the
* command passed directly back without any interference, use the
* passthru function.
*
* @param string $command The command that will be executed.
* @param int|null $result_code If the result_code argument is present, then the
* return status of the executed command will be written to this
* variable.
* @return string Returns the last line of the command output on success.
* @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,79 @@
<?php
namespace Safe;
use Safe\Exceptions\FileinfoException;
/**
* This function closes the instance opened by finfo_open.
*
* @param \finfo $finfo An finfo instance, returned by finfo_open.
* @throws FileinfoException
*
*/
function finfo_close(\finfo $finfo): void
{
error_clear_last();
$safeResult = \finfo_close($finfo);
if ($safeResult === false) {
throw FileinfoException::createFromPhpError();
}
}
/**
* Procedural style
*
* Object-oriented style (constructor):
*
* This function opens a magic database and returns its instance.
*
* @param int $flags One or disjunction of more Fileinfo
* constants.
* @param null|string $magic_database Name of a magic database file, usually something like
* /path/to/magic.mime. If not specified, the
* MAGIC environment variable is used. If the
* environment variable isn't set, then PHP's bundled magic database will
* be used.
*
* Passing NULL or an empty string will be equivalent to the default
* value.
* @return \finfo (Procedural style only)
* Returns an finfo instance on success.
* @throws FileinfoException
*
*/
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null): \finfo
{
error_clear_last();
if ($magic_database !== null) {
$safeResult = \finfo_open($flags, $magic_database);
} else {
$safeResult = \finfo_open($flags);
}
if ($safeResult === false) {
throw FileinfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the MIME content type for a file as determined by using
* information from the magic.mime file.
*
* @param resource|string $filename Path to the tested file.
* @return string Returns the content type in MIME format, like
* text/plain or application/octet-stream.
* @throws FileinfoException
*
*/
function mime_content_type($filename): string
{
error_clear_last();
$safeResult = \mime_content_type($filename);
if ($safeResult === false) {
throw FileinfoException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
<?php
namespace Safe;
use Safe\Exceptions\FilterException;
/**
* This function is useful for retrieving many values without
* repetitively calling filter_input.
*
* @param int $type
* @param array|int $options
* @param bool $add_empty
* @return array|null
* @throws FilterException
*
*/
function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empty = true): ?array
{
error_clear_last();
$safeResult = \filter_input_array($type, $options, $add_empty);
if ($safeResult === false) {
throw FilterException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param array $array
* @param mixed $options
* @param bool $add_empty Add missing keys as NULL to the return value.
* @return array|null An array containing the values of the requested variables on success. An array value will be FALSE if the filter fails, or NULL if
* the variable is not set.
* @throws FilterException
*
*/
function filter_var_array(array $array, $options = FILTER_DEFAULT, bool $add_empty = true): ?array
{
error_clear_last();
$safeResult = \filter_var_array($array, $options, $add_empty);
if ($safeResult === false) {
throw FilterException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Safe;
use Safe\Exceptions\FpmException;
/**
* This function flushes all response data to the client and finishes the
* request. This allows for time consuming tasks to be performed without
* leaving the connection to the client open.
*
* @throws FpmException
*
*/
function fastcgi_finish_request(): void
{
error_clear_last();
$safeResult = \fastcgi_finish_request();
if ($safeResult === false) {
throw FpmException::createFromPhpError();
}
}
/**
* This function returns the full current FPM pool status as an associative array. It always
* returns the full status, including per-process status information. See the
* FPM status page guide for further
* details.
*
* Note that this function will only be defined if FPM is being used to serve the script.
*
* @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} Associative array containing the full FPM pool status.
* @throws FpmException
*
*/
function fpm_get_status(): array
{
error_clear_last();
$safeResult = \fpm_get_status();
if ($safeResult === false) {
throw FpmException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/ftp.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,26 @@
<?php
namespace Safe;
use Safe\Exceptions\FunchandException;
/**
*
*
* @param callable(): void $callback The function to register.
* @param mixed $args
* @throws FunchandException
*
*/
function register_tick_function(callable $callback, ...$args): void
{
error_clear_last();
if ($args !== []) {
$safeResult = \register_tick_function($callback, ...$args);
} else {
$safeResult = \register_tick_function($callback);
}
if ($safeResult === false) {
throw FunchandException::createFromPhpError();
}
}

0
vendor/thecodingmachine/safe/generated/8.4/functionsList.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/gettext.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,25 @@
<?php
namespace Safe;
use Safe\Exceptions\GmpException;
/**
*
*
* @param \GMP|int|string $seed The seed to be set for the gmp_random,
* gmp_random_bits, and
* gmp_random_range functions.
*
*
* A GMP object, an integer,
* or a string that can be interpreted as a number following the same logic
* as if the string was used in gmp_init with automatic
* base detection (i.e. when base is equal to 0).
*
*/
function gmp_random_seed($seed): void
{
error_clear_last();
$safeResult = \gmp_random_seed($seed);
}

View File

@@ -0,0 +1,188 @@
<?php
namespace Safe;
use Safe\Exceptions\GnupgException;
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $fingerprint The fingerprint key.
* @param string $passphrase The pass phrase.
* @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 The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $fingerprint The fingerprint key.
* @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 The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $fingerprint The fingerprint key.
* @param string $passphrase The pass phrase.
* @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 The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @throws GnupgException
*
*/
function gnupg_cleardecryptkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_cleardecryptkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @throws GnupgException
*
*/
function gnupg_clearencryptkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_clearencryptkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @throws GnupgException
*
*/
function gnupg_clearsignkeys($identifier): void
{
error_clear_last();
$safeResult = \gnupg_clearsignkeys($identifier);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
*
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param string $key The key to delete.
* @param bool $allow_secret It specifies whether to delete secret keys as well.
* @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();
}
}
/**
* Toggle the armored output.
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param int $armor Pass a non-zero integer-value to this function to enable armored-output
* (default).
* Pass 0 to disable armored output.
* @throws GnupgException
*
*/
function gnupg_setarmor($identifier, int $armor): void
{
error_clear_last();
$safeResult = \gnupg_setarmor($identifier, $armor);
if ($safeResult === false) {
throw GnupgException::createFromPhpError();
}
}
/**
* Sets the mode for signing.
*
* @param resource $identifier The gnupg identifier, from a call to
* gnupg_init or gnupg.
* @param int $signmode The mode for signing.
*
* signmode takes a constant indicating what type of
* signature should be produced. The possible values are
* GNUPG_SIG_MODE_NORMAL,
* GNUPG_SIG_MODE_DETACH and
* GNUPG_SIG_MODE_CLEAR.
* By default GNUPG_SIG_MODE_CLEAR is used.
* @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,61 @@
<?php
namespace Safe;
use Safe\Exceptions\HashException;
/**
*
*
* @param string $algo Name of selected hashing algorithm (e.g. "sha256").
* For a list of supported algorithms see hash_hmac_algos.
*
*
* Non-cryptographic hash functions are not allowed.
*
*
*
* Non-cryptographic hash functions are not allowed.
* @param string $key Input keying material (raw binary). Cannot be empty.
* @param int $length Desired output length in bytes.
* Cannot be greater than 255 times the chosen hash function size.
*
* If length is 0, the output length
* will default to the chosen hash function size.
* @param string $info Application/context-specific info string.
* @param string $salt Salt to use during derivation.
*
* While optional, adding random salt significantly improves the strength of HKDF.
* @return false|non-falsy-string Returns a string containing a raw binary representation of the derived key
* (also known as output keying material - OKM).
*
*/
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 Hashing context returned by hash_init.
* @param string $filename URL describing location of file to be hashed; Supports fopen wrappers.
* @param \HashContext|null $stream_context Stream context as returned by stream_context_create.
* @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();
}
}

View File

@@ -0,0 +1,661 @@
<?php
namespace Safe;
use Safe\Exceptions\IbaseException;
/**
* This function will discard a BLOB if it has not yet been closed by
* fbird_blob_close.
*
* @param resource $blob_handle A BLOB handle opened with fbird_blob_create.
* @throws IbaseException
*
*/
function fbird_blob_cancel($blob_handle): void
{
error_clear_last();
$safeResult = \fbird_blob_cancel($blob_handle);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param resource $service_handle The handle on the database server service.
* @param string $user_name The login name of the new database user.
* @param string $password The password of the new user.
* @param string $first_name The first name of the new database user.
* @param string $middle_name The middle name of the new database user.
* @param string $last_name The last name of the new database user.
* @throws IbaseException
*
*/
function ibase_add_user($service_handle, string $user_name, string $password, ?string $first_name = null, ?string $middle_name = null, ?string $last_name = null): void
{
error_clear_last();
if ($last_name !== null) {
$safeResult = \ibase_add_user($service_handle, $user_name, $password, $first_name, $middle_name, $last_name);
} elseif ($middle_name !== null) {
$safeResult = \ibase_add_user($service_handle, $user_name, $password, $first_name, $middle_name);
} elseif ($first_name !== null) {
$safeResult = \ibase_add_user($service_handle, $user_name, $password, $first_name);
} else {
$safeResult = \ibase_add_user($service_handle, $user_name, $password);
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This function passes the arguments to the (remote) database server. There it starts a new backup process. Therefore you
* won't get any responses.
*
* @param resource $service_handle A previously opened connection to the database server.
* @param string $source_db The absolute file path to the database on the database server. You can also use a database alias.
* @param string $dest_file The path to the backup file on the database server.
* @param int $options Additional options to pass to the database server for backup.
* The options parameter can be a combination
* of the following constants:
* IBASE_BKP_IGNORE_CHECKSUMS,
* IBASE_BKP_IGNORE_LIMBO,
* IBASE_BKP_METADATA_ONLY,
* IBASE_BKP_NO_GARBAGE_COLLECT,
* IBASE_BKP_OLD_DESCRIPTIONS,
* IBASE_BKP_NON_TRANSPORTABLE or
* IBASE_BKP_CONVERT.
* Read the section about for further information.
* @param bool $verbose Since the backup process is done on the database server, you don't have any chance
* to get its output. This argument is useless.
* @return mixed Returns TRUE on success.
*
* Since the backup process is done on the (remote) server, this function just passes the arguments to it.
* While the arguments are legal, you won't get FALSE.
* @throws IbaseException
*
*/
function ibase_backup($service_handle, string $source_db, string $dest_file, int $options = 0, bool $verbose = false)
{
error_clear_last();
$safeResult = \ibase_backup($service_handle, $source_db, $dest_file, $options, $verbose);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* This function will discard a BLOB if it has not yet been closed by
* ibase_blob_close.
*
* @param resource $blob_handle A BLOB handle opened with ibase_blob_create.
* @throws IbaseException
*
*/
function ibase_blob_cancel($blob_handle): void
{
error_clear_last();
$safeResult = \ibase_blob_cancel($blob_handle);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* ibase_blob_create creates a new BLOB for filling with
* data.
*
* @param null|resource $link_identifier An InterBase link identifier. If omitted, the last opened link is
* assumed.
* @return resource Returns a BLOB handle for later use with
* ibase_blob_add.
* @throws IbaseException
*
*/
function ibase_blob_create($link_identifier = null)
{
error_clear_last();
if ($link_identifier !== null) {
$safeResult = \ibase_blob_create($link_identifier);
} else {
$safeResult = \ibase_blob_create();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* This function returns at most len bytes from a BLOB
* that has been opened for reading by ibase_blob_open.
*
* @param resource $blob_handle A BLOB handle opened with ibase_blob_open.
* @param int $len Size of returned data.
* @return string Returns at most len bytes from the BLOB.
* @throws IbaseException
*
*/
function ibase_blob_get($blob_handle, int $len): string
{
error_clear_last();
$safeResult = \ibase_blob_get($blob_handle, $len);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* Closes the link to an InterBase database that's associated with
* a connection id returned from ibase_connect.
* Default transaction on link is committed, other transactions are
* rolled back.
*
* @param null|resource $connection_id An InterBase link identifier returned from
* ibase_connect. If omitted, the last opened link
* is assumed.
* @throws IbaseException
*
*/
function ibase_close($connection_id = null): void
{
error_clear_last();
if ($connection_id !== null) {
$safeResult = \ibase_close($connection_id);
} else {
$safeResult = \ibase_close();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Commits a transaction without closing it.
*
* @param null|resource $link_or_trans_identifier If called without an argument, this function commits the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be committed. If the argument is a transaction identifier, the
* corresponding transaction will be committed. The transaction context
* will be retained, so statements executed from within this transaction
* will not be invalidated.
* @throws IbaseException
*
*/
function ibase_commit_ret($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_commit_ret($link_or_trans_identifier);
} else {
$safeResult = \ibase_commit_ret();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Commits a transaction.
*
* @param null|resource $link_or_trans_identifier If called without an argument, this function commits the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be committed. If the argument is a transaction identifier, the
* corresponding transaction will be committed.
* @throws IbaseException
*
*/
function ibase_commit($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_commit($link_or_trans_identifier);
} else {
$safeResult = \ibase_commit();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Establishes a connection to an Firebird/InterBase server.
*
* In case a second call is made to ibase_connect with
* the same arguments, no new link will be established, but instead, the link
* identifier of the already opened link will be returned. The link to the
* server will be closed as soon as the execution of the script ends, unless
* it's closed earlier by explicitly calling ibase_close.
*
* @param string $database The database argument has to be a valid path to
* database file on the server it resides on. If the server is not local,
* it must be prefixed with either 'hostname:' (TCP/IP), 'hostname/port:'
* (TCP/IP with interbase server on custom TCP port), '//hostname/'
* (NetBEUI), depending on the connection
* protocol used.
* @param string $username The user name. Can be set with the
* ibase.default_user php.ini directive.
* @param string $password The password for username. Can be set with the
* ibase.default_password php.ini directive.
* @param string $charset charset is the default character set for a
* database.
* @param int $buffers buffers is the number of database buffers to
* allocate for the server-side cache. If 0 or omitted, server chooses
* its own default.
* @param int $dialect dialect selects the default SQL dialect for any
* statement executed within a connection, and it defaults to the highest
* one supported by client libraries.
* @param string $role Functional only with InterBase 5 and up.
* @param int $sync
* @return resource Returns an Firebird/InterBase link identifier on success.
* @throws IbaseException
*
*/
function ibase_connect(?string $database = null, ?string $username = null, ?string $password = null, ?string $charset = null, ?int $buffers = null, ?int $dialect = null, ?string $role = null, ?int $sync = null)
{
error_clear_last();
if ($sync !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync);
} elseif ($role !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect, $role);
} elseif ($dialect !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect);
} elseif ($buffers !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset, $buffers);
} elseif ($charset !== null) {
$safeResult = \ibase_connect($database, $username, $password, $charset);
} elseif ($password !== null) {
$safeResult = \ibase_connect($database, $username, $password);
} elseif ($username !== null) {
$safeResult = \ibase_connect($database, $username);
} elseif ($database !== null) {
$safeResult = \ibase_connect($database);
} else {
$safeResult = \ibase_connect();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param resource $service_handle The handle on the database server service.
* @param string $user_name The login name of the user you want to delete from the database.
* @throws IbaseException
*
*/
function ibase_delete_user($service_handle, string $user_name): void
{
error_clear_last();
$safeResult = \ibase_delete_user($service_handle, $user_name);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This functions drops a database that was opened by either ibase_connect
* or ibase_pconnect. The database is closed and deleted from the server.
*
* @param null|resource $connection An InterBase link identifier. If omitted, the last opened link is
* assumed.
* @throws IbaseException
*
*/
function ibase_drop_db($connection = null): void
{
error_clear_last();
if ($connection !== null) {
$safeResult = \ibase_drop_db($connection);
} else {
$safeResult = \ibase_drop_db();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This function causes the registered event handler specified by
* event to be cancelled. The callback function will
* no longer be called for the events it was registered to handle.
*
* @param resource $event An event resource, created by
* ibase_set_event_handler.
* @throws IbaseException
*
*/
function ibase_free_event_handler($event): void
{
error_clear_last();
$safeResult = \ibase_free_event_handler($event);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Frees a prepared query.
*
* @param resource $query A query prepared with ibase_prepare.
* @throws IbaseException
*
*/
function ibase_free_query($query): void
{
error_clear_last();
$safeResult = \ibase_free_query($query);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Frees a result set.
*
* @param resource $result_identifier A result set created by ibase_query or
* ibase_execute.
* @throws IbaseException
*
*/
function ibase_free_result($result_identifier): void
{
error_clear_last();
$safeResult = \ibase_free_result($result_identifier);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param resource $service_handle
* @param string $db
* @param int $action
* @param int $argument
* @throws IbaseException
*
*/
function ibase_maintain_db($service_handle, string $db, int $action, int $argument = 0): void
{
error_clear_last();
$safeResult = \ibase_maintain_db($service_handle, $db, $action, $argument);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param resource $service_handle The handle on the database server service.
* @param string $user_name The login name of the database user to modify.
* @param string $password The user's new password.
* @param string $first_name The user's new first name.
* @param string $middle_name The user's new middle name.
* @param string $last_name The user's new last name.
* @throws IbaseException
*
*/
function ibase_modify_user($service_handle, string $user_name, string $password, ?string $first_name = null, ?string $middle_name = null, ?string $last_name = null): void
{
error_clear_last();
if ($last_name !== null) {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password, $first_name, $middle_name, $last_name);
} elseif ($middle_name !== null) {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password, $first_name, $middle_name);
} elseif ($first_name !== null) {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password, $first_name);
} else {
$safeResult = \ibase_modify_user($service_handle, $user_name, $password);
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* This function assigns a name to a result set. This name can be used later in
* UPDATE|DELETE ... WHERE CURRENT OF name statements.
*
* @param resource $result An InterBase result set.
* @param string $name The name to be assigned.
* @throws IbaseException
*
*/
function ibase_name_result($result, string $name): void
{
error_clear_last();
$safeResult = \ibase_name_result($result, $name);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Opens a persistent connection to an InterBase database.
*
* ibase_pconnect acts very much like
* ibase_connect with two major differences.
*
* First, when connecting, the function will first try to find a (persistent)
* link that's already opened with the same parameters. If one is found, an
* identifier for it will be returned instead of opening a new connection.
*
* Second, the connection to the InterBase server will not be closed when the
* execution of the script ends. Instead, the link will remain open for
* future use (ibase_close will not close links
* established by ibase_pconnect). This type of link is
* therefore called 'persistent'.
*
* @param string $database The database argument has to be a valid path to
* database file on the server it resides on. If the server is not local,
* it must be prefixed with either 'hostname:' (TCP/IP), '//hostname/'
* (NetBEUI) or 'hostname@' (IPX/SPX), depending on the connection
* protocol used.
* @param string $username The user name. Can be set with the
* ibase.default_user php.ini directive.
* @param string $password The password for username. Can be set with the
* ibase.default_password php.ini directive.
* @param string $charset charset is the default character set for a
* database.
* @param int $buffers buffers is the number of database buffers to
* allocate for the server-side cache. If 0 or omitted, server chooses
* its own default.
* @param int $dialect dialect selects the default SQL dialect for any
* statement executed within a connection, and it defaults to the highest
* one supported by client libraries. Functional only with InterBase 6
* and up.
* @param string $role Functional only with InterBase 5 and up.
* @param int $sync
* @return resource Returns an InterBase link identifier on success.
* @throws IbaseException
*
*/
function ibase_pconnect(?string $database = null, ?string $username = null, ?string $password = null, ?string $charset = null, ?int $buffers = null, ?int $dialect = null, ?string $role = null, ?int $sync = null)
{
error_clear_last();
if ($sync !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync);
} elseif ($role !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect, $role);
} elseif ($dialect !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect);
} elseif ($buffers !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset, $buffers);
} elseif ($charset !== null) {
$safeResult = \ibase_pconnect($database, $username, $password, $charset);
} elseif ($password !== null) {
$safeResult = \ibase_pconnect($database, $username, $password);
} elseif ($username !== null) {
$safeResult = \ibase_pconnect($database, $username);
} elseif ($database !== null) {
$safeResult = \ibase_pconnect($database);
} else {
$safeResult = \ibase_pconnect();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* This function passes the arguments to the (remote) database server. There it starts a new restore process. Therefore you
* won't get any responses.
*
* @param resource $service_handle A previously opened connection to the database server.
* @param string $source_file The absolute path on the server where the backup file is located.
* @param string $dest_db The path to create the new database on the server. You can also use database alias.
* @param int $options Additional options to pass to the database server for restore.
* The options parameter can be a combination
* of the following constants:
* IBASE_RES_DEACTIVATE_IDX,
* IBASE_RES_NO_SHADOW,
* IBASE_RES_NO_VALIDITY,
* IBASE_RES_ONE_AT_A_TIME,
* IBASE_RES_REPLACE,
* IBASE_RES_CREATE,
* IBASE_RES_USE_ALL_SPACE,
* IBASE_PRP_PAGE_BUFFERS,
* IBASE_PRP_SWEEP_INTERVAL,
* IBASE_RES_CREATE.
* Read the section about for further information.
* @param bool $verbose Since the restore process is done on the database server, you don't have any chance
* to get its output. This argument is useless.
* @return mixed Returns TRUE on success.
*
* Since the restore process is done on the (remote) server, this function just passes the arguments to it.
* While the arguments are legal, you won't get FALSE.
* @throws IbaseException
*
*/
function ibase_restore($service_handle, string $source_file, string $dest_db, int $options = 0, bool $verbose = false)
{
error_clear_last();
$safeResult = \ibase_restore($service_handle, $source_file, $dest_db, $options, $verbose);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
* Rolls back a transaction without closing it.
*
* @param null|resource $link_or_trans_identifier If called without an argument, this function rolls back the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be rolled back. If the argument is a transaction identifier, the
* corresponding transaction will be rolled back. The transaction context
* will be retained, so statements executed from within this transaction
* will not be invalidated.
* @throws IbaseException
*
*/
function ibase_rollback_ret($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_rollback_ret($link_or_trans_identifier);
} else {
$safeResult = \ibase_rollback_ret();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
* Rolls back a transaction.
*
* @param null|resource $link_or_trans_identifier If called without an argument, this function rolls back the default
* transaction of the default link. If the argument is a connection
* identifier, the default transaction of the corresponding connection
* will be rolled back. If the argument is a transaction identifier, the
* corresponding transaction will be rolled back.
* @throws IbaseException
*
*/
function ibase_rollback($link_or_trans_identifier = null): void
{
error_clear_last();
if ($link_or_trans_identifier !== null) {
$safeResult = \ibase_rollback($link_or_trans_identifier);
} else {
$safeResult = \ibase_rollback();
}
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}
/**
*
*
* @param string $host The name or ip address of the database host. You can define the port by adding
* '/' and port number. If no port is specified, port 3050 will be used.
* @param string $dba_username The name of any valid user.
* @param string $dba_password The user's password.
* @return resource Returns a Interbase / Firebird link identifier on success.
* @throws IbaseException
*
*/
function ibase_service_attach(string $host, string $dba_username, string $dba_password)
{
error_clear_last();
$safeResult = \ibase_service_attach($host, $dba_username, $dba_password);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param resource $service_handle A previously created connection to the database server.
* @throws IbaseException
*
*/
function ibase_service_detach($service_handle): void
{
error_clear_last();
$safeResult = \ibase_service_detach($service_handle);
if ($safeResult === false) {
throw IbaseException::createFromPhpError();
}
}

0
vendor/thecodingmachine/safe/generated/8.4/ibmDb2.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,309 @@
<?php
namespace Safe;
use Safe\Exceptions\IconvException;
/**
* Retrieve internal configuration variables of iconv extension.
*
* @param string $type The value of the optional type can be:
*
* all
* input_encoding
* output_encoding
* internal_encoding
*
* @return mixed Returns the current value of the internal configuration variable if
* successful.
*
* If type is omitted or set to "all",
* iconv_get_encoding returns an array that
* stores all these variables.
* @throws IconvException
*
*/
function iconv_get_encoding(string $type = "all")
{
error_clear_last();
$safeResult = \iconv_get_encoding($type);
if ($safeResult === false) {
throw IconvException::createFromPhpError();
}
return $safeResult;
}
/**
* Decodes a MIME header field.
*
* @param string $string The encoded header, as a string.
* @param int $mode mode determines the behaviour in the event
* iconv_mime_decode encounters a malformed
* MIME header field. You can specify any combination
* of the following bitmasks.
*
* Bitmasks acceptable to iconv_mime_decode
*
*
*
* Value
* Constant
* Description
*
*
*
*
* 1
* ICONV_MIME_DECODE_STRICT
*
* If set, the given header is decoded in full conformance with the
* standards defined in RFC2047.
* This option is disabled by default because there are a lot of
* broken mail user agents that don't follow the specification and don't
* produce correct MIME headers.
*
*
*
* 2
* ICONV_MIME_DECODE_CONTINUE_ON_ERROR
*
* If set, iconv_mime_decode_headers
* attempts to ignore any grammatical errors and continue to process
* a given header.
*
*
*
*
*
* @param null|string $encoding The optional encoding parameter specifies the
* character set to represent the result by. If omitted or NULL,
* iconv.internal_encoding
* will be used.
* @return string Returns a decoded MIME field on success,
* or FALSE if an error occurs during the decoding.
* @throws IconvException
*
*/
function iconv_mime_decode(string $string, int $mode = 0, ?string $encoding = null): string
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \iconv_mime_decode($string, $mode, $encoding);
} else {
$safeResult = \iconv_mime_decode($string, $mode);
}
if ($safeResult === false) {
throw IconvException::createFromPhpError();
}
return $safeResult;
}
/**
* Composes and returns a string that represents a valid MIME
* header field, which looks like the following:
*
*
*
* In the above example, "Subject" is the field name and the portion that
* begins with "=?ISO-8859-1?..." is the field value.
*
* @param string $field_name The field name.
* @param string $field_value The field value.
* @param array $options You can control the behaviour of iconv_mime_encode
* by specifying an associative array that contains configuration items
* to the optional third parameter options.
* The items supported by iconv_mime_encode are
* listed below. Note that item names are treated case-sensitive.
*
* Configuration items supported by iconv_mime_encode
*
*
*
* Item
* Type
* Description
* Default value
* Example
*
*
*
*
* scheme
* string
*
* Specifies the method to encode a field value by. The value of
* this item may be either "B" or "Q", where "B" stands for
* base64 encoding scheme and "Q" stands for
* quoted-printable encoding scheme.
*
* B
* B
*
*
* input-charset
* string
*
* Specifies the character set in which the first parameter
* field_name and the second parameter
* field_value are presented. If not given,
* iconv_mime_encode assumes those parameters
* are presented to it in the
* iconv.internal_encoding
* ini setting.
*
*
* iconv.internal_encoding
*
* ISO-8859-1
*
*
* output-charset
* string
*
* Specifies the character set to use to compose the
* MIME header.
*
*
* iconv.internal_encoding
*
* UTF-8
*
*
* line-length
* int
*
* Specifies the maximum length of the header lines. The resulting
* header is "folded" to a set of multiple lines in case
* the resulting header field would be longer than the value of this
* parameter, according to
* RFC2822 - Internet Message Format.
* If not given, the length will be limited to 76 characters.
*
* 76
* 996
*
*
* line-break-chars
* string
*
* Specifies the sequence of characters to append to each line
* as an end-of-line sign when "folding" is performed on a long header
* field. If not given, this defaults to "\r\n"
* (CR LF). Note that
* this parameter is always treated as an ASCII string regardless
* of the value of input-charset.
*
* \r\n
* \n
*
*
*
*
* @return string Returns an encoded MIME field on success,
* or FALSE if an error occurs during the encoding.
* @throws IconvException
*
*/
function iconv_mime_encode(string $field_name, string $field_value, array $options = []): string
{
error_clear_last();
$safeResult = \iconv_mime_encode($field_name, $field_value, $options);
if ($safeResult === false) {
throw IconvException::createFromPhpError();
}
return $safeResult;
}
/**
* Changes the value of the internal configuration variable specified by
* type to encoding.
*
* @param string $type The value of type can be any one of these:
*
* input_encoding
* output_encoding
* internal_encoding
*
* @param string $encoding The character set.
* @throws IconvException
*
*/
function iconv_set_encoding(string $type, string $encoding): void
{
error_clear_last();
$safeResult = \iconv_set_encoding($type, $encoding);
if ($safeResult === false) {
throw IconvException::createFromPhpError();
}
}
/**
* In contrast to strlen,
* iconv_strlen counts the occurrences of characters
* in the given byte sequence string on the basis of
* the specified character set, the result of which is not necessarily
* identical to the length of the string in bytes.
*
* @param string $string The string.
* @param null|string $encoding If encoding parameter is omitted or NULL,
* string is assumed to be encoded in
* iconv.internal_encoding.
* @return 0|positive-int Returns the character count of string, as an integer,
* or FALSE if an error occurs during the encoding.
* @throws IconvException
*
*/
function iconv_strlen(string $string, ?string $encoding = null): int
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \iconv_strlen($string, $encoding);
} else {
$safeResult = \iconv_strlen($string);
}
if ($safeResult === false) {
throw IconvException::createFromPhpError();
}
return $safeResult;
}
/**
* Converts string from from_encoding
* to to_encoding.
*
* @param string $from_encoding The current encoding used to interpret string.
* @param string $to_encoding The desired encoding of the result.
*
* If the string //TRANSLIT is appended to
* to_encoding, then transliteration is activated. This
* means that when a character can't be represented in the target charset,
* it may be approximated through one or several similarly looking
* characters. If the string //IGNORE is appended,
* characters that cannot be represented in the target charset are silently
* discarded. Otherwise, E_NOTICE is generated and the function
* will return FALSE.
*
* If and how //TRANSLIT works exactly depends on the
* system's iconv() implementation (cf. ICONV_IMPL).
* Some implementations are known to ignore //TRANSLIT,
* so the conversion is likely to fail for characters which are illegal for
* the to_encoding.
* @param string $string The string to be converted.
* @return string Returns the converted string.
* @throws IconvException
*
*/
function iconv(string $from_encoding, string $to_encoding, string $string): string
{
error_clear_last();
$safeResult = \iconv($from_encoding, $to_encoding, $string);
if ($safeResult === false) {
throw IconvException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/image.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/imap.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/info.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/inotify.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,58 @@
<?php
namespace Safe;
use Safe\Exceptions\JsonException;
/**
* Returns a string containing the JSON representation of the supplied
* value. If the parameter is an array or object,
* it will be serialized recursively.
*
* If a value to be serialized is an object, then by default only publicly visible
* properties will be included. Alternatively, a class may implement JsonSerializable
* to control how its values are serialized to JSON.
*
* The encoding is affected by the supplied flags
* and additionally the encoding of float values depends on the value of
* serialize_precision.
*
* @param mixed $value The value being encoded. Can be any type except
* a resource.
*
* All string data must be UTF-8 encoded.
*
* PHP implements a superset of JSON as specified in the original
* RFC 7159.
* @param int $flags Bitmask consisting of
* JSON_FORCE_OBJECT,
* JSON_HEX_QUOT,
* JSON_HEX_TAG,
* JSON_HEX_AMP,
* JSON_HEX_APOS,
* JSON_INVALID_UTF8_IGNORE,
* JSON_INVALID_UTF8_SUBSTITUTE,
* JSON_NUMERIC_CHECK,
* JSON_PARTIAL_OUTPUT_ON_ERROR,
* JSON_PRESERVE_ZERO_FRACTION,
* JSON_PRETTY_PRINT,
* JSON_UNESCAPED_LINE_TERMINATORS,
* JSON_UNESCAPED_SLASHES,
* JSON_UNESCAPED_UNICODE,
* JSON_THROW_ON_ERROR.
* The behaviour of these constants is described on the
* JSON constants page.
* @param positive-int $depth Set the maximum depth. Must be greater than zero.
* @return non-empty-string Returns a JSON encoded string on success.
* @throws JsonException
*
*/
function json_encode($value, int $flags = 0, int $depth = 512): string
{
error_clear_last();
$safeResult = \json_encode($value, $flags, $depth);
if ($safeResult === false) {
throw JsonException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/ldap.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,59 @@
<?php
namespace Safe;
use Safe\Exceptions\LibxmlException;
/**
* Changes the default external entity loader.
* This can be used to suppress the expansion of arbitrary external entities to avoid XXE attacks,
* even when LIBXML_NOENT has been set for the respective operation,
* and is usually preferable over calling libxml_disable_entity_loader.
*
* @param callable $resolver_function A callable with the following signature:
*
* resourcestringnullresolver
* stringnullpublic_id
* stringsystem_id
* arraycontext
*
*
*
* public_id
*
*
* The public ID.
*
*
*
*
* system_id
*
*
* The system ID.
*
*
*
*
* context
*
*
* An array with the four elements "directory", "intSubName",
* "extSubURI" and "extSubSystem".
*
*
*
*
* This callable should return a resource, a string from which a resource can be
* opened. If NULL is returned, the entity reference resolution will fail.
* @throws LibxmlException
*
*/
function libxml_set_external_entity_loader(callable $resolver_function): void
{
error_clear_last();
$safeResult = \libxml_set_external_entity_loader($resolver_function);
if ($safeResult === false) {
throw LibxmlException::createFromPhpError();
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Safe;
use Safe\Exceptions\LzfException;
/**
* lzf_compress compresses the given
* data string using LZF encoding.
*
* @param string $data The string to compress.
* @return string Returns the compressed data.
* @throws LzfException
*
*/
function lzf_compress(string $data): string
{
error_clear_last();
$safeResult = \lzf_compress($data);
if ($safeResult === false) {
throw LzfException::createFromPhpError();
}
return $safeResult;
}
/**
* lzf_compress decompresses the given
* data string containing lzf encoded data.
*
* @param string $data The compressed string.
* @return string Returns the decompressed data.
* @throws LzfException
*
*/
function lzf_decompress(string $data): string
{
error_clear_last();
$safeResult = \lzf_decompress($data);
if ($safeResult === false) {
throw LzfException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,127 @@
<?php
namespace Safe;
use Safe\Exceptions\MailparseException;
/**
* Extracts/decodes a message section from the supplied filename.
*
* The contents of the section will be decoded according to their transfer
* encoding - base64, quoted-printable and uuencoded text are supported.
*
* @param resource $mimemail A valid MIME resource, created with
* mailparse_msg_create.
* @param mixed $filename Can be a file name or a valid stream resource.
* @param callable $callbackfunc If set, this must be either a valid callback that will be passed the
* extracted section, or NULL to make this function return the
* extracted section.
*
* If not specified, the contents will be sent to "stdout".
* @return string If callbackfunc is not NULL returns TRUE on
* success.
*
* If callbackfunc is set to NULL, returns the
* extracted section as a string.
* @throws MailparseException
*
*/
function mailparse_msg_extract_part_file($mimemail, $filename, ?callable $callbackfunc = null): string
{
error_clear_last();
if ($callbackfunc !== null) {
$safeResult = \mailparse_msg_extract_part_file($mimemail, $filename, $callbackfunc);
} else {
$safeResult = \mailparse_msg_extract_part_file($mimemail, $filename);
}
if ($safeResult === false) {
throw MailparseException::createFromPhpError();
}
return $safeResult;
}
/**
* Frees a MIME resource.
*
* @param resource $mimemail A valid MIME resource allocated by
* mailparse_msg_create or
* mailparse_msg_parse_file.
* @throws MailparseException
*
*/
function mailparse_msg_free($mimemail): void
{
error_clear_last();
$safeResult = \mailparse_msg_free($mimemail);
if ($safeResult === false) {
throw MailparseException::createFromPhpError();
}
}
/**
* Parses a file.
* This is the optimal way of parsing a mail file that you have on disk.
*
* @param string $filename Path to the file holding the message.
* The file is opened and streamed through the parser.
*
* The message contained in filename is supposed to end with a newline
* (CRLF); otherwise the last line of the message will not be parsed.
* @return resource Returns a MIME resource representing the structure.
* @throws MailparseException
*
*/
function mailparse_msg_parse_file(string $filename)
{
error_clear_last();
$safeResult = \mailparse_msg_parse_file($filename);
if ($safeResult === false) {
throw MailparseException::createFromPhpError();
}
return $safeResult;
}
/**
* Incrementally parse data into the supplied mime mail resource.
*
* This function allow you to stream portions of a file at a time, rather
* than read and parse the whole thing.
*
* @param resource $mimemail A valid MIME resource.
* @param string $data The final chunk of data is supposed to end with a newline
* (CRLF); otherwise the last line of the message will not be parsed.
* @throws MailparseException
*
*/
function mailparse_msg_parse($mimemail, string $data): void
{
error_clear_last();
$safeResult = \mailparse_msg_parse($mimemail, $data);
if ($safeResult === false) {
throw MailparseException::createFromPhpError();
}
}
/**
* Streams data from the source file pointer, apply
* encoding and write to the destination file pointer.
*
* @param resource $sourcefp A valid file handle. The file is streamed through the parser.
* @param resource $destfp The destination file handle in which the encoded data will be written.
* @param string $encoding One of the character encodings supported by the
* mbstring module.
* @throws MailparseException
*
*/
function mailparse_stream_encode($sourcefp, $destfp, string $encoding): void
{
error_clear_last();
$safeResult = \mailparse_stream_encode($sourcefp, $destfp, $encoding);
if ($safeResult === false) {
throw MailparseException::createFromPhpError();
}
}

0
vendor/thecodingmachine/safe/generated/8.4/mbstring.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/misc.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,938 @@
<?php
namespace Safe;
use Safe\Exceptions\MysqlException;
/**
* mysql_close closes the non-persistent connection to
* the MySQL server that's associated with the specified link identifier. If
* link_identifier isn't specified, the last opened
* link is used.
*
*
* Open non-persistent MySQL connections and result sets are automatically destroyed when a
* PHP script finishes its execution. So, while explicitly closing open
* connections and freeing result sets is optional, doing so is recommended.
* This will immediately return resources to PHP and MySQL, which can
* improve performance. For related information, see
* freeing resources
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no connection is found or
* established, an E_WARNING level error is
* generated.
* @throws MysqlException
*
*/
function mysql_close($link_identifier = null): void
{
error_clear_last();
$safeResult = \mysql_close($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* Opens or reuses a connection to a MySQL server.
*
* @param string $server The MySQL server. It can also include a port number. e.g.
* "hostname:port" or a path to a local socket e.g. ":/path/to/socket" for
* the localhost.
*
* If the PHP directive
* mysql.default_host is undefined (default), then the default
* value is 'localhost:3306'. In SQL safe mode, this parameter is ignored
* and value 'localhost:3306' is always used.
* @param string $username The username. Default value is defined by mysql.default_user. In
* SQL safe mode, this parameter is ignored and the name of the user that
* owns the server process is used.
* @param string $password The password. Default value is defined by mysql.default_password. In
* SQL safe mode, this parameter is ignored and empty password is used.
* @param bool $new_link If a second call is made to mysql_connect
* with the same arguments, no new link will be established, but
* instead, the link identifier of the already opened link will be
* returned. The new_link parameter modifies this
* behavior and makes mysql_connect always open
* a new link, even if mysql_connect was called
* before with the same parameters.
* In SQL safe mode, this parameter is ignored.
* @param int $client_flags The client_flags parameter can be a combination
* of the following constants:
* 128 (enable LOAD DATA LOCAL handling),
* MYSQL_CLIENT_SSL,
* MYSQL_CLIENT_COMPRESS,
* MYSQL_CLIENT_IGNORE_SPACE or
* MYSQL_CLIENT_INTERACTIVE.
* Read the section about for further information.
* In SQL safe mode, this parameter is ignored.
* @return resource Returns a MySQL link identifier on success.
* @throws MysqlException
*
*/
function mysql_connect(?string $server = null, ?string $username = null, ?string $password = null, bool $new_link = false, int $client_flags = 0)
{
error_clear_last();
if ($client_flags !== 0) {
$safeResult = \mysql_connect($server, $username, $password, $new_link, $client_flags);
} elseif ($new_link !== false) {
$safeResult = \mysql_connect($server, $username, $password, $new_link);
} elseif ($password !== null) {
$safeResult = \mysql_connect($server, $username, $password);
} elseif ($username !== null) {
$safeResult = \mysql_connect($server, $username);
} elseif ($server !== null) {
$safeResult = \mysql_connect($server);
} else {
$safeResult = \mysql_connect();
}
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_create_db attempts to create a new
* database on the server associated with the specified link
* identifier.
*
* @param string $database_name The name of the database being created.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @throws MysqlException
*
*/
function mysql_create_db(string $database_name, $link_identifier = null): void
{
error_clear_last();
$safeResult = \mysql_create_db($database_name, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* mysql_data_seek moves the internal row
* pointer of the MySQL result associated with the specified result
* identifier to point to the specified row number. The next call
* to a MySQL fetch function, such as mysql_fetch_assoc,
* would return that row.
*
* row_number starts at 0. The
* row_number should be a value in the range from 0 to
* mysql_num_rows - 1. However if the result set
* is empty (mysql_num_rows == 0), a seek to 0 will
* fail with an E_WARNING and
* mysql_data_seek will return FALSE.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @param int $row_number The desired row number of the new result pointer.
* @throws MysqlException
*
*/
function mysql_data_seek($result, int $row_number): void
{
error_clear_last();
$safeResult = \mysql_data_seek($result, $row_number);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* Retrieve the database name from a call to
* mysql_list_dbs.
*
* @param resource $result The result pointer from a call to mysql_list_dbs.
* @param int $row The index into the result set.
* @param mixed $field The field name.
* @return string Returns the database name on success. If FALSE
* is returned, use mysql_error to determine the nature
* of the error.
* @throws MysqlException
*
*/
function mysql_db_name($result, int $row, $field = null): string
{
error_clear_last();
$safeResult = \mysql_db_name($result, $row, $field);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_db_query selects a database, and executes a
* query on it.
*
* @param string $database The name of the database that will be selected.
* @param string $query The MySQL query.
*
* Data inside the query should be properly escaped.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return bool|resource Returns a positive MySQL result resource to the query result. The function also returns TRUE/FALSE for
* INSERT/UPDATE/DELETE
* queries to indicate success/failure.
* @throws MysqlException
*
*/
function mysql_db_query(string $database, string $query, $link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_db_query($database, $query, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_drop_db attempts to drop (remove) an
* entire database from the server associated with the specified
* link identifier. This function is deprecated, it is preferable to use
* mysql_query to issue an sql
* DROP DATABASE statement instead.
*
* @param string $database_name The name of the database that will be deleted.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @throws MysqlException
*
*/
function mysql_drop_db(string $database_name, $link_identifier = null): void
{
error_clear_last();
$safeResult = \mysql_drop_db($database_name, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* Returns an array that corresponds to the lengths of each field
* in the last row fetched by MySQL.
*
* mysql_fetch_lengths stores the lengths of
* each result column in the last row returned by
* mysql_fetch_row,
* mysql_fetch_assoc,
* mysql_fetch_array, and
* mysql_fetch_object in an array, starting at
* offset 0.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @return array An array of lengths on success.
* @throws MysqlException
*
*/
function mysql_fetch_lengths($result): array
{
error_clear_last();
$safeResult = \mysql_fetch_lengths($result);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_field_flags returns the field flags of
* the specified field. The flags are reported as a single word
* per flag separated by a single space, so that you can split the
* returned value using explode.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @param int $field_offset The numerical field offset. The
* field_offset starts at 0. If
* field_offset does not exist, an error of level
* E_WARNING is also issued.
* @return string Returns a string of flags associated with the result.
*
* The following flags are reported, if your version of MySQL
* is current enough to support them: "not_null",
* "primary_key", "unique_key",
* "multiple_key", "blob",
* "unsigned", "zerofill",
* "binary", "enum",
* "auto_increment" and "timestamp".
* @throws MysqlException
*
*/
function mysql_field_flags($result, int $field_offset): string
{
error_clear_last();
$safeResult = \mysql_field_flags($result, $field_offset);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_field_len returns the length of the
* specified field.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @param int $field_offset The numerical field offset. The
* field_offset starts at 0. If
* field_offset does not exist, an error of level
* E_WARNING is also issued.
* @return int The length of the specified field index on success.
* @throws MysqlException
*
*/
function mysql_field_len($result, int $field_offset): int
{
error_clear_last();
$safeResult = \mysql_field_len($result, $field_offset);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_field_name returns the name of the
* specified field index.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @param int $field_offset The numerical field offset. The
* field_offset starts at 0. If
* field_offset does not exist, an error of level
* E_WARNING is also issued.
* @return string The name of the specified field index on success.
* @throws MysqlException
*
*/
function mysql_field_name($result, int $field_offset): string
{
error_clear_last();
$safeResult = \mysql_field_name($result, $field_offset);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Seeks to the specified field offset. If the next call to
* mysql_fetch_field doesn't include a field
* offset, the field offset specified in
* mysql_field_seek will be returned.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @param int $field_offset The numerical field offset. The
* field_offset starts at 0. If
* field_offset does not exist, an error of level
* E_WARNING is also issued.
* @throws MysqlException
*
*/
function mysql_field_seek($result, int $field_offset): void
{
error_clear_last();
$safeResult = \mysql_field_seek($result, $field_offset);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* mysql_free_result will free all memory
* associated with the result identifier result.
*
* mysql_free_result only needs to be called if
* you are concerned about how much memory is being used for queries
* that return large result sets. All associated result memory is
* automatically freed at the end of the script's execution.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @throws MysqlException
*
*/
function mysql_free_result($result): void
{
error_clear_last();
$safeResult = \mysql_free_result($result);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* Describes the type of connection in use for the connection, including the
* server host name.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return string Returns a string describing the type of MySQL connection in use for the
* connection.
* @throws MysqlException
*
*/
function mysql_get_host_info($link_identifier = null): string
{
error_clear_last();
$safeResult = \mysql_get_host_info($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the MySQL protocol.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return int Returns the MySQL protocol on success.
* @throws MysqlException
*
*/
function mysql_get_proto_info($link_identifier = null): int
{
error_clear_last();
$safeResult = \mysql_get_proto_info($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the MySQL server version.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return string Returns the MySQL server version on success.
* @throws MysqlException
*
*/
function mysql_get_server_info($link_identifier = null): string
{
error_clear_last();
$safeResult = \mysql_get_server_info($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns detailed information about the last query.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return string Returns information about the statement on success. See the example below for which statements provide information,
* and what the returned value may look like. Statements that are not listed
* will return FALSE.
* @throws MysqlException
*
*/
function mysql_info($link_identifier = null): string
{
error_clear_last();
$safeResult = \mysql_info($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns a result pointer containing the databases available from the
* current mysql daemon.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource Returns a result pointer resource on success. Use the mysql_tablename function to traverse
* this result pointer, or any function for result tables, such as
* mysql_fetch_array.
* @throws MysqlException
*
*/
function mysql_list_dbs($link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_list_dbs($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves information about the given table name.
*
* This function is deprecated. It is preferable to use
* mysql_query to issue an SQL SHOW COLUMNS FROM
* table [LIKE 'name'] statement instead.
*
* @param string $database_name The name of the database that's being queried.
* @param string $table_name The name of the table that's being queried.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource A result pointer resource on success.
*
* The returned result can be used with mysql_field_flags,
* mysql_field_len,
* mysql_field_name and
* mysql_field_type.
* @throws MysqlException
*
*/
function mysql_list_fields(string $database_name, string $table_name, $link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_list_fields($database_name, $table_name, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the current MySQL server threads.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource A result pointer resource on success.
* @throws MysqlException
*
*/
function mysql_list_processes($link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_list_processes($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves a list of table names from a MySQL database.
*
* This function is deprecated. It is preferable to use
* mysql_query to issue an SQL SHOW TABLES
* [FROM db_name] [LIKE 'pattern'] statement instead.
*
* @param string $database The name of the database
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource A result pointer resource on success.
*
* Use the mysql_tablename function to
* traverse this result pointer, or any function for result tables,
* such as mysql_fetch_array.
* @throws MysqlException
*
*/
function mysql_list_tables(string $database, $link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_list_tables($database, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the number of fields from a query.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @return int Returns the number of fields in the result set resource on
* success.
* @throws MysqlException
*
*/
function mysql_num_fields($result): int
{
error_clear_last();
$safeResult = \mysql_num_fields($result);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the number of rows from a result set. This command is only valid
* for statements like SELECT or SHOW that return an actual result set.
* To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or
* DELETE query, use mysql_affected_rows.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @return int The number of rows in a result set on success.
* @throws MysqlException
*
*/
function mysql_num_rows($result): int
{
error_clear_last();
$safeResult = \mysql_num_rows($result);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_query sends a unique query (multiple queries
* are not supported) to the currently
* active database on the server that's associated with the
* specified link_identifier.
*
* @param string $query An SQL query
*
* The query string should not end with a semicolon.
* Data inside the query should be properly escaped.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return bool|resource For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset,
* mysql_query
* returns a resource on success.
*
* For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc,
* mysql_query returns TRUE on success.
*
* The returned result resource should be passed to
* mysql_fetch_array, and other
* functions for dealing with result tables, to access the returned data.
*
* Use mysql_num_rows to find out how many rows
* were returned for a SELECT statement or
* mysql_affected_rows to find out how many
* rows were affected by a DELETE, INSERT, REPLACE, or UPDATE
* statement.
*
* mysql_query will also fail and return FALSE
* if the user does not have permission to access the table(s) referenced by
* the query.
* @throws MysqlException
*
*/
function mysql_query(string $query, $link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_query($query, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Escapes special characters in the unescaped_string,
* taking into account the current character set of the connection so that it
* is safe to place it in a mysql_query. If binary data
* is to be inserted, this function must be used.
*
* mysql_real_escape_string calls MySQL's library function
* mysql_real_escape_string, which prepends backslashes to the following characters:
* \x00, \n,
* \r, \, ',
* " and \x1a.
*
* This function must always (with few exceptions) be used to make data
* safe before sending a query to MySQL.
*
* @param string $unescaped_string The string that is to be escaped.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return string Returns the escaped string.
* @throws MysqlException
*
*/
function mysql_real_escape_string(string $unescaped_string, $link_identifier = null): string
{
error_clear_last();
$safeResult = \mysql_real_escape_string($unescaped_string, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the contents of one cell from a MySQL result set.
*
* When working on large result sets, you should consider using one
* of the functions that fetch an entire row (specified below). As
* these functions return the contents of multiple cells in one
* function call, they're MUCH quicker than
* mysql_result. Also, note that specifying a
* numeric offset for the field argument is much quicker than
* specifying a fieldname or tablename.fieldname argument.
*
* @param resource $result The result resource that
* is being evaluated. This result comes from a call to
* mysql_query.
* @param int $row The row number from the result that's being retrieved. Row numbers
* start at 0.
* @param mixed $field The name or offset of the field being retrieved.
*
* It can be the field's offset, the field's name, or the field's table
* dot field name (tablename.fieldname). If the column name has been
* aliased ('select foo as bar from...'), use the alias instead of the
* column name. If undefined, the first field is retrieved.
* @return string The contents of one cell from a MySQL result set on success.
* @throws MysqlException
*
*/
function mysql_result($result, int $row, $field = 0): string
{
error_clear_last();
$safeResult = \mysql_result($result, $row, $field);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Sets the current active database on the server that's associated with the
* specified link identifier. Every subsequent call to
* mysql_query will be made on the active database.
*
* @param string $database_name The name of the database that is to be selected.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @throws MysqlException
*
*/
function mysql_select_db(string $database_name, $link_identifier = null): void
{
error_clear_last();
$safeResult = \mysql_select_db($database_name, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* Sets the default character set for the current connection.
*
* @param string $charset A valid character set name.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @throws MysqlException
*
*/
function mysql_set_charset(string $charset, $link_identifier = null): void
{
error_clear_last();
$safeResult = \mysql_set_charset($charset, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
}
/**
* Retrieves the table name from a result.
*
* This function is deprecated. It is preferable to use
* mysql_query to issue an SQL SHOW TABLES
* [FROM db_name] [LIKE 'pattern'] statement instead.
*
* @param resource $result A result pointer resource that's returned from
* mysql_list_tables.
* @param int $i The integer index (row/table number)
* @return string The name of the table on success.
*
* Use the mysql_tablename function to
* traverse this result pointer, or any function for result tables,
* such as mysql_fetch_array.
* @throws MysqlException
*
*/
function mysql_tablename($result, int $i): string
{
error_clear_last();
$safeResult = \mysql_tablename($result, $i);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the current thread ID. If the connection is lost, and a reconnect
* with mysql_ping is executed, the thread ID will
* change. This means only retrieve the thread ID when needed.
*
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return int The thread ID on success.
* @throws MysqlException
*
*/
function mysql_thread_id($link_identifier = null): int
{
error_clear_last();
$safeResult = \mysql_thread_id($link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}
/**
* mysql_unbuffered_query sends the SQL query
* query to MySQL without automatically
* fetching and buffering the result rows as
* mysql_query does. This saves a considerable
* amount of memory with SQL queries that produce large result sets,
* and you can start working on the result set immediately after the
* first row has been retrieved as you don't have to wait until the
* complete SQL query has been performed. To use
* mysql_unbuffered_query while multiple database
* connections are open, you must specify the optional parameter
* link_identifier to identify which connection
* you want to use.
*
* @param string $query The SQL query to execute.
*
* Data inside the query should be properly escaped.
* @param null|resource $link_identifier The MySQL connection. If the
* link identifier is not specified, the last link opened by
* mysql_connect is assumed. If no such link is found, it
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return bool|resource For SELECT, SHOW, DESCRIBE or EXPLAIN statements,
* mysql_unbuffered_query
* returns a resource on success.
*
* For other type of SQL statements, UPDATE, DELETE, DROP, etc,
* mysql_unbuffered_query returns TRUE on success.
* @throws MysqlException
*
*/
function mysql_unbuffered_query(string $query, $link_identifier = null)
{
error_clear_last();
$safeResult = \mysql_unbuffered_query($query, $link_identifier);
if ($safeResult === false) {
throw MysqlException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Safe;
use Safe\Exceptions\MysqliException;
/**
* Returns client per-process statistics.
*
* @return array|false Returns an array with client stats.
*
*/
function mysqli_get_client_stats()
{
error_clear_last();
$safeResult = \mysqli_get_client_stats();
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/network.php vendored Normal file → Executable file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
<?php
namespace Safe;
use Safe\Exceptions\OpcacheException;
/**
* This function compiles a PHP script and adds it to the opcode cache without
* executing it. This can be used to prime the cache after a Web server
* restart by pre-caching files that will be included in later requests.
*
* @param string $filename The path to the PHP script to be compiled.
* @throws OpcacheException
*
*/
function opcache_compile_file(string $filename): void
{
error_clear_last();
$safeResult = \opcache_compile_file($filename);
if ($safeResult === false) {
throw OpcacheException::createFromPhpError();
}
}
/**
* This function returns state information about the in-memory cache instance. It will not return any
* information about the file cache.
*
* @param bool $include_scripts Include script specific state information
* @return array Returns an array of information, optionally containing script specific state information.
* @throws OpcacheException
*
*/
function opcache_get_status(bool $include_scripts = true): array
{
error_clear_last();
$safeResult = \opcache_get_status($include_scripts);
if ($safeResult === false) {
throw OpcacheException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/openssl.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/outcontrol.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,255 @@
<?php
namespace Safe;
use Safe\Exceptions\PcntlException;
/**
* pcntl_getpriority gets the priority of
* process_id. Because priority levels can differ between
* system types and kernel versions, please see your system's getpriority(2)
* man page for specific details.
*
* @param int|null $process_id If NULL, the process id of the current process is used.
* @param int $mode One of PRIO_PGRP, PRIO_USER,
* PRIO_PROCESS,
* PRIO_DARWIN_BG or PRIO_DARWIN_THREAD.
* @return int pcntl_getpriority returns the priority of the process. A lower numerical value causes more favorable
* scheduling.
* @throws PcntlException
*
*/
function pcntl_getpriority(?int $process_id = null, int $mode = PRIO_PROCESS): int
{
error_clear_last();
if ($mode !== PRIO_PROCESS) {
$safeResult = \pcntl_getpriority($process_id, $mode);
} elseif ($process_id !== null) {
$safeResult = \pcntl_getpriority($process_id);
} else {
$safeResult = \pcntl_getpriority();
}
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
return $safeResult;
}
/**
* pcntl_setpriority sets the priority of
* process_id.
*
* @param int $priority priority is generally a value in the range
* -20 to 20. The default priority
* is 0 while a lower numerical value causes more
* favorable scheduling. Because priority levels can differ between
* system types and kernel versions, please see your system's setpriority(2)
* man page for specific details.
* @param int|null $process_id If NULL, the process id of the current process is used.
* @param int $mode One of PRIO_PGRP, PRIO_USER,
* PRIO_PROCESS,
* PRIO_DARWIN_BG or PRIO_DARWIN_THREAD.
* @throws PcntlException
*
*/
function pcntl_setpriority(int $priority, ?int $process_id = null, int $mode = PRIO_PROCESS): void
{
error_clear_last();
if ($mode !== PRIO_PROCESS) {
$safeResult = \pcntl_setpriority($priority, $process_id, $mode);
} elseif ($process_id !== null) {
$safeResult = \pcntl_setpriority($priority, $process_id);
} else {
$safeResult = \pcntl_setpriority($priority);
}
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
}
/**
* The pcntl_signal_dispatch function calls the signal
* handlers installed by pcntl_signal for each pending
* signal.
*
* @throws PcntlException
*
*/
function pcntl_signal_dispatch(): void
{
error_clear_last();
$safeResult = \pcntl_signal_dispatch();
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
}
/**
* The pcntl_signal function installs a new
* signal handler or replaces the current signal handler for the signal indicated by signal.
*
* @param int $signal The signal number.
* @param callable|int $handler The signal handler. This may be either a callable, which
* will be invoked to handle the signal, or either of the two global
* constants SIG_IGN or SIG_DFL,
* which will ignore the signal or restore the default signal handler
* respectively.
*
* If a callable is given, it must implement the following
* signature:
*
*
* voidhandler
* intsigno
* mixedsiginfo
*
*
*
* signal
*
*
* The signal being handled.
*
*
*
*
* siginfo
*
*
* If operating systems supports siginfo_t structures, this will be an array of signal information dependent on the signal.
*
*
*
*
*
* Note that when you set a handler to an object method, that object's
* reference count is increased which makes it persist until you either
* change the handler to something else, or your script ends.
* @param bool $restart_syscalls
* @throws PcntlException
*
*/
function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): void
{
error_clear_last();
$safeResult = \pcntl_signal($signal, $handler, $restart_syscalls);
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
}
/**
* The pcntl_sigprocmask function adds, removes or sets blocked
* signals, depending on the mode parameter.
*
* @param int $mode Sets the behavior of pcntl_sigprocmask. Possible
* values:
*
* SIG_BLOCK: Add the signals to the
* currently blocked signals.
* SIG_UNBLOCK: Remove the signals from the
* currently blocked signals.
* SIG_SETMASK: Replace the currently
* blocked signals by the given list of signals.
*
* @param array $signals List of signals.
* @param array|null $old_signals The old_signals parameter is set to an array
* containing the list of the previously blocked signals.
* @throws PcntlException
*
*/
function pcntl_sigprocmask(int $mode, array $signals, ?array &$old_signals = null): void
{
error_clear_last();
$safeResult = \pcntl_sigprocmask($mode, $signals, $old_signals);
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
}
/**
* The pcntl_sigtimedwait function operates in exactly
* the same way as pcntl_sigwaitinfo except that it takes
* two additional parameters, seconds and
* nanoseconds, which enable an upper bound to be placed
* on the time for which the script is suspended.
*
* @param array $signals Array of signals to wait for.
* @param array|null $info The info is set to an array containing
* information about the signal. See
* pcntl_sigwaitinfo.
* @param int $seconds Timeout in seconds.
* @param int $nanoseconds Timeout in nanoseconds.
* @return int pcntl_sigtimedwait returns a signal number on success.
* @throws PcntlException
*
*/
function pcntl_sigtimedwait(array $signals, ?array &$info = [], int $seconds = 0, int $nanoseconds = 0): int
{
error_clear_last();
$safeResult = \pcntl_sigtimedwait($signals, $info, $seconds, $nanoseconds);
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
return $safeResult;
}
/**
* The pcntl_sigwaitinfo function suspends execution of the
* calling script until one of the signals given in signals
* are delivered. If one of the signal is already pending (e.g. blocked by
* pcntl_sigprocmask),
* pcntl_sigwaitinfo will return immediately.
*
* @param array $signals Array of signals to wait for.
* @param array|null $info The info parameter is set to an array containing
* information about the signal.
*
* The following elements are set for all signals:
*
* signo: Signal number
* errno: An error number
* code: Signal code
*
*
* The following elements may be set for the SIGCHLD signal:
*
* status: Exit value or signal
* utime: User time consumed
* stime: System time consumed
* pid: Sending process ID
* uid: Real user ID of sending process
*
*
* The following elements may be set for the SIGILL,
* SIGFPE, SIGSEGV and
* SIGBUS signals:
*
* addr: Memory location which caused fault
*
*
* The following element may be set for the SIGPOLL
* signal:
*
* band: Band event
* fd: File descriptor number
*
* @return int Returns a signal number on success.
* @throws PcntlException
*
*/
function pcntl_sigwaitinfo(array $signals, ?array &$info = []): int
{
error_clear_last();
$safeResult = \pcntl_sigwaitinfo($signals, $info);
if ($safeResult === false) {
throw PcntlException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,788 @@
<?php
namespace Safe;
use Safe\Exceptions\PcreException;
/**
* Returns the array consisting of the elements of the
* array array that match the given
* pattern.
*
* @param string $pattern The pattern to search for, as a string.
* @param array $array The input array.
* @param int $flags If set to PREG_GREP_INVERT, this function returns
* the elements of the input array that do not match
* the given pattern.
* @return array Returns an array indexed using the keys from the
* array array.
* @throws PcreException
*
*/
function preg_grep(string $pattern, array $array, int $flags = 0): array
{
error_clear_last();
$safeResult = \preg_grep($pattern, $array, $flags);
if ($safeResult === false) {
throw PcreException::createFromPhpError();
}
return $safeResult;
}
/**
* Searches subject for all matches to the regular
* expression given in pattern and puts them in
* matches in the order specified by
* flags.
*
* After the first match is found, the subsequent searches are continued
* on from end of the last match.
*
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param array|null $matches Array of all matches in multi-dimensional array ordered according to
* flags.
* @param int $flags Can be a combination of the following flags (note that it doesn't make
* sense to use PREG_PATTERN_ORDER together with
* PREG_SET_ORDER):
*
*
* PREG_PATTERN_ORDER
*
*
* Orders results so that $matches[0] is an array of full
* pattern matches, $matches[1] is an array of strings matched by
* the first parenthesized subpattern, and so on.
*
*
*
*
*
* ]]>
*
* The above example will output:
*
* example: , this is a test
* example: , this is a test
* ]]>
*
*
* So, $out[0] contains an array of strings that matched the full pattern,
* and $out[1] contains an array of strings enclosed by tags.
*
*
*
*
* If the pattern contains named subpatterns, $matches
* additionally contains entries for keys with the subpattern name.
*
*
* If the pattern contains duplicate named subpatterns, only the rightmost
* subpattern is stored in $matches[NAME].
*
*
*
* ]]>
*
* The above example will output:
*
*
* [1] => bar
* )
* ]]>
*
*
*
*
*
*
* PREG_SET_ORDER
*
*
* Orders results so that $matches[0] is an array of first set
* of matches, $matches[1] is an array of second set of matches,
* and so on.
*
*
*
* ]]>
*
* The above example will output:
*
* example: , example:
* this is a test, this is a test
* ]]>
*
*
*
*
*
*
* PREG_OFFSET_CAPTURE
*
*
* If this flag is passed, for every occurring match the appendant string
* offset (in bytes) will also be returned. Note that this changes the value of
* matches into an array of arrays where every element is an
* array consisting of the matched string at offset 0
* and its string offset into subject at offset
* 1.
*
*
*
* ]]>
*
* The above example will output:
*
* Array
* (
* [0] => Array
* (
* [0] => foobarbaz
* [1] => 0
* )
*
* )
*
* [1] => Array
* (
* [0] => Array
* (
* [0] => foo
* [1] => 0
* )
*
* )
*
* [2] => Array
* (
* [0] => Array
* (
* [0] => bar
* [1] => 3
* )
*
* )
*
* [3] => Array
* (
* [0] => Array
* (
* [0] => baz
* [1] => 6
* )
*
* )
*
* )
* ]]>
*
*
*
*
*
*
* PREG_UNMATCHED_AS_NULL
*
*
* If this flag is passed, unmatched subpatterns are reported as NULL;
* otherwise they are reported as an empty string.
*
*
*
*
*
* Orders results so that $matches[0] is an array of full
* pattern matches, $matches[1] is an array of strings matched by
* the first parenthesized subpattern, and so on.
*
*
*
*
* ]]>
*
* The above example will output:
*
* example: , this is a test
* example: , this is a test
* ]]>
*
*
* So, $out[0] contains an array of strings that matched the full pattern,
* and $out[1] contains an array of strings enclosed by tags.
*
*
*
* The above example will output:
*
* So, $out[0] contains an array of strings that matched the full pattern,
* and $out[1] contains an array of strings enclosed by tags.
*
* If the pattern contains named subpatterns, $matches
* additionally contains entries for keys with the subpattern name.
*
* If the pattern contains duplicate named subpatterns, only the rightmost
* subpattern is stored in $matches[NAME].
*
*
*
* ]]>
*
* The above example will output:
*
*
* [1] => bar
* )
* ]]>
*
*
*
* The above example will output:
*
* Orders results so that $matches[0] is an array of first set
* of matches, $matches[1] is an array of second set of matches,
* and so on.
*
*
*
* ]]>
*
* The above example will output:
*
* example: , example:
* this is a test, this is a test
* ]]>
*
*
*
* The above example will output:
*
* If this flag is passed, for every occurring match the appendant string
* offset (in bytes) will also be returned. Note that this changes the value of
* matches into an array of arrays where every element is an
* array consisting of the matched string at offset 0
* and its string offset into subject at offset
* 1.
*
*
*
* ]]>
*
* The above example will output:
*
* Array
* (
* [0] => Array
* (
* [0] => foobarbaz
* [1] => 0
* )
*
* )
*
* [1] => Array
* (
* [0] => Array
* (
* [0] => foo
* [1] => 0
* )
*
* )
*
* [2] => Array
* (
* [0] => Array
* (
* [0] => bar
* [1] => 3
* )
*
* )
*
* [3] => Array
* (
* [0] => Array
* (
* [0] => baz
* [1] => 6
* )
*
* )
*
* )
* ]]>
*
*
*
* The above example will output:
*
* If this flag is passed, unmatched subpatterns are reported as NULL;
* otherwise they are reported as an empty string.
*
* If no order flag is given, PREG_PATTERN_ORDER is
* assumed.
* @param int $offset Orders results so that $matches[0] is an array of full
* pattern matches, $matches[1] is an array of strings matched by
* the first parenthesized subpattern, and so on.
*
*
*
*
* ]]>
*
* The above example will output:
*
* example: , this is a test
* example: , this is a test
* ]]>
*
*
* So, $out[0] contains an array of strings that matched the full pattern,
* and $out[1] contains an array of strings enclosed by tags.
*
*
*
* The above example will output:
*
* So, $out[0] contains an array of strings that matched the full pattern,
* and $out[1] contains an array of strings enclosed by tags.
*
* If the pattern contains named subpatterns, $matches
* additionally contains entries for keys with the subpattern name.
*
* If the pattern contains duplicate named subpatterns, only the rightmost
* subpattern is stored in $matches[NAME].
*
*
*
* ]]>
*
* The above example will output:
*
*
* [1] => bar
* )
* ]]>
*
*
*
* The above example will output:
* @return 0|positive-int Returns the number of full pattern matches (which might be zero).
* @throws PcreException
*
*/
function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
error_clear_last();
$safeResult = \preg_match_all($pattern, $subject, $matches, $flags, $offset);
if ($safeResult === false) {
throw PcreException::createFromPhpError();
}
return $safeResult;
}
/**
* Searches subject for a match to the regular
* expression given in pattern.
*
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param null|string[] $matches If matches is provided, then it is filled with
* the results of search. $matches[0] will contain the
* text that matched the full pattern, $matches[1]
* will have the text that matched the first captured parenthesized
* subpattern, and so on.
* @param int $flags flags can be a combination of the following flags:
*
*
* PREG_OFFSET_CAPTURE
*
*
* If this flag is passed, for every occurring match the appendant string
* offset (in bytes) will also be returned. Note that this changes the value of
* matches into an array where every element is an
* array consisting of the matched string at offset 0
* and its string offset into subject at offset
* 1.
*
*
*
* ]]>
*
* The above example will output:
*
* Array
* (
* [0] => foobarbaz
* [1] => 0
* )
*
* [1] => Array
* (
* [0] => foo
* [1] => 0
* )
*
* [2] => Array
* (
* [0] => bar
* [1] => 3
* )
*
* [3] => Array
* (
* [0] => baz
* [1] => 6
* )
*
* )
* ]]>
*
*
*
*
*
*
* PREG_UNMATCHED_AS_NULL
*
*
* If this flag is passed, unmatched subpatterns are reported as NULL;
* otherwise they are reported as an empty string.
*
*
*
* ]]>
*
* The above example will output:
*
*
* string(2) "ac"
* [1]=>
* string(1) "a"
* [2]=>
* string(0) ""
* [3]=>
* string(1) "c"
* }
* array(4) {
* [0]=>
* string(2) "ac"
* [1]=>
* string(1) "a"
* [2]=>
* NULL
* [3]=>
* string(1) "c"
* }
* ]]>
*
*
*
*
*
*
*
* If this flag is passed, for every occurring match the appendant string
* offset (in bytes) will also be returned. Note that this changes the value of
* matches into an array where every element is an
* array consisting of the matched string at offset 0
* and its string offset into subject at offset
* 1.
*
*
*
* ]]>
*
* The above example will output:
*
* Array
* (
* [0] => foobarbaz
* [1] => 0
* )
*
* [1] => Array
* (
* [0] => foo
* [1] => 0
* )
*
* [2] => Array
* (
* [0] => bar
* [1] => 3
* )
*
* [3] => Array
* (
* [0] => baz
* [1] => 6
* )
*
* )
* ]]>
*
*
*
* The above example will output:
*
* If this flag is passed, unmatched subpatterns are reported as NULL;
* otherwise they are reported as an empty string.
*
*
*
* ]]>
*
* The above example will output:
*
*
* string(2) "ac"
* [1]=>
* string(1) "a"
* [2]=>
* string(0) ""
* [3]=>
* string(1) "c"
* }
* array(4) {
* [0]=>
* string(2) "ac"
* [1]=>
* string(1) "a"
* [2]=>
* NULL
* [3]=>
* string(1) "c"
* }
* ]]>
*
*
*
* The above example will output:
* @param int $offset If this flag is passed, for every occurring match the appendant string
* offset (in bytes) will also be returned. Note that this changes the value of
* matches into an array where every element is an
* array consisting of the matched string at offset 0
* and its string offset into subject at offset
* 1.
*
*
*
* ]]>
*
* The above example will output:
*
* Array
* (
* [0] => foobarbaz
* [1] => 0
* )
*
* [1] => Array
* (
* [0] => foo
* [1] => 0
* )
*
* [2] => Array
* (
* [0] => bar
* [1] => 3
* )
*
* [3] => Array
* (
* [0] => baz
* [1] => 6
* )
*
* )
* ]]>
*
*
*
* The above example will output:
* @return 0|1 preg_match returns 1 if the pattern
* matches given subject, 0 if it does not.
* @throws PcreException
*
*/
function preg_match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
error_clear_last();
$safeResult = \preg_match($pattern, $subject, $matches, $flags, $offset);
if ($safeResult === false) {
throw PcreException::createFromPhpError();
}
return $safeResult;
}
/**
* The behavior of this function is similar to
* preg_replace_callback, except that callbacks are
* executed on a per-pattern basis.
*
* @param array $pattern An associative array mapping patterns (keys) to callables (values).
* @param array|string $subject The string or an array with strings to search and replace.
* @param int $limit The maximum possible replacements for each pattern in each
* subject string. Defaults to
* -1 (no limit).
* @param int|null $count If specified, this variable will be filled with the number of
* replacements done.
* @param int $flags flags can be a combination of the
* PREG_OFFSET_CAPTURE and
* PREG_UNMATCHED_AS_NULL flags, which influence the
* format of the matches array.
* See the description in preg_match for more details.
* @return array|string preg_replace_callback_array returns an array if the
* subject parameter is an array, or a string
* otherwise. On errors the return value is NULL
*
* If matches are found, the new subject will be returned, otherwise
* subject will be returned unchanged.
* @throws PcreException
*
*/
function preg_replace_callback_array(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0)
{
error_clear_last();
$safeResult = \preg_replace_callback_array($pattern, $subject, $limit, $count, $flags);
if ($safeResult === null) {
throw PcreException::createFromPhpError();
}
return $safeResult;
}
/**
* The behavior of this function is almost identical to
* preg_replace, except for the fact that instead of
* replacement parameter, one should specify a
* callback.
*
* @param array|string $pattern The pattern to search for. It can be either a string or an array with
* strings.
* @param callable(array):string $callback A callback that will be called and passed an array of matched elements
* in the subject string. The callback should
* return the replacement string. This is the callback signature:
*
*
* stringhandler
* arraymatches
*
*
* You'll often need the callback function
* for a preg_replace_callback in just one place.
* In this case you can use an
* anonymous function to
* declare the callback within the call to
* preg_replace_callback. By doing it this way
* you have all information for the call in one place and do not
* clutter the function namespace with a callback function's name
* not used anywhere else.
*
*
* preg_replace_callback and
* anonymous function
*
*
* ]]>
*
*
* @param array|string $subject The string or an array with strings to search and replace.
* @param int $limit The maximum possible replacements for each pattern in each
* subject string. Defaults to
* -1 (no limit).
* @param int|null $count If specified, this variable will be filled with the number of
* replacements done.
* @param int $flags flags can be a combination of the
* PREG_OFFSET_CAPTURE and
* PREG_UNMATCHED_AS_NULL flags, which influence the
* format of the matches array.
* See the description in preg_match for more details.
* @return array|string preg_replace_callback returns an array if the
* subject parameter is an array, or a string
* otherwise. On errors the return value is NULL
*
* If matches are found, the new subject will be returned, otherwise
* subject will be returned unchanged.
* @throws PcreException
*
*/
function preg_replace_callback($pattern, callable $callback, $subject, int $limit = -1, ?int &$count = null, int $flags = 0)
{
error_clear_last();
$safeResult = \preg_replace_callback($pattern, $callback, $subject, $limit, $count, $flags);
if ($safeResult === null) {
throw PcreException::createFromPhpError();
}
return $safeResult;
}
/**
* Split the given string by a regular expression.
*
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param int|null $limit If specified, then only substrings up to limit
* are returned with the rest of the string being placed in the last
* substring. A limit of -1 or 0 means "no limit".
* @param int $flags flags can be any combination of the following
* flags (combined with the | bitwise operator):
*
*
* PREG_SPLIT_NO_EMPTY
*
*
* If this flag is set, only non-empty pieces will be returned by
* preg_split.
*
*
*
*
* PREG_SPLIT_DELIM_CAPTURE
*
*
* If this flag is set, parenthesized expression in the delimiter pattern
* will be captured and returned as well.
*
*
*
*
* PREG_SPLIT_OFFSET_CAPTURE
*
*
* If this flag is set, for every occurring match the appendant string
* offset will also be returned. Note that this changes the return
* value in an array where every element is an array consisting of the
* matched string at offset 0 and its string offset
* into subject at offset 1.
*
*
*
*
*
* If this flag is set, for every occurring match the appendant string
* offset will also be returned. Note that this changes the return
* value in an array where every element is an array consisting of the
* matched string at offset 0 and its string offset
* into subject at offset 1.
* @return list Returns an array containing substrings of subject
* split along boundaries matched by pattern.
* @throws PcreException
*
*/
function preg_split(string $pattern, string $subject, ?int $limit = -1, int $flags = 0): array
{
error_clear_last();
$safeResult = \preg_split($pattern, $subject, $limit, $flags);
if ($safeResult === false) {
throw PcreException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/pgsql.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/posix.php vendored Normal file → Executable file
View File

File diff suppressed because it is too large Load Diff

0
vendor/thecodingmachine/safe/generated/8.4/pspell.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/readline.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/rector-migrate.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,629 @@
<?php
namespace Safe;
use Safe\Exceptions\RnpException;
/**
* Private keys used for decryption should be loaded into the FFI object before calling this function.
* If password encryption was used, then password provider should be set by calling
* rnp_ffi_set_pass_provider.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $input Encrypted message.
* @return string Decrypted message on success.
* @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 Input string containing OpenPGP data, either in binary or ASCII-armored format.
* @param int $flags See RNP_JSON_DUMP_* predefined constants.
* @return string JSON string with dump.
* @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 Input string containing OpenPGP data, either in binary or ASCII-armored format.
* @param int $flags See RNP_DUMP_* predefined constants.
* @return string Text describing packet sequence.
* @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 the format of the public keyring, RNP_KEYSTORE_GPG or other
* RNP_KEYSTORE_* constant.
* @param string $sec_format the format of the secret keyring, RNP_KEYSTORE_GPG or other
* RNP_KEYSTORE_* constant
* @return \RnpFFI Returns RnpFFI object on success.
* @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;
}
/**
* Sets password provider function. This function can ask for the password on a standard input
* (if PHP script is executed in a command line environment), display GUI dialog or provide
* password in any other possible ways. Requested passwords are used to encrypt or decrypt
* secret keys or perform symmetric encryption/decryption operations.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param callable $password_callback The function that is to be called for every password request. It has the following signature:
*
* boolpassword_callback
* stringkey_fp
* stringpgp_context
* stringpassword
*
*
* $key_fp - The key fingerprint, if any. Can be empty.
* $pgp_context - String describing why the key is being requested.
* $password - Password string reference where provided password should be stored to.
*
* Callback function should return TRUE if password was successfully set or FALSE on failure.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $input OpenPGP packets containing key(s) to be loaded. Can be either binary or ASCII armored.
* @param int $flags See RNP_LOAD_SAVE_* predefined constants.
* @return string JSON string with information about new and updated keys on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $input OpenPGP packets containing signatures to be imported. Can be either binary or ASCII armored.
* @param int $flags Currently must be 0.
* @return string JSON string with information about updated keys on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $key_fp Primary key fingerprint.
* @param string $subkey_fp Subkey to export. Can be an empty string
* to pick the first suitable subkey.
* @param string $uid User ID to export. Can be an empty string
* if exported key has only one uid.
* @param int $flags Only RNP_KEY_EXPORT_BASE64 is currently supported. Enabling
* it would export base64-encoded key data instead of binary.
* @return string OpenPGP packets of exported key on success.
* @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;
}
/**
* Note: to revoke a key you'll need to import this signature into the keystore or use
* rnp_key_revoke function.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $key_fp Key fingerprint of the primary key to be revoked.
* @param int $flags RNP_KEY_EXPORT_ARMORED or 0.
* @param array $options An associative array with options.
* @return string Exported revocation signature on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $key_fp Key fingerprint.
* @param int $flags See RNP_KEY_EXPORT_* predefined constants
* (except RNP_KEY_EXPORT_BASE64).
* @return string OpenPGP packets of exported key (binary or ASCII-armored) on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $key_fp Key fingerprint.
* @return array An associative array with information about the key.
* @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;
}
/**
* Note: you need to call rnp_save_keys to write updated keyring(s) out.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $key_fp Key fingerprint.
* @param int $flags See RNP_KEY_REMOVE_* constants. Flag RNP_KEY_REMOVE_SUBKEYS will work only for
* the primary key and will remove all of its subkeys as well.
* @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();
}
}
/**
* Note: you need to call rnp_save_keys to write updated keyring(s) out.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $key_fp Key fingerprint.
* @param int $flags Currently must be 0.
* @param array $options An associative array with 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 The FFI object returned by rnp_ffi_create.
* @param string $identifier_type Key identifier type ("userid", "keyid", "grip", "fingerprint").
* @return array An associative array where key is an identifier string and value is a PGP key fingerprint.
* @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;
}
/**
* Note that for G10, the input must be a directory (which must already exist).
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $format The key format of the data (GPG, KBX, G10).
* @param string $input_path file or directory containing the keys.
* @param int $flags See RNP_LOAD_SAVE_* flags description.
* @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();
}
}
/**
* Note that for G10, the input must be a directory (which must already exist).
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $format The key format of the data (GPG, KBX, G10).
* @param string $input OpenPGP packets containing key(s) to be loaded. Can be either binary or ASCII armored.
* @param int $flags See RNP_LOAD_SAVE_* flags description.
* @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();
}
}
/**
* Note: only valid userids are checked while searching by userid.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $identifier_type Identifier type string: "userid", "keyid", "fingerprint", "grip".
* @param string $identifier PGP User ID (name and email) for "userid" type, hexadecimal string
* that represents key id, fingerprint or key grip correspondingly.
* @return string Returns hexadecimal fingerprint of the key found on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $message Message to be encrypted.
* @param array $recipient_keys_fp Array with fingerprints of recipient's keys. At least one key must be present.
* @param array $options An associative array with options.
* @return string Encrypted data on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $userid PGP User ID - text that is intended to represent
* the name and email address of the key holder.
* @param string $key_alg Primary key algorithm (i.e. 'RSA', 'DSA', etc).
* @param string $sub_alg Subkey algorithm. If not set, subkey will not be generated.
* @param array $options An associative array with options.
* @return string Fingerprint of the generated primary key. This fingerprint can be used
* later to reference the key in sign and encrypt operations. The key data is stored in FFI
* memory context and can be saved using
* rnp_save_keys or rnp_save_keys_to_path.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $data Data to be signed.
* @param array $keys_fp Array with key fingerprints. At least one key must be provided.
* Keys should be present in ffi.
* @param array $options An associative array with options.
* @return string Cleartext signed message containing source data with
* additional headers and ASCII-armored signature on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $data Data to be signed.
* @param array $keys_fp Array with key fingerprints. At least one key must be provided.
* Keys should be present in ffi.
* @param array $options An associative array with options.
* @return string Detached signature(s) data on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $data Data to be signed.
* @param array $keys_fp Array with key fingerprints. At least one key must be provided.
* Keys should be present in ffi.
* @param array $options An associative array with options.
* @return string Data with embedded signature(s) on success.
* @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 The FFI object returned by rnp_ffi_create.
* @param string $data Source data.
* @param string $signature Detached signature data.
* @return array An associative array with information about verification results.
*
* "signatures" sub-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 The FFI object returned by rnp_ffi_create.
* @param string $data Signed data.
* @return array An associative array with information about verification results.
*
* "signatures" sub-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;
}
/**
* Saves keys present in the FFI object (loaded or generated) to the specified file or directory.
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $format The key format of the data (GPG, KBX, G10).
* @param string $output_path File or directory path where keys should be saved to.
* @param int $flags See RNP_LOAD_SAVE_* flags description.
* @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();
}
}
/**
* Note that for G10, the output must be a directory (which must already exist).
*
* @param \RnpFFI $ffi The FFI object returned by rnp_ffi_create.
* @param string $format The key format of the data (GPG, KBX, G10).
* @param string $output key packets will be saved to the string referenced by output.
* @param int $flags See RNP_LOAD_SAVE_* flags description.
* @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();
}
}
/**
* Get the JSON formatted string containing array of supported rnp feature values (algorithms, curves, etc) by type.
*
* @param string $type See RNP_FEATURE_* constants for supported values.
* @return string String containing JSON formatted array of supported algorithms, curves, etc.
* @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,21 @@
<?php
namespace Safe;
use Safe\Exceptions\RpminfoException;
/**
* Add an additional retrieved tag in subsequent queries.
*
* @param int $tag One of RPMTAG_* constant, see the rpminfo constants page.
* @throws RpminfoException
*
*/
function rpmaddtag(int $tag): void
{
error_clear_last();
$safeResult = \rpmaddtag($tag);
if ($safeResult === false) {
throw RpminfoException::createFromPhpError();
}
}

View File

@@ -0,0 +1,190 @@
<?php
namespace Safe;
use Safe\Exceptions\RrdException;
/**
* Creates the rdd database file.
*
* @param string $filename Filename for newly created rrd file.
* @param array $options Options for rrd create - list of strings. See man page of rrd create
* for whole list of options.
* @throws RrdException
*
*/
function rrd_create(string $filename, array $options): void
{
error_clear_last();
$safeResult = \rrd_create($filename, $options);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
}
/**
* Returns the first data sample from the specified RRA of the RRD file.
*
* @param string $file RRD database file name.
* @param int $raaindex The index number of the RRA that is to be examined. Default value is 0.
* @return int Integer number of unix timestamp.
* @throws RrdException
*
*/
function rrd_first(string $file, int $raaindex = 0): int
{
error_clear_last();
$safeResult = \rrd_first($file, $raaindex);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
return $safeResult;
}
/**
* Creates image for a particular data from RRD file.
*
* @param string $filename The filename to output the graph to. This will generally end in either
* .png, .svg or
* .eps, depending on the format you want to output.
* @param array $options Options for generating image. See man page of rrd graph for all
* possible options. All options (data definitions, variable definitions, etc.)
* are allowed.
* @return array Array with information about generated image is returned.
* @throws RrdException
*
*/
function rrd_graph(string $filename, array $options): array
{
error_clear_last();
$safeResult = \rrd_graph($filename, $options);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns information about particular RRD database file.
*
* @param string $filename RRD database file name.
* @return array Array with information about requested RRD file.
* @throws RrdException
*
*/
function rrd_info(string $filename): array
{
error_clear_last();
$safeResult = \rrd_info($filename);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets array of the UNIX timestamp and the values stored for each date in the
* most recent update of the RRD database file.
*
* @param string $filename RRD database file name.
* @return array Array of information about last update.
* @throws RrdException
*
*/
function rrd_lastupdate(string $filename): array
{
error_clear_last();
$safeResult = \rrd_lastupdate($filename);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
return $safeResult;
}
/**
* Restores the RRD file from the XML dump.
*
* @param string $xml_file XML filename with the dump of the original RRD database file.
* @param string $rrd_file Restored RRD database file name.
* @param array $options Array of options for restoring. See man page for rrd restore.
* @throws RrdException
*
*/
function rrd_restore(string $xml_file, string $rrd_file, ?array $options = null): void
{
error_clear_last();
if ($options !== null) {
$safeResult = \rrd_restore($xml_file, $rrd_file, $options);
} else {
$safeResult = \rrd_restore($xml_file, $rrd_file);
}
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
}
/**
* Change some options in the RRD dabase header file. E.g. renames the source for
* the data etc.
*
* @param string $filename RRD database file name.
* @param array $options Options with RRD database file properties which will be changed. See
* rrd tune man page for details.
* @throws RrdException
*
*/
function rrd_tune(string $filename, array $options): void
{
error_clear_last();
$safeResult = \rrd_tune($filename, $options);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
}
/**
* Updates the RRD database file. The input data is time interpolated according to the
* properties of the RRD database file.
*
* @param string $filename RRD database file name. This database will be updated.
* @param array $options Options for updating the RRD database. This is list of strings. See man page of rrd update
* for whole list of options.
* @throws RrdException
*
*/
function rrd_update(string $filename, array $options): void
{
error_clear_last();
$safeResult = \rrd_update($filename, $options);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
}
/**
* Exports the information about RRD database file. This data can be converted
* to XML file via user space PHP script and then restored back as RRD database
* file.
*
* @param array $options Array of options for the export, see rrd xport man page.
* @return array Array with information about RRD database file.
* @throws RrdException
*
*/
function rrd_xport(array $options): array
{
error_clear_last();
$safeResult = \rrd_xport($options);
if ($safeResult === false) {
throw RrdException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,545 @@
<?php
namespace Safe;
use Safe\Exceptions\SemException;
/**
* msg_get_queue returns an id that can be used to
* access the System V message queue with the given
* key. The first call creates the message queue with
* the optional permissions.
* A second call to msg_get_queue for the same
* key will return a different message queue
* identifier, but both identifiers access the same underlying message
* queue.
*
* @param int $key Message queue numeric ID
* @param int $permissions Queue permissions. Default to 0666. If the message queue already
* exists, the permissions will be ignored.
* @return \SysvMessageQueue Returns SysvMessageQueue instance that can be used to access the System V message queue.
* @throws SemException
*
*/
function msg_get_queue(int $key, int $permissions = 0666): \SysvMessageQueue
{
error_clear_last();
$safeResult = \msg_get_queue($key, $permissions);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
return $safeResult;
}
/**
* Checks whether the message queue key exists.
*
* @param int $key Queue key.
* @throws SemException
*
*/
function msg_queue_exists(int $key): void
{
error_clear_last();
$safeResult = \msg_queue_exists($key);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* msg_receive will receive the first message from the
* specified queue of the type specified by
* desired_message_type.
*
* @param \SysvMessageQueue $queue The message queue.
* @param int $desired_message_type If desired_message_type is 0, the message from the front
* of the queue is returned. If desired_message_type is
* greater than 0, then the first message of that type is returned.
* If desired_message_type is less than 0, the first
* message on the queue with a type less than or equal to the
* absolute value of desired_message_type will be read.
* If no messages match the criteria, your script will wait until a suitable
* message arrives on the queue. You can prevent the script from blocking
* by specifying MSG_IPC_NOWAIT in the
* flags parameter.
* @param int|null $received_message_type The type of the message that was received will be stored in this
* parameter.
* @param int $max_message_size The maximum size of message to be accepted is specified by the
* max_message_size; if the message in the queue is larger
* than this size the function will fail (unless you set
* flags as described below).
* @param mixed $message The received message will be stored in message,
* unless there were errors receiving the message.
* @param bool $unserialize If set to
* TRUE, the message is treated as though it was serialized using the
* same mechanism as the session module. The message will be unserialized
* and then returned to your script. This allows you to easily receive
* arrays or complex object structures from other PHP scripts, or if you
* are using the WDDX serializer, from any WDDX compatible source.
*
* If unserialize is FALSE, the message will be
* returned as a binary-safe string.
* @param int $flags The optional flags allows you to pass flags to the
* low-level msgrcv system call. It defaults to 0, but you may specify one
* or more of the following values (by adding or ORing them together).
*
* Flag values for msg_receive
*
*
*
* MSG_IPC_NOWAIT
* If there are no messages of the
* desired_message_type, return immediately and do not
* wait. The function will fail and return an integer value
* corresponding to MSG_ENOMSG.
*
*
*
* MSG_EXCEPT
* Using this flag in combination with a
* desired_message_type greater than 0 will cause the
* function to receive the first message that is not equal to
* desired_message_type.
*
*
* MSG_NOERROR
*
* If the message is longer than max_message_size,
* setting this flag will truncate the message to
* max_message_size and will not signal an error.
*
*
*
*
*
* @param int|null $error_code If the function fails, the optional error_code
* will be set to the value of the system errno variable.
* @throws SemException
*
*/
function msg_receive(\SysvMessageQueue $queue, int $desired_message_type, ?int &$received_message_type, int $max_message_size, &$message, bool $unserialize = true, int $flags = 0, ?int &$error_code = null): void
{
error_clear_last();
$safeResult = \msg_receive($queue, $desired_message_type, $received_message_type, $max_message_size, $message, $unserialize, $flags, $error_code);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* msg_remove_queue destroys the message queue specified
* by the queue. Only use this function when all
* processes have finished working with the message queue and you need to
* release the system resources held by it.
*
* @param \SysvMessageQueue $queue The message queue.
* @throws SemException
*
*/
function msg_remove_queue(\SysvMessageQueue $queue): void
{
error_clear_last();
$safeResult = \msg_remove_queue($queue);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* msg_send sends a message of type
* message_type (which MUST be greater than 0) to
* the message queue specified by queue.
*
* @param \SysvMessageQueue $queue The message queue.
* @param int $message_type The type of the message (MUST be greater than 0)
* @param mixed $message The body of the message.
*
* If serialize set to FALSE is supplied,
* MUST be of type: string, int, float
* or bool. In other case a warning will be issued.
* @param bool $serialize The optional serialize controls how the
* message is sent. serialize
* defaults to TRUE which means that the message is
* serialized using the same mechanism as the session module before being
* sent to the queue. This allows complex arrays and objects to be sent to
* other PHP scripts, or if you are using the WDDX serializer, to any WDDX
* compatible client.
* @param bool $blocking If the message is too large to fit in the queue, your script will wait
* until another process reads messages from the queue and frees enough
* space for your message to be sent.
* This is called blocking; you can prevent blocking by setting the
* optional blocking parameter to FALSE, in which
* case msg_send will immediately return FALSE if the
* message is too big for the queue, and set the optional
* error_code to MSG_EAGAIN,
* indicating that you should try to send your message again a little
* later on.
* @param int|null $error_code If the function fails, the optional errorcode will be set to the value of the system errno variable.
* @throws SemException
*
*/
function msg_send(\SysvMessageQueue $queue, int $message_type, $message, bool $serialize = true, bool $blocking = true, ?int &$error_code = null): void
{
error_clear_last();
$safeResult = \msg_send($queue, $message_type, $message, $serialize, $blocking, $error_code);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* msg_set_queue allows you to change the values of the
* msg_perm.uid, msg_perm.gid, msg_perm.mode and msg_qbytes fields of the
* underlying message queue data structure.
*
* Changing the data structure will require that PHP be running as the same
* user that created the queue, owns the queue (as determined by the
* existing msg_perm.xxx fields), or be running with root privileges.
* root privileges are required to raise the msg_qbytes values above the
* system defined limit.
*
* @param \SysvMessageQueue $queue The message queue.
* @param array $data You specify the values you require by setting the value of the keys
* that you require in the data array.
* @throws SemException
*
*/
function msg_set_queue(\SysvMessageQueue $queue, array $data): void
{
error_clear_last();
$safeResult = \msg_set_queue($queue, $data);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* msg_stat_queue returns the message queue meta data
* for the message queue specified by the queue.
* This is useful, for example, to determine which process sent the message
* that was just received.
*
* @param \SysvMessageQueue $queue The message queue.
* @return array On success, the return value is an array whose keys and values have the following
* meanings:
*
* Array structure for msg_stat_queue
*
*
*
* msg_perm.uid
*
* The uid of the owner of the queue.
*
*
*
* msg_perm.gid
*
* The gid of the owner of the queue.
*
*
*
* msg_perm.mode
*
* The file access mode of the queue.
*
*
*
* msg_stime
*
* The time that the last message was sent to the queue.
*
*
*
* msg_rtime
*
* The time that the last message was received from the queue.
*
*
*
* msg_ctime
*
* The time that the queue was last changed.
*
*
*
* msg_qnum
*
* The number of messages waiting to be read from the queue.
*
*
*
* msg_qbytes
*
* The maximum number of bytes allowed in one message queue. On
* Linux, this value may be read and modified via
* /proc/sys/kernel/msgmnb.
*
*
*
* msg_lspid
*
* The pid of the process that sent the last message to the queue.
*
*
*
* msg_lrpid
*
* The pid of the process that received the last message from the queue.
*
*
*
*
*
*
* Returns FALSE on failure.
* @throws SemException
*
*/
function msg_stat_queue(\SysvMessageQueue $queue): array
{
error_clear_last();
$safeResult = \msg_stat_queue($queue);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
return $safeResult;
}
/**
* sem_acquire by default blocks (if necessary) until the
* semaphore can be acquired. A process attempting to acquire a semaphore which
* it has already acquired will block forever if acquiring the semaphore would
* cause its maximum number of semaphore to be exceeded.
*
* After processing a request, any semaphores acquired by the process but not
* explicitly released will be released automatically and a warning will be
* generated.
*
* @param \SysvSemaphore $semaphore semaphore is a semaphore
* obtained from sem_get.
* @param bool $non_blocking Specifies if the process shouldn't wait for the semaphore to be acquired.
* If set to TRUE, the call will return
* FALSE immediately if a semaphore cannot be immediately
* acquired.
* @throws SemException
*
*/
function sem_acquire(\SysvSemaphore $semaphore, bool $non_blocking = false): void
{
error_clear_last();
$safeResult = \sem_acquire($semaphore, $non_blocking);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* sem_get returns an id that can be used to
* access the System V semaphore with the given key.
*
* A second call to sem_get for the same key
* will return a different semaphore identifier, but both
* identifiers access the same underlying semaphore.
*
* If key is 0, a new private semaphore
* is created for each call to sem_get.
*
* @param int $key
* @param int $max_acquire The number of processes that can acquire the semaphore simultaneously
* is set to max_acquire.
* @param int $permissions The semaphore permissions. Actually this value is
* set only if the process finds it is the only process currently
* attached to the semaphore.
* @param bool $auto_release Specifies if the semaphore should be automatically released on request
* shutdown.
* @return \SysvSemaphore Returns a positive semaphore identifier on success.
* @throws SemException
*
*/
function sem_get(int $key, int $max_acquire = 1, int $permissions = 0666, bool $auto_release = true): \SysvSemaphore
{
error_clear_last();
$safeResult = \sem_get($key, $max_acquire, $permissions, $auto_release);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
return $safeResult;
}
/**
* sem_release releases the semaphore if it
* is currently acquired by the calling process, otherwise
* a warning is generated.
*
* After releasing the semaphore, sem_acquire
* may be called to re-acquire it.
*
* @param \SysvSemaphore $semaphore A Semaphore as returned by
* sem_get.
* @throws SemException
*
*/
function sem_release(\SysvSemaphore $semaphore): void
{
error_clear_last();
$safeResult = \sem_release($semaphore);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* sem_remove removes the given semaphore.
*
* After removing the semaphore, it is no longer accessible.
*
* @param \SysvSemaphore $semaphore A semaphore as returned
* by sem_get.
* @throws SemException
*
*/
function sem_remove(\SysvSemaphore $semaphore): void
{
error_clear_last();
$safeResult = \sem_remove($semaphore);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* shm_attach returns an id that can be used to access
* the System V shared memory with the given key, the
* first call creates the shared memory segment with
* size and the optional perm-bits
* permissions.
*
* A second call to shm_attach for the same
* key will return a different SysvSharedMemory
* instance, but both instances access the same underlying
* shared memory. size and
* permissions will be ignored.
*
* @param int $key A numeric shared memory segment ID
* @param int|null $size The memory size. If not provided, default to the
* sysvshm.init_mem in the php.ini, otherwise 10000
* bytes.
* @param int $permissions The optional permission bits. Default to 0666.
* @return \SysvSharedMemory Returns a SysvSharedMemory instance on success.
* @throws SemException
*
*/
function shm_attach(int $key, ?int $size = null, int $permissions = 0666): \SysvSharedMemory
{
error_clear_last();
if ($permissions !== 0666) {
$safeResult = \shm_attach($key, $size, $permissions);
} elseif ($size !== null) {
$safeResult = \shm_attach($key, $size);
} else {
$safeResult = \shm_attach($key);
}
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
return $safeResult;
}
/**
* shm_detach disconnects from the shared memory given
* by the shm created by
* shm_attach. Remember, that shared memory still exist
* in the Unix system and the data is still present.
*
* @param \SysvSharedMemory $shm A shared memory segment obtained from shm_attach.
* @throws SemException
*
*/
function shm_detach(\SysvSharedMemory $shm): void
{
error_clear_last();
$safeResult = \shm_detach($shm);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* shm_put_var inserts or updates the
* value with the given
* key.
*
* Warnings (E_WARNING level) will be issued if
* shm is not a valid SysV shared memory
* index or if there was not enough shared memory remaining to complete your
* request.
*
* @param \SysvSharedMemory $shm A shared memory segment obtained from shm_attach.
* @param int $key The variable key.
* @param mixed $value The variable. All variable types
* that serialize supports may be used: generally
* this means all types except for resources and some internal objects
* that cannot be serialized.
* @throws SemException
*
*/
function shm_put_var(\SysvSharedMemory $shm, int $key, $value): void
{
error_clear_last();
$safeResult = \shm_put_var($shm, $key, $value);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* Removes a variable with a given key
* and frees the occupied memory.
*
* @param \SysvSharedMemory $shm A shared memory segment obtained from shm_attach.
* @param int $key The variable key.
* @throws SemException
*
*/
function shm_remove_var(\SysvSharedMemory $shm, int $key): void
{
error_clear_last();
$safeResult = \shm_remove_var($shm, $key);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}
/**
* shm_remove removes the shared memory
* shm. All data will be destroyed.
*
* @param \SysvSharedMemory $shm A shared memory segment obtained from shm_attach.
* @throws SemException
*
*/
function shm_remove(\SysvSharedMemory $shm): void
{
error_clear_last();
$safeResult = \shm_remove($shm);
if ($safeResult === false) {
throw SemException::createFromPhpError();
}
}

View File

@@ -0,0 +1,542 @@
<?php
namespace Safe;
use Safe\Exceptions\SessionException;
/**
* session_abort finishes session without saving
* data. Thus the original values in session data are kept.
*
* @throws SessionException
*
*/
function session_abort(): void
{
error_clear_last();
$safeResult = \session_abort();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* session_cache_expire returns the current setting of
* session.cache_expire.
*
* The cache expire is reset to the default value of 180 stored in
* session.cache_expire
* at request startup time. Thus,
* you need to call session_cache_expire for every
* request (and before session_start is called).
*
* @param int|null $value If value is given and not NULL, the current cache
* expire is replaced with value.
*
*
*
* Setting value is of value only, if
* session.cache_limiter is set to a value
* different from nocache.
*
*
* @return int Returns the current setting of session.cache_expire.
* The value returned should be read in minutes, defaults to 180.
* @throws SessionException
*
*/
function session_cache_expire(?int $value = null): int
{
error_clear_last();
if ($value !== null) {
$safeResult = \session_cache_expire($value);
} else {
$safeResult = \session_cache_expire();
}
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_cache_limiter returns the name of the
* current cache limiter.
*
* The cache limiter defines which cache control HTTP headers are sent to
* the client. These headers determine the rules by which the page content
* may be cached by the client and intermediate proxies. Setting the cache
* limiter to nocache disallows any client/proxy caching.
* A value of public permits caching by proxies and the
* client, whereas private disallows caching by proxies
* and permits the client to cache the contents.
*
* In private mode, the Expire header sent to the client
* may cause confusion for some browsers, including Mozilla.
* You can avoid this problem by using private_no_expire mode. The
* Expire header is never sent to the client in this mode.
*
* Setting the cache limiter to '' will turn off automatic sending
* of cache headers entirely.
*
* The cache limiter is reset to the default value stored in
* session.cache_limiter
* at request startup time. Thus, you need to call
* session_cache_limiter for every
* request (and before session_start is called).
*
* @param null|string $value If value is specified and not NULL, the name of the
* current cache limiter is changed to the new value.
* @return string Returns the name of the current cache limiter.
* @throws SessionException
*
*/
function session_cache_limiter(?string $value = null): string
{
error_clear_last();
if ($value !== null) {
$safeResult = \session_cache_limiter($value);
} else {
$safeResult = \session_cache_limiter();
}
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_create_id is used to create new
* session id for the current session. It returns collision free
* session id.
*
* If session is not active, collision check is omitted.
*
* Session ID is created according to php.ini settings.
*
* It is important to use the same user ID of your web server for GC
* task script. Otherwise, you may have permission problems especially
* with files save handler.
*
* @param string $prefix If prefix is specified, new session id
* is prefixed by prefix. Not all
* characters are allowed within the session id. Characters in
* the range [a-zA-Z0-9,-] are allowed. Maximum length is 256 characters.
* @return string session_create_id returns new collision free
* session id for the current session. If it is used without active
* session, it omits collision check.
* On failure, FALSE is returned.
* @throws SessionException
*
*/
function session_create_id(string $prefix = ""): string
{
error_clear_last();
$safeResult = \session_create_id($prefix);
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_decode decodes the serialized session data provided in
* $data, and populates the $_SESSION superglobal
* with the result.
*
* By default, the unserialization method used is internal to PHP, and is not the same as unserialize.
* The serialization method can be set using session.serialize_handler.
*
* @param string $data The encoded data to be stored.
* @throws SessionException
*
*/
function session_decode(string $data): void
{
error_clear_last();
$safeResult = \session_decode($data);
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* In order to kill the session altogether, the
* session ID must also be unset. If a cookie is used to propagate the
* session ID (default behavior), then the session cookie must be deleted.
* setcookie may be used for that.
*
* When session.use_strict_mode
* is enabled. You do not have to remove obsolete session ID cookie because
* session module will not accept session ID cookie when there is no
* data associated to the session ID and set new session ID cookie.
* Enabling session.use_strict_mode
* is recommended for all sites.
*
* @throws SessionException
*
*/
function session_destroy(): void
{
error_clear_last();
$safeResult = \session_destroy();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* session_encode returns a serialized string of the
* contents of the current session data stored in the $_SESSION superglobal.
*
* By default, the serialization method used is internal to PHP, and is not the same as serialize.
* The serialization method can be set using session.serialize_handler.
*
* @return string Returns the contents of the current session encoded.
* @throws SessionException
*
*/
function session_encode(): string
{
error_clear_last();
$safeResult = \session_encode();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_gc is used to perform session data
* GC (garbage collection). PHP does probability based session GC by
* default.
*
* Probability based GC works somewhat but it has few problems. 1) Low
* traffic sites' session data may not be deleted within the preferred
* duration. 2) High traffic sites' GC may be too frequent GC. 3) GC is
* performed on the user's request and the user will experience a GC
* delay.
*
* Therefore, it is recommended to execute GC periodically for
* production systems using, e.g., "cron" for UNIX-like systems.
* Make sure to disable probability based GC by setting
* session.gc_probability
* to 0.
*
* @return int session_gc returns number of deleted session
* data for success.
*
* Old save handlers do not return number of deleted session data, but
* only success/failure flag. If this is the case, number of deleted
* session data became 1 regardless of actually deleted data.
* @throws SessionException
*
*/
function session_gc(): int
{
error_clear_last();
$safeResult = \session_gc();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_id is used to get or set the session id for
* the current session.
*
* The constant SID can also be used to
* retrieve the current name and session id as a string suitable for
* adding to URLs. See also Session
* handling.
*
* @param null|string $id If id is specified and not NULL, it will replace the current
* session id. session_id needs to be called before
* session_start for that purpose. Depending on the
* session handler, not all characters are allowed within the session id.
* For example, the file session handler only allows characters in the
* range [a-zA-Z0-9,-]!
* @return string session_id returns the session id for the current
* session or the empty string ("") if there is no current
* session (no current session id exists).
* On failure, FALSE is returned.
* @throws SessionException
*
*/
function session_id(?string $id = null): string
{
error_clear_last();
if ($id !== null) {
$safeResult = \session_id($id);
} else {
$safeResult = \session_id();
}
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_module_name gets the name of the current
* session module, which is also known as
* session.save_handler.
*
* @param null|string $module If module is specified and not NULL, that module will be
* used instead.
* Passing "user" to this parameter is forbidden. Instead
* session_set_save_handler has to be called to set a user
* defined session handler.
* @return string Returns the name of the current session module.
* @throws SessionException
*
*/
function session_module_name(?string $module = null): string
{
error_clear_last();
if ($module !== null) {
$safeResult = \session_module_name($module);
} else {
$safeResult = \session_module_name();
}
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_name returns the name of the current
* session. If name is given,
* session_name will update the session name and return
* the old session name.
*
* If a new session name is
* supplied, session_name modifies the HTTP cookie
* (and outputs the content when session.use_trans_sid is
* enabled). Once the HTTP cookie has been
* sent, calling session_name raises an E_WARNING.
* session_name must be called
* before session_start for the session to work
* properly.
*
* The session name is reset to the default value stored in
* session.name at request startup time. Thus, you need to
* call session_name for every request (and before
* session_start is called).
*
* @param null|string $name The session name references the name of the session, which is
* used in cookies and URLs (e.g. PHPSESSID). It
* should contain only alphanumeric characters; it should be short and
* descriptive (i.e. for users with enabled cookie warnings).
* If name is specified and not NULL, the name of the current
* session is changed to its value.
*
*
*
* The session name can't consist of digits only, at least one letter
* must be present. Otherwise a new session id is generated every time.
*
*
*
* The session name can't consist of digits only, at least one letter
* must be present. Otherwise a new session id is generated every time.
* @return non-falsy-string Returns the name of the current session. If name is given
* and function updates the session name, name of the old session
* is returned.
* @throws SessionException
*
*/
function session_name(?string $name = null): string
{
error_clear_last();
if ($name !== null) {
$safeResult = \session_name($name);
} else {
$safeResult = \session_name();
}
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_regenerate_id will replace the current
* session id with a new one, and keep the current session information.
*
* When session.use_trans_sid
* is enabled, output must be started after session_regenerate_id
* call. Otherwise, old session ID is used.
*
* @param bool $delete_old_session Whether to delete the old associated session file or not.
* You should not delete old session if you need to avoid
* races caused by deletion or detect/avoid session hijack
* attacks.
* @throws SessionException
*
*/
function session_regenerate_id(bool $delete_old_session = false): void
{
error_clear_last();
$safeResult = \session_regenerate_id($delete_old_session);
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* session_reset reinitializes a session with
* original values stored in session storage. This function requires an active session and
* discards changes in $_SESSION.
*
* @throws SessionException
*
*/
function session_reset(): void
{
error_clear_last();
$safeResult = \session_reset();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* session_save_path returns the path of the current
* directory used to save session data.
*
* @param null|string $path Session data path. If specified and not NULL, the path to which data is saved will
* be changed. session_save_path needs to be called
* before session_start for that purpose.
*
*
*
* On some operating systems, you may want to specify a path on a
* filesystem that handles lots of small files efficiently.
*
*
*
* On some operating systems, you may want to specify a path on a
* filesystem that handles lots of small files efficiently.
* @return string Returns the path of the current directory used for data storage.
* @throws SessionException
*
*/
function session_save_path(?string $path = null): string
{
error_clear_last();
if ($path !== null) {
$safeResult = \session_save_path($path);
} else {
$safeResult = \session_save_path();
}
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
return $safeResult;
}
/**
* session_start creates a session or resumes the
* current one based on a session identifier passed via a GET or POST
* request, or passed via a cookie.
*
* When session_start is called or when a session auto starts,
* PHP will call the open and read session save handlers. These will either be a built-in
* save handler provided by default or by PHP extensions (such as SQLite or Memcached); or can be
* custom handler as defined by session_set_save_handler.
* The read callback will retrieve any existing session data (stored in a special serialized format)
* and will be unserialized and used to automatically populate the $_SESSION superglobal when the
* read callback returns the saved session data back to PHP session handling.
*
* To use a named session, call
* session_name before calling
* session_start.
*
* When session.use_trans_sid
* is enabled, the session_start function will
* register an internal output handler for URL rewriting.
*
* If a user uses ob_gzhandler or similar with
* ob_start, the function order is important for
* proper output. For example,
* ob_gzhandler must be registered before starting the session.
*
* @param array $options If provided, this is an associative array of options that will override
* the currently set
* session configuration directives.
* The keys should not include the session. prefix.
*
* In addition to the normal set of configuration directives, a
* read_and_close option may also be provided. If set to
* TRUE, this will result in the session being closed immediately after
* being read, thereby avoiding unnecessary locking if the session data
* won't be changed.
* @throws SessionException
*
*/
function session_start(array $options = []): void
{
error_clear_last();
$safeResult = \session_start($options);
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* The session_unset function frees all session variables
* currently registered.
*
* @throws SessionException
*
*/
function session_unset(): void
{
error_clear_last();
$safeResult = \session_unset();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}
/**
* End the current session and store session data.
*
* Session data is usually stored after your script terminated without the
* need to call session_write_close, but as session data
* is locked to prevent concurrent writes only one script may operate on a
* session at any time. When using framesets together with sessions you will
* experience the frames loading one by one due to this locking. You can
* reduce the time needed to load all the frames by ending the session as
* soon as all changes to session variables are done.
*
* @throws SessionException
*
*/
function session_write_close(): void
{
error_clear_last();
$safeResult = \session_write_close();
if ($safeResult === false) {
throw SessionException::createFromPhpError();
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Safe;
use Safe\Exceptions\ShmopException;
/**
* shmop_delete is used to delete a shared memory block.
*
* @param \Shmop $shmop The shared memory block resource created by
* shmop_open
* @throws ShmopException
*
*/
function shmop_delete(\Shmop $shmop): void
{
error_clear_last();
$safeResult = \shmop_delete($shmop);
if ($safeResult === false) {
throw ShmopException::createFromPhpError();
}
}
/**
* shmop_read will read a string from shared memory block.
*
* @param \Shmop $shmop The shared memory block identifier created by
* shmop_open
* @param int $offset Offset from which to start reading; must be greater than or equal to zero
* and less than or equal to the actual size of the shared memory segment.
* @param int $size The number of bytes to read; must be greater than or equal to zero,
* and the sum of offset and size
* must be less than or equal to the actual size of the shared memory segment.
* 0 reads shmop_size($shmid) - $start bytes.
* @return string Returns the data.
* @throws ShmopException
*
*/
function shmop_read(\Shmop $shmop, int $offset, int $size): string
{
error_clear_last();
$safeResult = \shmop_read($shmop, $offset, $size);
if ($safeResult === false) {
throw ShmopException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/sockets.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.4/sodium.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,22 @@
<?php
namespace Safe;
use Safe\Exceptions\SolrException;
/**
* This function returns the current version of the extension as a string.
*
* @return string It returns a string on success.
* @throws SolrException
*
*/
function solr_get_version(): string
{
error_clear_last();
$safeResult = \solr_get_version();
if ($safeResult === false) {
throw SolrException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,147 @@
<?php
namespace Safe;
use Safe\Exceptions\SplException;
/**
* This function returns an array with the names of the interfaces that the
* given object_or_class and its parents implement.
*
* @param object|string $object_or_class An object (class instance) or a string (class or interface name).
* @param bool $autoload Whether to autoload
* if not already loaded.
* @return array An array on success, or FALSE when the given class doesn't exist.
* @throws SplException
*
*/
function class_implements($object_or_class, bool $autoload = true): array
{
error_clear_last();
$safeResult = \class_implements($object_or_class, $autoload);
if ($safeResult === false) {
throw SplException::createFromPhpError();
}
return $safeResult;
}
/**
* This function returns an array with the name of the parent classes of
* the given object_or_class.
*
* @param object|string $object_or_class An object (class instance) or a string (class name).
* @param bool $autoload Whether to autoload
* if not already loaded.
* @return array An array on success, or FALSE when the given class doesn't exist.
* @throws SplException
*
*/
function class_parents($object_or_class, bool $autoload = true): array
{
error_clear_last();
$safeResult = \class_parents($object_or_class, $autoload);
if ($safeResult === false) {
throw SplException::createFromPhpError();
}
return $safeResult;
}
/**
* This function returns an array with the names of the traits that the
* given object_or_class uses. This does however not include
* any traits used by a parent class.
*
* @param object|string $object_or_class An object (class instance) or a string (class name).
* @param bool $autoload Whether to autoload
* if not already loaded.
* @return array An array on success, or FALSE when the given class doesn't exist.
* @throws SplException
*
*/
function class_uses($object_or_class, bool $autoload = true): array
{
error_clear_last();
$safeResult = \class_uses($object_or_class, $autoload);
if ($safeResult === false) {
throw SplException::createFromPhpError();
}
return $safeResult;
}
/**
* Register a function with the spl provided __autoload queue. If the queue
* is not yet activated it will be activated.
*
* If your code has an existing __autoload function then
* this function must be explicitly registered on the __autoload queue. This
* is because spl_autoload_register will effectively
* replace the engine cache for the __autoload function
* by either spl_autoload or
* spl_autoload_call.
*
* If there must be multiple autoload functions, spl_autoload_register
* allows for this. It effectively creates a queue of autoload functions, and
* runs through each of them in the order they are defined. By contrast,
* __autoload may only be defined once.
*
* @param callable(string):void|null $callback The autoload function being registered.
* If NULL, then the default implementation of
* spl_autoload will be registered.
*
* The class will not contain the leading
* backslash of a fully-qualified identifier.
* @param bool $throw This parameter specifies whether
* spl_autoload_register should throw
* exceptions when the callback
* cannot be registered.
*
* This parameter is ignored as of PHP 8.0.0, and a notice will be
* emitted if set to FALSE. spl_autoload_register
* will now always throw a TypeError on invalid
* arguments.
* @param bool $prepend If TRUE, spl_autoload_register will prepend
* the autoloader on the autoload queue instead of appending it.
* @throws SplException
*
*/
function spl_autoload_register(?callable $callback = null, bool $throw = true, bool $prepend = false): void
{
error_clear_last();
if ($prepend !== false) {
$safeResult = \spl_autoload_register($callback, $throw, $prepend);
} elseif ($throw !== true) {
$safeResult = \spl_autoload_register($callback, $throw);
} elseif ($callback !== null) {
$safeResult = \spl_autoload_register($callback);
} else {
$safeResult = \spl_autoload_register();
}
if ($safeResult === false) {
throw SplException::createFromPhpError();
}
}
/**
* Removes a function from the autoload queue. If the queue
* is activated and empty after removing the given function then it will
* be deactivated.
*
* When this function results in the queue being deactivated, any
* __autoload function that previously existed will not be reactivated.
*
* @param mixed $callback The autoload function being unregistered.
* @throws SplException
*
*/
function spl_autoload_unregister($callback): void
{
error_clear_last();
$safeResult = \spl_autoload_unregister($callback);
if ($safeResult === false) {
throw SplException::createFromPhpError();
}
}

View File

@@ -0,0 +1,571 @@
<?php
namespace Safe;
use Safe\Exceptions\SqlsrvException;
/**
* The transaction begun by sqlsrv_begin_transaction includes
* all statements that were executed after the call to
* sqlsrv_begin_transaction and before calls to
* sqlsrv_rollback or sqlsrv_commit.
* Explicit transactions should be started and committed or rolled back using
* these functions instead of executing SQL statements that begin and commit/roll
* back transactions. For more information, see
* SQLSRV Transactions.
*
* @param resource $conn The connection resource returned by a call to sqlsrv_connect.
* @throws SqlsrvException
*
*/
function sqlsrv_begin_transaction($conn): void
{
error_clear_last();
$safeResult = \sqlsrv_begin_transaction($conn);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Cancels a statement. Any results associated with the statement that have not
* been consumed are deleted. After sqlsrv_cancel has been
* called, the specified statement can be re-executed if it was created with
* sqlsrv_prepare. Calling sqlsrv_cancel
* is not necessary if all the results associated with the statement have been
* consumed.
*
* @param resource $stmt The statement resource to be cancelled.
* @throws SqlsrvException
*
*/
function sqlsrv_cancel($stmt): void
{
error_clear_last();
$safeResult = \sqlsrv_cancel($stmt);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Returns information about the client and specified connection
*
* @param resource $conn The connection about which information is returned.
* @return array Returns an associative array with keys described in the table below.
*
* Array returned by sqlsrv_client_info
*
*
*
* Key
* Description
*
*
*
*
* DriverDllName
* SQLNCLI10.DLL
*
*
* DriverODBCVer
* ODBC version (xx.yy)
*
*
* DriverVer
* SQL Server Native Client DLL version (10.5.xxx)
*
*
* ExtensionVer
* php_sqlsrv.dll version (2.0.xxx.x)
*
*
*
*
* @throws SqlsrvException
*
*/
function sqlsrv_client_info($conn): array
{
error_clear_last();
$safeResult = \sqlsrv_client_info($conn);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Closes an open connection and releases resourses associated with the connection.
*
* @param resource $conn The connection to be closed.
* @throws SqlsrvException
*
*/
function sqlsrv_close($conn): void
{
error_clear_last();
$safeResult = \sqlsrv_close($conn);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Commits a transaction that was begun with sqlsrv_begin_transaction.
* The connection is returned to auto-commit mode after sqlsrv_commit
* is called. The transaction that is committed includes all statements that were
* executed after the call to sqlsrv_begin_transaction.
* Explicit transactions should be started and committed or rolled back using these
* functions instead of executing SQL statements that begin and commit/roll back
* transactions. For more information, see
* SQLSRV Transactions.
*
* @param resource $conn The connection on which the transaction is to be committed.
* @throws SqlsrvException
*
*/
function sqlsrv_commit($conn): void
{
error_clear_last();
$safeResult = \sqlsrv_commit($conn);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Changes the driver error handling and logging configurations.
*
* @param string $setting The name of the setting to set. The possible values are
* "WarningsReturnAsErrors", "LogSubsystems", and "LogSeverity".
* @param mixed $value The value of the specified setting. The following table shows possible values:
*
* Error and Logging Setting Options
*
*
*
* Setting
* Options
*
*
*
*
* WarningsReturnAsErrors
* 1 (TRUE) or 0 (FALSE)
*
*
* LogSubsystems
* SQLSRV_LOG_SYSTEM_ALL (-1)
* SQLSRV_LOG_SYSTEM_CONN (2)
* SQLSRV_LOG_SYSTEM_INIT (1)
* SQLSRV_LOG_SYSTEM_OFF (0)
* SQLSRV_LOG_SYSTEM_STMT (4)
* SQLSRV_LOG_SYSTEM_UTIL (8)
*
*
* LogSeverity
* SQLSRV_LOG_SEVERITY_ALL (-1)
* SQLSRV_LOG_SEVERITY_ERROR (1)
* SQLSRV_LOG_SEVERITY_NOTICE (4)
* SQLSRV_LOG_SEVERITY_WARNING (2)
*
*
*
*
* @throws SqlsrvException
*
*/
function sqlsrv_configure(string $setting, $value): void
{
error_clear_last();
$safeResult = \sqlsrv_configure($setting, $value);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Executes a statement prepared with sqlsrv_prepare. This
* function is ideal for executing a prepared statement multiple times with
* different parameter values.
*
* @param resource $stmt A statement resource returned by sqlsrv_prepare.
* @throws SqlsrvException
*
*/
function sqlsrv_execute($stmt): void
{
error_clear_last();
$safeResult = \sqlsrv_execute($stmt);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Returns the next available row of data as an associative array, a numeric
* array, or both (the default).
*
* @param resource $stmt A statement resource returned by sqlsrv_query or sqlsrv_prepare.
* @param int $fetchType A predefined constant specifying the type of array to return. Possible
* values are SQLSRV_FETCH_ASSOC,
* SQLSRV_FETCH_NUMERIC, and
* SQLSRV_FETCH_BOTH (the default).
*
* A fetch type of SQLSRV_FETCH_ASSOC should not be used when consuming a
* result set with multiple columns of the same name.
* @param int $row Specifies the row to access in a result set that uses a scrollable cursor.
* Possible values are SQLSRV_SCROLL_NEXT,
* SQLSRV_SCROLL_PRIOR, SQLSRV_SCROLL_FIRST,
* SQLSRV_SCROLL_LAST, SQLSRV_SCROLL_ABSOLUTE and,
* SQLSRV_SCROLL_RELATIVE (the default). When this parameter
* is specified, the fetchType must be explicitly defined.
* @param int $offset Specifies the row to be accessed if the row parameter is set to
* SQLSRV_SCROLL_ABSOLUTE or
* SQLSRV_SCROLL_RELATIVE. Note that the first row in
* a result set has index 0.
* @return array|null Returns an array on success, NULL if there are no more rows to return, and
* FALSE if an error occurs.
* @throws SqlsrvException
*
*/
function sqlsrv_fetch_array($stmt, ?int $fetchType = null, ?int $row = null, ?int $offset = null): ?array
{
error_clear_last();
if ($offset !== null) {
$safeResult = \sqlsrv_fetch_array($stmt, $fetchType, $row, $offset);
} elseif ($row !== null) {
$safeResult = \sqlsrv_fetch_array($stmt, $fetchType, $row);
} elseif ($fetchType !== null) {
$safeResult = \sqlsrv_fetch_array($stmt, $fetchType);
} else {
$safeResult = \sqlsrv_fetch_array($stmt);
}
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the next row of data in a result set as an instance of the specified
* class with properties that match the row field names and values that correspond
* to the row field values.
*
* @param resource $stmt A statement resource created by sqlsrv_query or
* sqlsrv_execute.
* @param string $className The name of the class to instantiate. If no class name is specified,
* stdClass is instantiated.
* @param array $ctorParams Values passed to the constructor of the specified class. If the constructor
* of the specified class takes parameters, the ctorParams array must be
* supplied.
* @param int $row The row to be accessed. This parameter can only be used if the specified
* statement was prepared with a scrollable cursor. In that case, this parameter
* can take on one of the following values:
*
* SQLSRV_SCROLL_NEXT
* SQLSRV_SCROLL_PRIOR
* SQLSRV_SCROLL_FIRST
* SQLSRV_SCROLL_LAST
* SQLSRV_SCROLL_ABSOLUTE
* SQLSRV_SCROLL_RELATIVE
*
* @param int $offset Specifies the row to be accessed if the row parameter is set to
* SQLSRV_SCROLL_ABSOLUTE or
* SQLSRV_SCROLL_RELATIVE. Note that the first row in
* a result set has index 0.
* @return null|object Returns an object on success, NULL if there are no more rows to return,
* and FALSE if an error occurs or if the specified class does not exist.
* @throws SqlsrvException
*
*/
function sqlsrv_fetch_object($stmt, ?string $className = null, ?array $ctorParams = null, ?int $row = null, ?int $offset = null): ?object
{
error_clear_last();
if ($offset !== null) {
$safeResult = \sqlsrv_fetch_object($stmt, $className, $ctorParams, $row, $offset);
} elseif ($row !== null) {
$safeResult = \sqlsrv_fetch_object($stmt, $className, $ctorParams, $row);
} elseif ($ctorParams !== null) {
$safeResult = \sqlsrv_fetch_object($stmt, $className, $ctorParams);
} elseif ($className !== null) {
$safeResult = \sqlsrv_fetch_object($stmt, $className);
} else {
$safeResult = \sqlsrv_fetch_object($stmt);
}
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Makes the next row in a result set available for reading. Use
* sqlsrv_get_field to read the fields of the row.
*
* @param resource $stmt A statement resource created by executing sqlsrv_query
* or sqlsrv_execute.
* @param int $row The row to be accessed. This parameter can only be used if the specified
* statement was prepared with a scrollable cursor. In that case, this parameter
* can take on one of the following values:
*
* SQLSRV_SCROLL_NEXT
* SQLSRV_SCROLL_PRIOR
* SQLSRV_SCROLL_FIRST
* SQLSRV_SCROLL_LAST
* SQLSRV_SCROLL_ABSOLUTE
* SQLSRV_SCROLL_RELATIVE
*
* @param int $offset Specifies the row to be accessed if the row parameter is set to
* SQLSRV_SCROLL_ABSOLUTE or
* SQLSRV_SCROLL_RELATIVE. Note that the first row in
* a result set has index 0.
* @return bool|null Returns TRUE if the next row of a result set was successfully retrieved,
* FALSE if an error occurs, and NULL if there are no more rows in the result set.
* @throws SqlsrvException
*
*/
function sqlsrv_fetch($stmt, ?int $row = null, ?int $offset = null): ?bool
{
error_clear_last();
if ($offset !== null) {
$safeResult = \sqlsrv_fetch($stmt, $row, $offset);
} elseif ($row !== null) {
$safeResult = \sqlsrv_fetch($stmt, $row);
} else {
$safeResult = \sqlsrv_fetch($stmt);
}
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Frees all resources for the specified statement. The statement cannot be used
* after sqlsrv_free_stmt has been called on it. If
* sqlsrv_free_stmt is called on an in-progress statement
* that alters server state, statement execution is terminated and the statement
* is rolled back.
*
* @param resource $stmt The statement for which resources are freed.
* Note that NULL is a valid parameter value. This allows the function to be
* called multiple times in a script.
* @throws SqlsrvException
*
*/
function sqlsrv_free_stmt($stmt): void
{
error_clear_last();
$safeResult = \sqlsrv_free_stmt($stmt);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}
/**
* Gets field data from the currently selected row. Fields must be accessed in
* order. Field indices start at 0.
*
* @param resource $stmt A statement resource returned by sqlsrv_query or
* sqlsrv_execute.
* @param int $fieldIndex The index of the field to be retrieved. Field indices start at 0. Fields
* must be accessed in order. i.e. If you access field index 1, then field
* index 0 will not be available.
* @param int $getAsType The PHP data type for the returned field data. If this parameter is not
* set, the field data will be returned as its default PHP data type.
* For information about default PHP data types, see
* Default PHP Data Types
* in the Microsoft SQLSRV documentation.
* @return mixed Returns data from the specified field on success.
* @throws SqlsrvException
*
*/
function sqlsrv_get_field($stmt, int $fieldIndex, ?int $getAsType = null)
{
error_clear_last();
if ($getAsType !== null) {
$safeResult = \sqlsrv_get_field($stmt, $fieldIndex, $getAsType);
} else {
$safeResult = \sqlsrv_get_field($stmt, $fieldIndex);
}
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Makes the next result of the specified statement active. Results include result
* sets, row counts, and output parameters.
*
* @param resource $stmt The statement on which the next result is being called.
* @return bool|null Returns TRUE if the next result was successfully retrieved, FALSE if an error
* occurred, and NULL if there are no more results to retrieve.
* @throws SqlsrvException
*
*/
function sqlsrv_next_result($stmt): ?bool
{
error_clear_last();
$safeResult = \sqlsrv_next_result($stmt);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the number of fields (columns) on a statement.
*
* @param resource $stmt The statement for which the number of fields is returned.
* sqlsrv_num_fields can be called on a statement before
* or after statement execution.
* @return int Returns the number of fields on success.
* @throws SqlsrvException
*
*/
function sqlsrv_num_fields($stmt): int
{
error_clear_last();
$safeResult = \sqlsrv_num_fields($stmt);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieves the number of rows in a result set. This function requires that the
* statement resource be created with a static or keyset cursor. For more information,
* see sqlsrv_query, sqlsrv_prepare,
* or Specifying a Cursor Type and Selecting Rows
* in the Microsoft SQLSRV documentation.
*
* @param resource $stmt The statement for which the row count is returned. The statement resource
* must be created with a static or keyset cursor. For more information, see
* sqlsrv_query, sqlsrv_prepare, or
* Specifying a Cursor Type and Selecting Rows
* in the Microsoft SQLSRV documentation.
* @return int Returns the number of rows retrieved on success.
* If a forward cursor (the default) or dynamic cursor is used, FALSE is returned.
* @throws SqlsrvException
*
*/
function sqlsrv_num_rows($stmt): int
{
error_clear_last();
$safeResult = \sqlsrv_num_rows($stmt);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Prepares a query for execution. This function is ideal for preparing a query
* that will be executed multiple times with different parameter values.
*
* @param resource $conn A connection resource returned by sqlsrv_connect.
* @param string $sql The string that defines the query to be prepared and executed.
* @param array $params An array specifying parameter information when executing a parameterized
* query. Array elements can be any of the following:
*
* A literal value
* A PHP variable
* An array with this structure:
* array($value [, $direction [, $phpType [, $sqlType]]])
*
* The following table describes the elements in the array structure above:
* @param array $options An array specifying query property options. The supported keys are described
* in the following table:
* @return mixed Returns a statement resource on success.
* @throws SqlsrvException
*
*/
function sqlsrv_prepare($conn, string $sql, ?array $params = null, ?array $options = null)
{
error_clear_last();
if ($options !== null) {
$safeResult = \sqlsrv_prepare($conn, $sql, $params, $options);
} elseif ($params !== null) {
$safeResult = \sqlsrv_prepare($conn, $sql, $params);
} else {
$safeResult = \sqlsrv_prepare($conn, $sql);
}
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Prepares and executes a query.
*
* @param resource $conn A connection resource returned by sqlsrv_connect.
* @param string $sql The string that defines the query to be prepared and executed.
* @param array $params An array specifying parameter information when executing a parameterized query.
* Array elements can be any of the following:
*
* A literal value
* A PHP variable
* An array with this structure:
* array($value [, $direction [, $phpType [, $sqlType]]])
*
* The following table describes the elements in the array structure above:
* @param array $options An array specifying query property options. The supported keys are described
* in the following table:
* @return mixed Returns a statement resource on success.
* @throws SqlsrvException
*
*/
function sqlsrv_query($conn, string $sql, ?array $params = null, ?array $options = null)
{
error_clear_last();
if ($options !== null) {
$safeResult = \sqlsrv_query($conn, $sql, $params, $options);
} elseif ($params !== null) {
$safeResult = \sqlsrv_query($conn, $sql, $params);
} else {
$safeResult = \sqlsrv_query($conn, $sql);
}
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
return $safeResult;
}
/**
* Rolls back a transaction that was begun with sqlsrv_begin_transaction
* and returns the connection to auto-commit mode.
*
* @param resource $conn The connection resource returned by a call to sqlsrv_connect.
* @throws SqlsrvException
*
*/
function sqlsrv_rollback($conn): void
{
error_clear_last();
$safeResult = \sqlsrv_rollback($conn);
if ($safeResult === false) {
throw SqlsrvException::createFromPhpError();
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Safe;
use Safe\Exceptions\SsdeepException;
/**
* Calculates the match score between signature1
* and signature2 using
* context-triggered piecewise hashing, and returns the match
* score.
*
* @param string $signature1 The first fuzzy hash signature string.
* @param string $signature2 The second fuzzy hash signature string.
* @return int Returns an integer from 0 to 100 on success.
* @throws SsdeepException
*
*/
function ssdeep_fuzzy_compare(string $signature1, string $signature2): int
{
error_clear_last();
$safeResult = \ssdeep_fuzzy_compare($signature1, $signature2);
if ($safeResult === false) {
throw SsdeepException::createFromPhpError();
}
return $safeResult;
}
/**
* ssdeep_fuzzy_hash_filename calculates the hash
* of the file specified by file_name using
* context-triggered piecewise
* hashing, and returns that hash.
*
* @param string $file_name The filename of the file to hash.
* @return string Returns a string on success.
* @throws SsdeepException
*
*/
function ssdeep_fuzzy_hash_filename(string $file_name): string
{
error_clear_last();
$safeResult = \ssdeep_fuzzy_hash_filename($file_name);
if ($safeResult === false) {
throw SsdeepException::createFromPhpError();
}
return $safeResult;
}
/**
* ssdeep_fuzzy_hash calculates the hash of
* to_hash using
* context-triggered piecewise hashing, and returns that hash.
*
* @param string $to_hash The input string.
* @return string Returns a string on success.
* @throws SsdeepException
*
*/
function ssdeep_fuzzy_hash(string $to_hash): string
{
error_clear_last();
$safeResult = \ssdeep_fuzzy_hash($to_hash);
if ($safeResult === false) {
throw SsdeepException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,749 @@
<?php
namespace Safe;
use Safe\Exceptions\Ssh2Exception;
/**
* Authenticate over SSH using the ssh agent
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $username Remote user name.
* @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();
}
}
/**
* Authenticate using a public hostkey read from a file.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $username
* @param string $hostname
* @param string $pubkeyfile
* @param string $privkeyfile
* @param string $passphrase If privkeyfile is encrypted (which it should
* be), the passphrase must be provided.
* @param string $local_username If local_username is omitted, then the value
* for username will be used for it.
* @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();
}
}
/**
* Authenticate over SSH using a plain password. Since version 0.12 this function
* also supports keyboard_interactive method.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $username Remote user name.
* @param string $password Password for username
* @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();
}
}
/**
* Authenticate using a public key read from a file.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $username
* @param string $pubkeyfile The public key file needs to be in OpenSSH's format. It should look something like:
*
* ssh-rsa AAAAB3NzaC1yc2EAAA....NX6sqSnHA8= rsa-key-20121110
* @param string $privkeyfile
* @param string $passphrase If privkeyfile is encrypted (which it should
* be), the passphrase must be provided.
* @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();
}
}
/**
* Establish a connection to a remote SSH server.
*
* Once connected, the client should verify the server's hostkey using
* ssh2_fingerprint, then authenticate using either
* password or public key.
*
* @param string $host
* @param int $port
* @param array $methods methods may be an associative array with up to four parameters
* as described below.
*
*
* methods may be an associative array
* with any or all of the following parameters.
*
*
*
* Index
* Meaning
* Supported Values*
*
*
*
*
* kex
*
* List of key exchange methods to advertise, comma separated
* in order of preference.
*
*
* diffie-hellman-group1-sha1,
* diffie-hellman-group14-sha1, and
* diffie-hellman-group-exchange-sha1
*
*
*
* hostkey
*
* List of hostkey methods to advertise, comma separated
* in order of preference.
*
*
* ssh-rsa and
* ssh-dss
*
*
*
* client_to_server
*
* Associative array containing crypt, compression, and
* message authentication code (MAC) method preferences
* for messages sent from client to server.
*
*
*
*
* server_to_client
*
* Associative array containing crypt, compression, and
* message authentication code (MAC) method preferences
* for messages sent from server to client.
*
*
*
*
*
*
*
* * - Supported Values are dependent on methods supported by underlying library.
* See libssh2 documentation for additional
* information.
*
*
*
* client_to_server and
* server_to_client may be an associative array
* with any or all of the following parameters.
*
*
*
*
* Index
* Meaning
* Supported Values*
*
*
*
*
* crypt
* List of crypto methods to advertise, comma separated
* in order of preference.
*
* rijndael-cbc@lysator.liu.se,
* aes256-cbc,
* aes192-cbc,
* aes128-cbc,
* 3des-cbc,
* blowfish-cbc,
* cast128-cbc,
* arcfour, and
* none**
*
*
*
* comp
* List of compression methods to advertise, comma separated
* in order of preference.
*
* zlib and
* none
*
*
*
* mac
* List of MAC methods to advertise, comma separated
* in order of preference.
*
* hmac-sha1,
* hmac-sha1-96,
* hmac-ripemd160,
* hmac-ripemd160@openssh.com, and
* none**
*
*
*
*
*
*
*
* Crypt and MAC method "none"
*
* For security reasons, none is disabled by the underlying
* libssh2 library unless explicitly enabled
* during build time by using the appropriate ./configure options. See documentation
* for the underlying library for more information.
*
*
*
* For security reasons, none is disabled by the underlying
* libssh2 library unless explicitly enabled
* during build time by using the appropriate ./configure options. See documentation
* for the underlying library for more information.
* @param array $callbacks callbacks may be an associative array with any
* or all of the following parameters.
*
*
* Callbacks parameters
*
*
*
*
* Index
* Meaning
* Prototype
*
*
*
*
* ignore
*
* Name of function to call when an
* SSH2_MSG_IGNORE packet is received
*
* void ignore_cb($message)
*
*
* debug
*
* Name of function to call when an
* SSH2_MSG_DEBUG packet is received
*
* void debug_cb($message, $language, $always_display)
*
*
* macerror
*
* Name of function to call when a packet is received but the
* message authentication code failed. If the callback returns
* TRUE, the mismatch will be ignored, otherwise the connection
* will be terminated.
*
* bool macerror_cb($packet)
*
*
* disconnect
*
* Name of function to call when an
* SSH2_MSG_DISCONNECT packet is received
*
* void disconnect_cb($reason, $message, $language)
*
*
*
*
* @return resource Returns a resource on success.
* @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;
}
/**
* Close a connection to a remote SSH server.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @throws Ssh2Exception
*
*/
function ssh2_disconnect($session): void
{
error_clear_last();
$safeResult = \ssh2_disconnect($session);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* Execute a command at the remote end and allocate a channel for it.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $command
* @param string $pty
* @param array $env env may be passed as an associative array of
* name/value pairs to set in the target environment.
* @param int $width Width of the virtual terminal.
* @param int $height Height of the virtual terminal.
* @param int $width_height_type width_height_type should be one of
* SSH2_TERM_UNIT_CHARS or
* SSH2_TERM_UNIT_PIXELS.
* @return resource Returns a stream on success.
* @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;
}
/**
* Accepts a connection created by a listener.
*
* @param resource $listener An SSH2 Listener resource, obtained from a call to ssh2_forward_listen.
* @return resource Returns a stream resource.
* @throws Ssh2Exception
*
*/
function ssh2_forward_accept($listener)
{
error_clear_last();
$safeResult = \ssh2_forward_accept($listener);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* Binds a port on the remote server and listen for connections.
*
* @param resource $session An SSH Session resource, obtained from a call to ssh2_connect.
* @param int $port The port of the remote server.
* @param string $host
* @param int $max_connections
* @return resource Returns an SSH2 Listener.
* @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 Publickey Subsystem resource created by ssh2_publickey_init.
* @param string $algoname Publickey algorithm (e.g.): ssh-dss, ssh-rsa
* @param string $blob Publickey blob as raw binary data
* @param bool $overwrite If the specified key already exists, should it be overwritten?
* @param array $attributes Associative array of attributes to assign to this public key.
* Refer to ietf-secsh-publickey-subsystem for a list of supported attributes.
* To mark an attribute as mandatory, precede its name with an asterisk.
* If the server is unable to support an attribute marked mandatory,
* it will abort the add process.
* @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();
}
}
/**
* Request the Publickey subsystem from an already connected SSH2 server.
*
* The publickey subsystem allows an already connected and authenticated
* client to manage the list of authorized public keys stored on the
* target server in an implementation agnostic manner.
* If the remote server does not support the publickey subsystem,
* the ssh2_publickey_init function will return FALSE.
*
* @param resource $session
* @return resource Returns an SSH2 Publickey Subsystem resource for use
* with all other ssh2_publickey_*() methods.
* @throws Ssh2Exception
*
*/
function ssh2_publickey_init($session)
{
error_clear_last();
$safeResult = \ssh2_publickey_init($session);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* Removes an authorized publickey.
*
* @param resource $pkey Publickey Subsystem Resource
* @param string $algoname Publickey algorithm (e.g.): ssh-dss, ssh-rsa
* @param string $blob Publickey blob as raw binary data
* @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();
}
}
/**
* Copy a file from the remote server to the local filesystem using the SCP protocol.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $remote_file Path to the remote file.
* @param string $local_file Path to the 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();
}
}
/**
* Copy a file from the local filesystem to the remote server using the SCP protocol.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $local_file Path to the local file.
* @param string $remote_file Path to the remote file.
* @param int $create_mode The file will be created with the mode specified by
* 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();
}
}
/**
* Sends an EOF to the stream; this is typically used to close standard input,
* while keeping output and error alive. For example, one can send a remote
* process some data over standard input, close it to start processing, and
* still be able to read out the results without creating additional files.
*
* @param resource $channel An SSH stream; can be acquired through functions like ssh2_fetch_stream
* or ssh2_connect.
* @throws Ssh2Exception
*
*/
function ssh2_send_eof($channel): void
{
error_clear_last();
$safeResult = \ssh2_send_eof($channel);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
}
/**
* Attempts to change the mode of the specified file to that given in
* mode.
*
* @param resource $sftp An SSH2 SFTP resource opened by ssh2_sftp.
* @param string $filename Path to the file.
* @param int $mode Permissions on the file. See the chmod for more details on this parameter.
* @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();
}
}
/**
* Creates a directory on the remote file server with permissions set to
* mode.
*
* This function is similar to using mkdir with the
* ssh2.sftp:// wrapper.
*
* @param resource $sftp An SSH2 SFTP resource opened by ssh2_sftp.
* @param string $dirname Path of the new directory.
* @param int $mode Permissions on the new directory.
* The actual mode is affected by the current umask.
* @param bool $recursive If recursive is TRUE any parent directories
* required for dirname will be automatically created as well.
* @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();
}
}
/**
* Renames a file on the remote filesystem.
*
* @param resource $sftp An SSH2 SFTP resource opened by ssh2_sftp.
* @param string $from The current file that is being renamed.
* @param string $to The new file name that replaces from.
* @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();
}
}
/**
* Removes a directory from the remote file server.
*
* This function is similar to using rmdir with the
* ssh2.sftp:// wrapper.
*
* @param resource $sftp An SSH2 SFTP resource opened by ssh2_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();
}
}
/**
* Creates a symbolic link named link on the remote
* filesystem pointing to target.
*
* @param resource $sftp An SSH2 SFTP resource opened by ssh2_sftp.
* @param string $target Target of the symbolic link.
* @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();
}
}
/**
* Deletes a file on the remote filesystem.
*
* @param resource $sftp An SSH2 SFTP resource opened by ssh2_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();
}
}
/**
* Request the SFTP subsystem from an already connected SSH2 server.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @return resource This method returns an SSH2 SFTP resource for use with
* all other ssh2_sftp_*() methods and the
* ssh2.sftp:// fopen wrapper.
* @throws Ssh2Exception
*
*/
function ssh2_sftp($session)
{
error_clear_last();
$safeResult = \ssh2_sftp($session);
if ($safeResult === false) {
throw Ssh2Exception::createFromPhpError();
}
return $safeResult;
}
/**
* Open a shell at the remote end and allocate a stream for it.
*
* @param resource $session An SSH connection link identifier, obtained from a call to
* ssh2_connect.
* @param string $termtype termtype should correspond to one of the
* entries in the target system's /etc/termcap file.
* @param array|null $env env may be passed as an associative array of
* name/value pairs to set in the target environment.
* @param int $width Width of the virtual terminal.
* @param int $height Height of the virtual terminal.
* @param int $width_height_type width_height_type should be one of
* SSH2_TERM_UNIT_CHARS or
* SSH2_TERM_UNIT_PIXELS.
* @return resource Returns a stream resource on success.
* @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;
}

0
vendor/thecodingmachine/safe/generated/8.4/stream.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,88 @@
<?php
namespace Safe;
use Safe\Exceptions\StringsException;
/**
* convert_uudecode decodes a uuencoded string.
*
* @param string $string The uuencoded data.
* @return string Returns the decoded data as a string.
* @throws StringsException
*
*/
function convert_uudecode(string $string): string
{
error_clear_last();
$safeResult = \convert_uudecode($string);
if ($safeResult === false) {
throw StringsException::createFromPhpError();
}
return $safeResult;
}
/**
* Decodes a hexadecimally encoded binary string.
*
* @param string $string Hexadecimal representation of data.
* @return string Returns the binary representation of the given data.
* @throws StringsException
*
*/
function hex2bin(string $string): string
{
error_clear_last();
$safeResult = \hex2bin($string);
if ($safeResult === false) {
throw StringsException::createFromPhpError();
}
return $safeResult;
}
/**
* Calculates the MD5 hash of the file specified by the
* filename parameter using the
* RSA Data Security, Inc.
* MD5 Message-Digest Algorithm, and returns that hash.
* The hash is a 32-character hexadecimal number.
*
* @param string $filename The filename
* @param bool $binary When TRUE, returns the digest in raw binary format with a length of
* 16.
* @return non-falsy-string&lowercase-string Returns a string on success.
* @throws StringsException
*
*/
function md5_file(string $filename, bool $binary = false): string
{
error_clear_last();
$safeResult = \md5_file($filename, $binary);
if ($safeResult === false) {
throw StringsException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param string $filename The filename of the file to hash.
* @param bool $binary When TRUE, returns the digest in raw binary format with a length of
* 20.
* @return non-falsy-string&lowercase-string Returns a string on success.
* @throws StringsException
*
*/
function sha1_file(string $filename, bool $binary = false): string
{
error_clear_last();
$safeResult = \sha1_file($filename, $binary);
if ($safeResult === false) {
throw StringsException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,148 @@
<?php
namespace Safe;
use Safe\Exceptions\SwooleException;
/**
*
*
* @param string $hostname The host name.
* @param callable $callback The host name.
*
* The IP address.
* @throws SwooleException
*
*/
function swoole_async_dns_lookup(string $hostname, callable $callback): void
{
error_clear_last();
$safeResult = \swoole_async_dns_lookup($hostname, $callback);
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}
/**
*
*
* @param string $filename The filename of the file being read.
* @param string $callback The name of the file.
*
* The content read from the file.
* @throws SwooleException
*
*/
function swoole_async_readfile(string $filename, string $callback): void
{
error_clear_last();
$safeResult = \swoole_async_readfile($filename, $callback);
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}
/**
*
*
* @param string $filename The filename being written.
* @param string $content The content writing to the file.
* @param int $offset The offset.
* @param callable $callback
* @throws SwooleException
*
*/
function swoole_async_write(string $filename, string $content, ?int $offset = null, ?callable $callback = null): void
{
error_clear_last();
if ($callback !== null) {
$safeResult = \swoole_async_write($filename, $content, $offset, $callback);
} elseif ($offset !== null) {
$safeResult = \swoole_async_write($filename, $content, $offset);
} else {
$safeResult = \swoole_async_write($filename, $content);
}
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}
/**
*
*
* @param string $filename The filename being written.
* @param string $content The content writing to the file.
* @param callable $callback
* @param int $flags
* @throws SwooleException
*
*/
function swoole_async_writefile(string $filename, string $content, ?callable $callback = null, int $flags = 0): void
{
error_clear_last();
if ($flags !== 0) {
$safeResult = \swoole_async_writefile($filename, $content, $callback, $flags);
} elseif ($callback !== null) {
$safeResult = \swoole_async_writefile($filename, $content, $callback);
} else {
$safeResult = \swoole_async_writefile($filename, $content);
}
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}
/**
*
*
* @param callable $callback
* @throws SwooleException
*
*/
function swoole_event_defer(callable $callback): void
{
error_clear_last();
$safeResult = \swoole_event_defer($callback);
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}
/**
*
*
* @param int $fd
* @throws SwooleException
*
*/
function swoole_event_del(int $fd): void
{
error_clear_last();
$safeResult = \swoole_event_del($fd);
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}
/**
*
*
* @param int $fd
* @param string $data
* @throws SwooleException
*
*/
function swoole_event_write(int $fd, string $data): void
{
error_clear_last();
$safeResult = \swoole_event_write($fd, $data);
if ($safeResult === false) {
throw SwooleException::createFromPhpError();
}
}

0
vendor/thecodingmachine/safe/generated/8.4/uodbc.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,40 @@
<?php
namespace Safe;
use Safe\Exceptions\UopzException;
/**
* Makes class extend parent
*
* @param string $class The name of the class to extend
* @param string $parent The name of the class to inherit
* @throws UopzException
*
*/
function uopz_extend(string $class, string $parent): void
{
error_clear_last();
$safeResult = \uopz_extend($class, $parent);
if ($safeResult === false) {
throw UopzException::createFromPhpError();
}
}
/**
* Makes class implement interface
*
* @param string $class
* @param string $interface
* @throws UopzException
*
*/
function uopz_implement(string $class, string $interface): void
{
error_clear_last();
$safeResult = \uopz_implement($class, $interface);
if ($safeResult === false) {
throw UopzException::createFromPhpError();
}
}

View File

@@ -0,0 +1,204 @@
<?php
namespace Safe;
use Safe\Exceptions\UrlException;
/**
* Decodes a base64 encoded string.
*
* @param string $string The encoded data.
* @param bool $strict If the strict parameter is set to TRUE
* then the base64_decode function will return
* FALSE if the input contains character from outside the base64
* alphabet. Otherwise invalid characters will be silently discarded.
* @return string Returns the decoded data. The returned data may be
* binary.
* @throws UrlException
*
*/
function base64_decode(string $string, bool $strict = false): string
{
error_clear_last();
$safeResult = \base64_decode($string, $strict);
if ($safeResult === false) {
throw UrlException::createFromPhpError();
}
return $safeResult;
}
/**
* get_headers returns an array with the headers sent
* by the server in response to a HTTP request.
*
* @param string $url The target URL.
* @param bool $associative If the optional associative parameter is set to true,
* get_headers parses the response and sets the
* array's keys.
* @param null|resource $context A valid context resource created with
* stream_context_create, or NULL to use the
* default context.
* @return array Returns an indexed or associative array with the headers.
* @throws UrlException
*
*/
function get_headers(string $url, bool $associative = false, $context = null): array
{
error_clear_last();
if ($context !== null) {
$safeResult = \get_headers($url, $associative, $context);
} else {
$safeResult = \get_headers($url, $associative);
}
if ($safeResult === false) {
throw UrlException::createFromPhpError();
}
return $safeResult;
}
/**
* Opens filename and parses it line by line for
* &lt;meta&gt; tags in the file. The parsing stops at
* &lt;/head&gt;.
*
* @param string $filename The path to the HTML file, as a string. This can be a local file or an
* URL.
*
*
* What get_meta_tags parses
*
*
*
*
*
*
* ]]>
*
*
* @param bool $use_include_path Setting use_include_path to TRUE will result
* in PHP trying to open the file along the standard include path as per
* the include_path directive.
* This is used for local files, not URLs.
* @return array Returns an array with all the parsed meta tags.
*
* The value of the name property becomes the key, the value of the content
* property becomes the value of the returned array, so you can easily use
* standard array functions to traverse it or access single values.
* Special characters in the value of the name property are substituted with
* '_', the rest is converted to lower case. If two meta tags have the same
* name, only the last one is returned.
*
* Returns FALSE on failure.
* @throws UrlException
*
*/
function get_meta_tags(string $filename, bool $use_include_path = false): array
{
error_clear_last();
$safeResult = \get_meta_tags($filename, $use_include_path);
if ($safeResult === false) {
throw UrlException::createFromPhpError();
}
return $safeResult;
}
/**
* This function parses a URL and returns an associative array containing any
* of the various components of the URL that are present.
* The values of the array elements are not URL decoded.
*
* This function is not meant to validate
* the given URL, it only breaks it up into the parts listed below. Partial and invalid
* URLs are also accepted, parse_url tries its best to
* parse them correctly.
*
* @param string $url The URL to parse.
* @param int $component Specify one of PHP_URL_SCHEME,
* PHP_URL_HOST, PHP_URL_PORT,
* PHP_URL_USER, PHP_URL_PASS,
* PHP_URL_PATH, PHP_URL_QUERY
* or PHP_URL_FRAGMENT to retrieve just a specific
* URL component as a string (except when
* PHP_URL_PORT is given, in which case the return
* value will be an int).
* @return array|int|null|string On seriously malformed URLs, parse_url.
*
* If the component parameter is omitted, an
* associative array is returned. At least one element will be
* present within the array. Potential keys within this array are:
*
*
*
* scheme - e.g. http
*
*
*
*
* host
*
*
*
*
* port
*
*
*
*
* user
*
*
*
*
* pass
*
*
*
*
* path
*
*
*
*
* query - after the question mark ?
*
*
*
*
* fragment - after the hashmark #
*
*
*
*
* If the component parameter is specified,
* parse_url returns a string (or an
* int, in the case of PHP_URL_PORT)
* instead of an array. If the requested component doesn't exist
* within the given URL, NULL will be returned.
* As of PHP 8.0.0, parse_url distinguishes absent and empty
* queries and fragments:
*
*
*
*
*
*
*
* Previously all cases resulted in query and fragment being NULL.
*
* Note that control characters (cf. ctype_cntrl) in the
* components are replaced with underscores (_).
* @throws UrlException
*
*/
function parse_url(string $url, int $component = -1)
{
error_clear_last();
$safeResult = \parse_url($url, $component);
if ($safeResult === false) {
throw UrlException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Safe;
use Safe\Exceptions\VarException;
/**
* Set the type of variable var to
* type.
*
* @param mixed $var The variable being converted.
* @param string $type Possibles values of type are:
*
*
*
* "boolean" or "bool"
*
*
*
*
* "integer" or "int"
*
*
*
*
* "float" or "double"
*
*
*
*
* "string"
*
*
*
*
* "array"
*
*
*
*
* "object"
*
*
*
*
* "null"
*
*
*
* @throws VarException
*
*/
function settype(&$var, string $type): void
{
error_clear_last();
$safeResult = \settype($var, $type);
if ($safeResult === false) {
throw VarException::createFromPhpError();
}
}

View File

@@ -0,0 +1,236 @@
<?php
namespace Safe;
use Safe\Exceptions\XdiffException;
/**
* Makes a binary diff of two files and stores the result in a patch file.
* This function works with both text and binary files. Resulting patch
* file can be later applied using xdiff_file_bpatch/xdiff_string_bpatch.
*
* @param string $old_file Path to the first file. This file acts as "old" file.
* @param string $new_file Path to the second file. This file acts as "new" file.
* @param string $dest Path of the resulting patch file. Resulting file contains differences
* between "old" and "new" files. It is in binary format and is human-unreadable.
* @throws XdiffException
*
*/
function xdiff_file_bdiff(string $old_file, string $new_file, string $dest): void
{
error_clear_last();
$safeResult = \xdiff_file_bdiff($old_file, $new_file, $dest);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
}
/**
* Patches a file with a binary
* patch and stores the result in a file dest.
* This function accepts patches created both via xdiff_file_bdiff
* and xdiff_file_rabdiff functions or their string counterparts.
*
* @param string $file The original file.
* @param string $patch The binary patch file.
* @param string $dest Path of the resulting file.
* @throws XdiffException
*
*/
function xdiff_file_bpatch(string $file, string $patch, string $dest): void
{
error_clear_last();
$safeResult = \xdiff_file_bpatch($file, $patch, $dest);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
}
/**
* Makes a binary diff of two files and stores the result in a patch file.
* This function works with both text and binary files. Resulting patch
* file can be later applied using xdiff_file_bpatch.
*
* Starting with version 1.5.0 this function is an alias of xdiff_file_bdiff.
*
* @param string $old_file Path to the first file. This file acts as "old" file.
* @param string $new_file Path to the second file. This file acts as "new" file.
* @param string $dest Path of the resulting patch file. Resulting file contains differences
* between "old" and "new" files. It is in binary format and is human-unreadable.
* @throws XdiffException
*
*/
function xdiff_file_diff_binary(string $old_file, string $new_file, string $dest): void
{
error_clear_last();
$safeResult = \xdiff_file_diff_binary($old_file, $new_file, $dest);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
}
/**
* Makes an unified diff containing differences between old_file and
* new_file and stores it in dest file. The
* resulting file is human-readable. An optional context parameter
* specifies how many lines of context should be added around each change.
* Setting minimal parameter to true will result in outputting the shortest
* patch file possible (can take a long time).
*
* @param string $old_file Path to the first file. This file acts as "old" file.
* @param string $new_file Path to the second file. This file acts as "new" file.
* @param string $dest Path of the resulting patch file.
* @param int $context Indicates how many lines of context you want to include in diff
* result.
* @param bool $minimal Set this parameter to TRUE if you want to minimalize size of the result
* (can take a long time).
* @throws XdiffException
*
*/
function xdiff_file_diff(string $old_file, string $new_file, string $dest, int $context = 3, bool $minimal = false): void
{
error_clear_last();
$safeResult = \xdiff_file_diff($old_file, $new_file, $dest, $context, $minimal);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
}
/**
* Patches a file with a binary
* patch and stores the result in a file dest.
* This function accepts patches created both via xdiff_file_bdiff
* or xdiff_file_rabdiff functions or their string counterparts.
*
* Starting with version 1.5.0 this function is an alias of xdiff_file_bpatch.
*
* @param string $file The original file.
* @param string $patch The binary patch file.
* @param string $dest Path of the resulting file.
* @throws XdiffException
*
*/
function xdiff_file_patch_binary(string $file, string $patch, string $dest): void
{
error_clear_last();
$safeResult = \xdiff_file_patch_binary($file, $patch, $dest);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
}
/**
* Makes a binary diff of two files and stores the result in a patch file.
* The difference between this function and xdiff_file_bdiff is different
* algorithm used which should result in faster execution and smaller diff produced.
* This function works with both text and binary files. Resulting patch
* file can be later applied using xdiff_file_bpatch/xdiff_string_bpatch.
*
* For more details about differences between algorithm used please check libxdiff
* website.
*
* @param string $old_file Path to the first file. This file acts as "old" file.
* @param string $new_file Path to the second file. This file acts as "new" file.
* @param string $dest Path of the resulting patch file. Resulting file contains differences
* between "old" and "new" files. It is in binary format and is human-unreadable.
* @throws XdiffException
*
*/
function xdiff_file_rabdiff(string $old_file, string $new_file, string $dest): void
{
error_clear_last();
$safeResult = \xdiff_file_rabdiff($old_file, $new_file, $dest);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
}
/**
* Patches a string str with a binary patch.
* This function accepts patches created both via xdiff_string_bdiff
* and xdiff_string_rabdiff functions or their file counterparts.
*
* @param string $str The original binary string.
* @param string $patch The binary patch string.
* @return string Returns the patched string.
* @throws XdiffException
*
*/
function xdiff_string_bpatch(string $str, string $patch): string
{
error_clear_last();
$safeResult = \xdiff_string_bpatch($str, $patch);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
return $safeResult;
}
/**
* Patches a string str with a binary patch.
* This function accepts patches created both via xdiff_string_bdiff
* and xdiff_string_rabdiff functions or their file counterparts.
*
* Starting with version 1.5.0 this function is an alias of xdiff_string_bpatch.
*
* @param string $str The original binary string.
* @param string $patch The binary patch string.
* @return string Returns the patched string.
* @throws XdiffException
*
*/
function xdiff_string_patch_binary(string $str, string $patch): string
{
error_clear_last();
$safeResult = \xdiff_string_patch_binary($str, $patch);
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
return $safeResult;
}
/**
* Patches a str string with an unified patch in patch parameter
* and returns the result. patch has to be an unified diff created by
* xdiff_file_diff/xdiff_string_diff function.
* An optional flags parameter specifies mode of operation. Any
* rejected parts of the patch will be stored inside error variable if
* it is provided.
*
* @param string $str The original string.
* @param string $patch The unified patch string. It has to be created using xdiff_string_diff,
* xdiff_file_diff functions or compatible tools.
* @param int $flags flags can be either
* XDIFF_PATCH_NORMAL (default mode, normal patch)
* or XDIFF_PATCH_REVERSE (reversed patch).
*
* Starting from version 1.5.0, you can also use binary OR to enable
* XDIFF_PATCH_IGNORESPACE flag.
* @param null|string $error If provided then rejected parts are stored inside this variable.
* @return string Returns the patched string.
* @throws XdiffException
*
*/
function xdiff_string_patch(string $str, string $patch, ?int $flags = null, ?string &$error = null): string
{
error_clear_last();
if ($error !== null) {
$safeResult = \xdiff_string_patch($str, $patch, $flags, $error);
} elseif ($flags !== null) {
$safeResult = \xdiff_string_patch($str, $patch, $flags);
} else {
$safeResult = \xdiff_string_patch($str, $patch);
}
if ($safeResult === false) {
throw XdiffException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/xml.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,22 @@
<?php
namespace Safe;
use Safe\Exceptions\XmlrpcException;
/**
* Sets xmlrpc type, base64 or datetime, for a PHP string value.
*
* @param \DateTime|string $value Value to set the type
* @param string $type 'base64' or 'datetime'
* @throws XmlrpcException
*
*/
function xmlrpc_set_type(&$value, string $type): void
{
error_clear_last();
$safeResult = \xmlrpc_set_type($value, $type);
if ($safeResult === false) {
throw XmlrpcException::createFromPhpError();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace Safe;
use Safe\Exceptions\YamlException;
/**
* Convert all or part of a YAML document stream read from a file to a PHP variable.
*
* @param string $filename Path to the file.
* @param int $pos Document to extract from stream (-1 for all
* documents, 0 for first document, ...).
* @param int|null $ndocs If ndocs is provided, then it is filled with the
* number of documents found in stream.
* @param array|null $callbacks Content handlers for YAML nodes. Associative array of YAML
* tag =&gt; callable mappings. See
* parse callbacks for more
* details.
* @return mixed Returns the value encoded in filename in appropriate
* PHP type. If pos is -1 an
* array will be returned with one entry for each document found
* in the stream.
* @throws YamlException
*
*/
function yaml_parse_file(string $filename, int $pos = 0, ?int &$ndocs = null, ?array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$safeResult = \yaml_parse_file($filename, $pos, $ndocs, $callbacks);
} else {
$safeResult = \yaml_parse_file($filename, $pos, $ndocs);
}
if ($safeResult === false) {
throw YamlException::createFromPhpError();
}
return $safeResult;
}
/**
* Convert all or part of a YAML document stream read from a URL to a PHP variable.
*
* @param string $url url should be of the form "scheme://...". PHP
* will search for a protocol handler (also known as a wrapper) for that
* scheme. If no wrappers for that protocol are registered, PHP will emit
* a notice to help you track potential problems in your script and then
* continue as though filename specifies a regular file.
* @param int $pos Document to extract from stream (-1 for all
* documents, 0 for first document, ...).
* @param int|null $ndocs If ndocs is provided, then it is filled with the
* number of documents found in stream.
* @param array|null $callbacks Content handlers for YAML nodes. Associative array of YAML
* tag =&gt; callable mappings. See
* parse callbacks for more details.
* @return mixed Returns the value encoded in url in appropriate
* PHP type. If pos is
* -1 an array will be returned with one entry
* for each document found in the stream.
* @throws YamlException
*
*/
function yaml_parse_url(string $url, int $pos = 0, ?int &$ndocs = null, ?array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$safeResult = \yaml_parse_url($url, $pos, $ndocs, $callbacks);
} else {
$safeResult = \yaml_parse_url($url, $pos, $ndocs);
}
if ($safeResult === false) {
throw YamlException::createFromPhpError();
}
return $safeResult;
}
/**
* Convert all or part of a YAML document stream to a PHP variable.
*
* @param string $input The string to parse as a YAML document stream.
* @param int $pos Document to extract from stream (-1 for all
* documents, 0 for first document, ...).
* @param int|null $ndocs If ndocs is provided, then it is filled with the
* number of documents found in stream.
* @param array|null $callbacks Content handlers for YAML nodes. Associative array of YAML
* tag =&gt; callable mappings. See
* parse callbacks for more
* details.
* @return mixed Returns the value encoded in input in appropriate
* PHP type. If pos is -1 an
* array will be returned with one entry for each document found
* in the stream.
* @throws YamlException
*
*/
function yaml_parse(string $input, int $pos = 0, ?int &$ndocs = null, ?array $callbacks = null)
{
error_clear_last();
if ($callbacks !== null) {
$safeResult = \yaml_parse($input, $pos, $ndocs, $callbacks);
} else {
$safeResult = \yaml_parse($input, $pos, $ndocs);
}
if ($safeResult === false) {
throw YamlException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,438 @@
<?php
namespace Safe;
use Safe\Exceptions\YazException;
/**
* This function invokes a CCL parser. It converts a given CCL FIND query to
* an RPN query which may be passed to the yaz_search
* function to perform a search.
*
* To define a set of valid CCL fields call yaz_ccl_conf
* prior to this function.
*
* @param resource $id The connection resource returned by yaz_connect.
* @param string $query The CCL FIND query.
* @param array|null $result If the function was executed successfully, this will be an array
* containing the valid RPN query under the key rpn.
*
* Upon failure, three indexes are set in this array to indicate the cause
* of failure:
*
*
*
* errorcode - the CCL error code (integer)
*
*
*
*
* errorstring - the CCL error string
*
*
*
*
* errorpos - approximate position in query of failure
* (integer is character position)
*
*
*
*
* errorcode - the CCL error code (integer)
*
* errorstring - the CCL error string
*
* errorpos - approximate position in query of failure
* (integer is character position)
* @throws YazException
*
*/
function yaz_ccl_parse($id, string $query, ?array &$result): void
{
error_clear_last();
$safeResult = \yaz_ccl_parse($id, $query, $result);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
}
/**
* Closes the connection given by parameter id.
*
* @param resource $id The connection resource returned by yaz_connect.
* @throws YazException
*
*/
function yaz_close($id): void
{
error_clear_last();
$safeResult = \yaz_close($id);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
}
/**
* This function returns a connection resource on success, zero on
* failure.
*
* yaz_connect prepares for a connection to a
* Z39.50 server.
* This function is non-blocking and does not attempt to establish
* a connection - it merely prepares a connect to be performed later when
* yaz_wait is called.
*
* @param string $zurl A string that takes the form host[:port][/database].
* If port is omitted, port 210 is used. If database is omitted
* Default is used.
* @param mixed $options If given as a string, it is treated as the Z39.50 V2 authentication
* string (OpenAuth).
*
* If given as an array, the contents of the array serves as options.
*
*
* user
*
*
* Username for authentication.
*
*
*
*
* group
*
*
* Group for authentication.
*
*
*
*
* password
*
*
* Password for authentication.
*
*
*
*
* cookie
*
*
* Cookie for session (YAZ proxy).
*
*
*
*
* proxy
*
*
* Proxy for connection (YAZ proxy).
*
*
*
*
* persistent
*
*
* A boolean. If TRUE the connection is persistent; If FALSE the
* connection is not persistent. By default connections are persistent.
*
*
*
* If you open a persistent connection, you won't be able to close
* it later with yaz_close.
*
*
*
*
*
* piggyback
*
*
* A boolean. If TRUE piggyback is enabled for searches; If FALSE
* piggyback is disabled. By default piggyback is enabled.
*
*
* Enabling piggyback is more efficient and usually saves a
* network-round-trip for first time fetches of records. However, a
* few Z39.50 servers do not support piggyback or they ignore element
* set names. For those, piggyback should be disabled.
*
*
*
*
* charset
*
*
* A string that specifies character set to be used in Z39.50
* language and character set negotiation. Use strings such as:
* ISO-8859-1, UTF-8,
* UTF-16.
*
*
* Most Z39.50 servers do not support this feature (and thus, this is
* ignored). Many servers use the ISO-8859-1 encoding for queries and
* messages. MARC21/USMARC records are not affected by this setting.
*
*
*
*
*
* preferredMessageSize
*
*
* An integer that specifies the maximum byte size of all records
* to be returned by a target during retrieval. See the
* Z39.50 standard for more
* information.
*
*
*
* This option is supported in PECL YAZ 1.0.5 or later.
*
*
*
*
*
*
* maximumRecordSize
*
*
* An integer that specifies the maximum byte size of a single record
* to be returned by a target during retrieval. This
* entity is referred to as Exceptional-record-size in the
* Z39.50 standard.
*
*
*
* This option is supported in PECL YAZ 1.0.5 or later.
*
*
*
*
*
*
*
* Username for authentication.
*
* Group for authentication.
*
* Password for authentication.
*
* Cookie for session (YAZ proxy).
*
* Proxy for connection (YAZ proxy).
*
* A boolean. If TRUE the connection is persistent; If FALSE the
* connection is not persistent. By default connections are persistent.
*
* If you open a persistent connection, you won't be able to close
* it later with yaz_close.
*
* A boolean. If TRUE piggyback is enabled for searches; If FALSE
* piggyback is disabled. By default piggyback is enabled.
*
* Enabling piggyback is more efficient and usually saves a
* network-round-trip for first time fetches of records. However, a
* few Z39.50 servers do not support piggyback or they ignore element
* set names. For those, piggyback should be disabled.
*
* A string that specifies character set to be used in Z39.50
* language and character set negotiation. Use strings such as:
* ISO-8859-1, UTF-8,
* UTF-16.
*
* Most Z39.50 servers do not support this feature (and thus, this is
* ignored). Many servers use the ISO-8859-1 encoding for queries and
* messages. MARC21/USMARC records are not affected by this setting.
*
* An integer that specifies the maximum byte size of all records
* to be returned by a target during retrieval. See the
* Z39.50 standard for more
* information.
*
* This option is supported in PECL YAZ 1.0.5 or later.
*
* An integer that specifies the maximum byte size of a single record
* to be returned by a target during retrieval. This
* entity is referred to as Exceptional-record-size in the
* Z39.50 standard.
*
* This option is supported in PECL YAZ 1.0.5 or later.
* @return mixed A connection resource on success, FALSE on error.
* @throws YazException
*
*/
function yaz_connect(string $zurl, $options = null)
{
error_clear_last();
if ($options !== null) {
$safeResult = \yaz_connect($zurl, $options);
} else {
$safeResult = \yaz_connect($zurl);
}
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
return $safeResult;
}
/**
* This function allows you to change databases within a session by
* specifying one or more databases to be used in search, retrieval, etc.
* - overriding databases specified in call to
* yaz_connect.
*
* @param resource $id The connection resource returned by yaz_connect.
* @param string $databases A string containing one or more databases. Multiple databases are
* separated by a plus sign +.
* @throws YazException
*
*/
function yaz_database($id, string $databases): void
{
error_clear_last();
$safeResult = \yaz_database($id, $databases);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
}
/**
* This function sets the element set name for retrieval.
*
* Call this function before yaz_search or
* yaz_present to specify the element set name for
* records to be retrieved.
*
* @param resource $id The connection resource returned by yaz_connect.
* @param string $elementset Most servers support F (for full records) and
* B (for brief records).
* @throws YazException
*
*/
function yaz_element($id, string $elementset): void
{
error_clear_last();
$safeResult = \yaz_element($id, $elementset);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
}
/**
* This function prepares for retrieval of records after a successful search.
*
* The yaz_range function should be called prior to this
* function to specify the range of records to be retrieved.
*
* @param resource $id The connection resource returned by yaz_connect.
* @throws YazException
*
*/
function yaz_present($id): void
{
error_clear_last();
$safeResult = \yaz_present($id);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
}
/**
* yaz_search prepares for a search on the given
* connection.
*
* Like yaz_connect this function is non-blocking and
* only prepares for a search to be executed later when
* yaz_wait is called.
*
* @param resource $id The connection resource returned by yaz_connect.
* @param string $type This parameter represents the query type - only "rpn"
* is supported now in which case the third argument specifies a Type-1
* query in prefix query notation.
* @param string $query The RPN query is a textual representation of the Type-1 query as
* defined by the Z39.50 standard. However, in the text representation
* as used by YAZ a prefix notation is used, that is the operator
* precedes the operands. The query string is a sequence of tokens where
* white space is ignored unless surrounded by double quotes. Tokens beginning
* with an at-character (@) are considered operators,
* otherwise they are treated as search terms.
*
* You can find information about attributes at the
* Z39.50 Maintenance Agency
* site.
*
* If you would like to use a more friendly notation,
* use the CCL parser - functions yaz_ccl_conf and
* yaz_ccl_parse.
* @throws YazException
*
*/
function yaz_search($id, string $type, string $query): void
{
error_clear_last();
$safeResult = \yaz_search($id, $type, $query);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
}
/**
* This function carries out networked (blocked) activity for outstanding
* requests which have been prepared by the functions
* yaz_connect, yaz_search,
* yaz_present, yaz_scan and
* yaz_itemorder.
*
* yaz_wait returns when all servers have either
* completed all requests or aborted (in case of errors).
*
* @param array $options An associative array of options:
*
*
* timeout
*
*
* Sets timeout in seconds. If a server has not responded within the
* timeout it is considered dead and yaz_wait
* returns. The default value for timeout is 15 seconds.
*
*
*
*
* event
*
*
* A boolean.
*
*
*
*
*
* Sets timeout in seconds. If a server has not responded within the
* timeout it is considered dead and yaz_wait
* returns. The default value for timeout is 15 seconds.
*
* A boolean.
* @return mixed Returns TRUE on success.
* In event mode, returns resource.
* @throws YazException
*
*/
function yaz_wait(?array &$options = null)
{
error_clear_last();
$safeResult = \yaz_wait($options);
if ($safeResult === false) {
throw YazException::createFromPhpError();
}
return $safeResult;
}

View File

@@ -0,0 +1,144 @@
<?php
namespace Safe;
use Safe\Exceptions\ZipException;
/**
* Closes the specified directory entry.
*
* @param resource $zip_entry A directory entry previously opened zip_entry_open.
* @throws ZipException
*
*/
function zip_entry_close($zip_entry): void
{
error_clear_last();
$safeResult = \zip_entry_close($zip_entry);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
}
/**
* Returns the compressed size of the specified directory entry.
*
* @param resource $zip_entry A directory entry returned by zip_read.
* @return int The compressed size.
* @throws ZipException
*
*/
function zip_entry_compressedsize($zip_entry): int
{
error_clear_last();
$safeResult = \zip_entry_compressedsize($zip_entry);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the compression method of the directory entry specified
* by zip_entry.
*
* @param resource $zip_entry A directory entry returned by zip_read.
* @return string The compression method.
* @throws ZipException
*
*/
function zip_entry_compressionmethod($zip_entry): string
{
error_clear_last();
$safeResult = \zip_entry_compressionmethod($zip_entry);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the actual size of the specified directory entry.
*
* @param resource $zip_entry A directory entry returned by zip_read.
* @return int The size of the directory entry.
* @throws ZipException
*
*/
function zip_entry_filesize($zip_entry): int
{
error_clear_last();
$safeResult = \zip_entry_filesize($zip_entry);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the name of the specified directory entry.
*
* @param resource $zip_entry A directory entry returned by zip_read.
* @return string The name of the directory entry.
* @throws ZipException
*
*/
function zip_entry_name($zip_entry): string
{
error_clear_last();
$safeResult = \zip_entry_name($zip_entry);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
return $safeResult;
}
/**
* Opens a directory entry in a zip file for reading.
*
* @param resource $zip_dp A valid resource handle returned by zip_open.
* @param resource $zip_entry A directory entry returned by zip_read.
* @param string $mode Any of the modes specified in the documentation of
* fopen.
*
* Currently, mode is ignored and is always
* "rb". This is due to the fact that zip support
* in PHP is read only access.
* @throws ZipException
*
*/
function zip_entry_open($zip_dp, $zip_entry, string $mode = "rb"): void
{
error_clear_last();
$safeResult = \zip_entry_open($zip_dp, $zip_entry, $mode);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
}
/**
* Reads from an open directory entry.
*
* @param resource $zip_entry A directory entry returned by zip_read.
* @param int $len The number of bytes to return.
*
* This should be the uncompressed length you wish to read.
* @return string Returns the data read, empty string on end of a file.
* @throws ZipException
*
*/
function zip_entry_read($zip_entry, int $len = 1024): string
{
error_clear_last();
$safeResult = \zip_entry_read($zip_entry, $len);
if ($safeResult === false) {
throw ZipException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.4/zlib.php vendored Normal file → Executable file
View File