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

View File

@@ -0,0 +1,199 @@
<?php
namespace Safe;
use Safe\Exceptions\ApacheException;
/**
* Fetch the Apache version.
*
* @return string Returns the Apache version on success.
* @throws ApacheException
*
*/
function apache_get_version(): string
{
error_clear_last();
$safeResult = \apache_get_version();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* Retrieve an Apache environment variable specified by
* variable.
*
* @param string $variable The Apache environment variable
* @param bool $walk_to_top Whether to get the top-level variable available to all Apache layers.
* @return string The value of the Apache environment variable on success
* @throws ApacheException
*
*/
function apache_getenv(string $variable, bool $walk_to_top = false): string
{
error_clear_last();
$safeResult = \apache_getenv($variable, $walk_to_top);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* This performs a partial request for a URI. It goes just far
* enough to obtain all the important information about the given
* resource.
*
* @param string $filename The filename (URI) that's being requested.
* @return object An object of related URI information. The properties of
* this object are:
*
*
* status
* the_request
* status_line
* method
* content_type
* handler
* uri
* filename
* path_info
* args
* boundary
* no_cache
* no_local_copy
* allowed
* send_bodyct
* bytes_sent
* byterange
* clength
* unparsed_uri
* mtime
* request_time
*
*
* Returns FALSE on failure.
* @throws ApacheException
*
*/
function apache_lookup_uri(string $filename): object
{
error_clear_last();
$safeResult = \apache_lookup_uri($filename);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* Fetches all HTTP request headers from the current request. Works in the
* Apache, FastCGI, CLI, and FPM webservers.
*
* @return array An associative array of all the HTTP headers in the current request.
* @throws ApacheException
*
*/
function apache_request_headers(): array
{
error_clear_last();
$safeResult = \apache_request_headers();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* Fetch all HTTP response headers. Works in the
* Apache, FastCGI, CLI, and FPM webservers.
*
* @return array An array of all Apache response headers on success.
* @throws ApacheException
*
*/
function apache_response_headers(): array
{
error_clear_last();
$safeResult = \apache_response_headers();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* apache_setenv sets the value of the Apache
* environment variable specified by
* variable.
*
* @param string $variable The environment variable that's being set.
* @param string $value The new variable value.
* @param bool $walk_to_top Whether to set the top-level variable available to all Apache layers.
* @throws ApacheException
*
*/
function apache_setenv(string $variable, string $value, bool $walk_to_top = false): void
{
error_clear_last();
$safeResult = \apache_setenv($variable, $value, $walk_to_top);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
}
/**
* Fetches all HTTP headers from the current request.
*
* This function is an alias for apache_request_headers.
* Please read the apache_request_headers
* documentation for more information on how this function works.
*
* @return array An associative array of all the HTTP headers in the current request.
* @throws ApacheException
*
*/
function getallheaders(): array
{
error_clear_last();
$safeResult = \getallheaders();
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
return $safeResult;
}
/**
* virtual is an Apache-specific function which
* is similar to &lt;!--#include virtual...--&gt; in
* mod_include.
* It performs an Apache sub-request. It is useful for including
* CGI scripts or .shtml files, or anything else that you would
* parse through Apache. Note that for a CGI script, the script
* must generate valid CGI headers. At the minimum that means it
* must generate a Content-Type header.
*
* To run the sub-request, all buffers are terminated and flushed to the
* browser, pending headers are sent too.
*
* @param string $uri The file that the virtual command will be performed on.
* @throws ApacheException
*
*/
function virtual(string $uri): void
{
error_clear_last();
$safeResult = \virtual($uri);
if ($safeResult === false) {
throw ApacheException::createFromPhpError();
}
}

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.2/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,25 @@
<?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.2/curl.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.2/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

0
vendor/thecodingmachine/safe/generated/8.2/errorfunc.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.2/exec.php vendored Normal file → Executable file
View File

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;
}

0
vendor/thecodingmachine/safe/generated/8.2/filesystem.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,81 @@
<?php
namespace Safe;
use Safe\Exceptions\FilterException;
/**
* This function is useful for retrieving many values without
* repetitively calling filter_input.
*
* @param int $type One of INPUT_GET, INPUT_POST,
* INPUT_COOKIE, INPUT_SERVER, or
* INPUT_ENV.
* @param array|int $options An array defining the arguments. A valid key is a string
* containing a variable name and a valid value is either a filter type, or an array
* optionally specifying the filter, flags and options. If the value is an
* array, valid keys are filter which specifies the
* filter type,
* flags which specifies any flags that apply to the
* filter, and options which specifies any options that
* apply to the filter. See the example below for a better understanding.
*
* This parameter can be also an integer holding a filter constant. Then all values in the
* input array are filtered by this filter.
* @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.
* If the input array designated by type is not populated,
* the function returns NULL if the FILTER_NULL_ON_FAILURE
* flag is not given, or FALSE otherwise. For other failures, FALSE is returned.
*
* An array value will be FALSE if the filter fails, or NULL if
* the variable is not set. Or if the flag FILTER_NULL_ON_FAILURE
* is used, it returns FALSE if the variable is not set and NULL if the filter
* fails. If the add_empty parameter is FALSE, no array
* element will be added for unset variables.
* @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;
}
/**
* This function is useful for retrieving many values without
* repetitively calling filter_var.
*
* @param array $array An array with string keys containing the data to filter.
* @param mixed $options An array defining the arguments. A valid key is a string
* containing a variable name and a valid value is either a
* filter type, or an
* array optionally specifying the filter, flags and options.
* If the value is an array, valid keys are filter
* which specifies the filter type,
* flags which specifies any flags that apply to the
* filter, and options which specifies any options that
* apply to the filter. See the example below for a better understanding.
*
* This parameter can be also an integer holding a filter constant. Then all values in the
* input array are filtered by this filter.
* @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;
}

0
vendor/thecodingmachine/safe/generated/8.2/fpm.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,568 @@
<?php
namespace Safe;
use Safe\Exceptions\FtpException;
/**
* Sends an ALLO command to the remote FTP server to
* allocate space for a file to be uploaded.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param int $size The number of bytes to allocate.
* @param null|string $response A textual representation of the servers response will be returned by
* reference in response if a variable is provided.
* @throws FtpException
*
*/
function ftp_alloc(\FTP\Connection $ftp, int $size, ?string &$response = null): void
{
error_clear_last();
$safeResult = \ftp_alloc($ftp, $size, $response);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
*
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $remote_filename
* @param string $local_filename
* @param FTP_ASCII|FTP_BINARY $mode
* @throws FtpException
*
*/
function ftp_append(\FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): void
{
error_clear_last();
$safeResult = \ftp_append($ftp, $remote_filename, $local_filename, $mode);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Changes to the parent directory.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @throws FtpException
*
*/
function ftp_cdup(\FTP\Connection $ftp): void
{
error_clear_last();
$safeResult = \ftp_cdup($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Changes the current directory to the specified one.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $directory The target directory.
* @throws FtpException
*
*/
function ftp_chdir(\FTP\Connection $ftp, string $directory): void
{
error_clear_last();
$safeResult = \ftp_chdir($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Sets the permissions on the specified remote file to
* permissions.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param int $permissions The new permissions, given as an octal value.
* @param string $filename The remote file.
* @return int Returns the new file permissions on success.
* @throws FtpException
*
*/
function ftp_chmod(\FTP\Connection $ftp, int $permissions, string $filename): int
{
error_clear_last();
$safeResult = \ftp_chmod($ftp, $permissions, $filename);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_close closes the given link identifier
* and releases the resource.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @throws FtpException
*
*/
function ftp_close(\FTP\Connection $ftp): void
{
error_clear_last();
$safeResult = \ftp_close($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_connect opens an FTP connection to the
* specified hostname.
*
* @param string $hostname The FTP server address. This parameter shouldn't have any trailing
* slashes and shouldn't be prefixed with ftp://.
* @param int $port This parameter specifies an alternate port to connect to. If it is
* omitted or set to zero, then the default FTP port, 21, will be used.
* @param int $timeout This parameter specifies the timeout in seconds for all subsequent network operations.
* If omitted, the default value is 90 seconds. The timeout can be changed and
* queried at any time with ftp_set_option and
* ftp_get_option.
* @return \FTP\Connection Returns an FTP\Connection instance on success.
* @throws FtpException
*
*/
function ftp_connect(string $hostname, int $port = 21, int $timeout = 90): \FTP\Connection
{
error_clear_last();
$safeResult = \ftp_connect($hostname, $port, $timeout);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_delete deletes the file specified by
* filename from the FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $filename The file to delete.
* @throws FtpException
*
*/
function ftp_delete(\FTP\Connection $ftp, string $filename): void
{
error_clear_last();
$safeResult = \ftp_delete($ftp, $filename);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_fget retrieves remote_filename
* from the FTP server, and writes it to the given file pointer.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param resource $stream An open file pointer in which we store the data.
* @param string $remote_filename The remote file path.
* @param FTP_ASCII|FTP_BINARY $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start downloading from.
* @throws FtpException
*
*/
function ftp_fget(\FTP\Connection $ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_fget($ftp, $stream, $remote_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_fput uploads the data from a file pointer
* to a remote file on the FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $remote_filename The remote file path.
* @param resource $stream An open file pointer on the local file. Reading stops at end of file.
* @param FTP_ASCII|FTP_BINARY $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start uploading to.
* @throws FtpException
*
*/
function ftp_fput(\FTP\Connection $ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_fput($ftp, $remote_filename, $stream, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_get retrieves a remote file from the FTP server,
* and saves it into a local file.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $local_filename The local file path (will be overwritten if the file already exists).
* @param string $remote_filename The remote file path.
* @param FTP_ASCII|FTP_BINARY $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start downloading from.
* @throws FtpException
*
*/
function ftp_get(\FTP\Connection $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_get($ftp, $local_filename, $remote_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Logs in to the given FTP connection.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $username The username (USER).
* @param string $password The password (PASS).
* @throws FtpException
*
*/
function ftp_login(\FTP\Connection $ftp, string $username, string $password): void
{
error_clear_last();
$safeResult = \ftp_login($ftp, $username, $password);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Creates the specified directory on the FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $directory The name of the directory that will be created.
* @return string Returns the newly created directory name on success.
* @throws FtpException
*
*/
function ftp_mkdir(\FTP\Connection $ftp, string $directory): string
{
error_clear_last();
$safeResult = \ftp_mkdir($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $directory The directory to be listed.
* @return array Returns an array of arrays with file infos from the specified directory on success.
* @throws FtpException
*
*/
function ftp_mlsd(\FTP\Connection $ftp, string $directory): array
{
error_clear_last();
$safeResult = \ftp_mlsd($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_nb_put stores a local file on the FTP server.
*
* The difference between this function and the ftp_put
* is that this function uploads the file asynchronously, so your program can
* perform other operations while the file is being uploaded.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $remote_filename The remote file path.
* @param string $local_filename The local file path.
* @param FTP_ASCII|FTP_BINARY $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start uploading to.
* @return int Returns FTP_FAILED or FTP_FINISHED
* or FTP_MOREDATA to open the local file.
* @throws FtpException
*
*/
function ftp_nb_put(\FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int
{
error_clear_last();
$safeResult = \ftp_nb_put($ftp, $remote_filename, $local_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $directory The directory to be listed. This parameter can also include arguments, eg.
* ftp_nlist($ftp, "-la /your/dir");.
* Note that this parameter isn't escaped so there may be some issues with
* filenames containing spaces and other characters.
* @return array Returns an array of filenames from the specified directory on success.
* @throws FtpException
*
*/
function ftp_nlist(\FTP\Connection $ftp, string $directory): array
{
error_clear_last();
$safeResult = \ftp_nlist($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_pasv turns on or off passive mode. In
* passive mode, data connections are initiated by the client,
* rather than by the server.
* It may be needed if the client is behind firewall.
*
* Please note that ftp_pasv can only be called after a
* successful login or otherwise it will fail.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param bool $enable If TRUE, the passive mode is turned on, else it's turned off.
* @throws FtpException
*
*/
function ftp_pasv(\FTP\Connection $ftp, bool $enable): void
{
error_clear_last();
$safeResult = \ftp_pasv($ftp, $enable);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_put stores a local file on the FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $remote_filename The remote file path.
* @param string $local_filename The local file path.
* @param FTP_ASCII|FTP_BINARY $mode The transfer mode. Must be either FTP_ASCII or
* FTP_BINARY.
* @param int $offset The position in the remote file to start uploading to.
* @throws FtpException
*
*/
function ftp_put(\FTP\Connection $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): void
{
error_clear_last();
$safeResult = \ftp_put($ftp, $remote_filename, $local_filename, $mode, $offset);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
*
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @return string Returns the current directory name.
* @throws FtpException
*
*/
function ftp_pwd(\FTP\Connection $ftp): string
{
error_clear_last();
$safeResult = \ftp_pwd($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* Sends an arbitrary command to the FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $command The command to execute.
* @return array Returns the server's response as an array of strings.
* No parsing is performed on the response string, nor does
* ftp_raw determine if the command succeeded.
* @throws FtpException
*
*/
function ftp_raw(\FTP\Connection $ftp, string $command): array
{
error_clear_last();
$safeResult = \ftp_raw($ftp, $command);
if ($safeResult === null) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_rename renames a file or a directory on the FTP
* server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $from The old file/directory name.
* @param string $to The new name.
* @throws FtpException
*
*/
function ftp_rename(\FTP\Connection $ftp, string $from, string $to): void
{
error_clear_last();
$safeResult = \ftp_rename($ftp, $from, $to);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* Removes the specified directory on the FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $directory The directory to delete. This must be either an absolute or relative
* path to an empty directory.
* @throws FtpException
*
*/
function ftp_rmdir(\FTP\Connection $ftp, string $directory): void
{
error_clear_last();
$safeResult = \ftp_rmdir($ftp, $directory);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_site sends the given SITE
* command to the FTP server.
*
* SITE commands are not standardized, and vary from server
* to server. They are useful for handling such things as file permissions and
* group membership.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $command The SITE command. Note that this parameter isn't escaped so there may
* be some issues with filenames containing spaces and other characters.
* @throws FtpException
*
*/
function ftp_site(\FTP\Connection $ftp, string $command): void
{
error_clear_last();
$safeResult = \ftp_site($ftp, $command);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
}
/**
* ftp_size returns the size of the given file in
* bytes.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @param string $filename The remote file.
* @return int Returns the file size on success.
* @throws FtpException
*
*/
function ftp_size(\FTP\Connection $ftp, string $filename): int
{
error_clear_last();
$safeResult = \ftp_size($ftp, $filename);
if ($safeResult === -1) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* ftp_ssl_connect opens an explicit SSL-FTP connection to the
* specified hostname. That implies that
* ftp_ssl_connect will succeed even if the server is not
* configured for SSL-FTP, or its certificate is invalid. Only when
* ftp_login is called, the client will send the
* appropriate AUTH FTP command, so ftp_login will fail in
* the mentioned cases.
*
* @param string $hostname The FTP server address. This parameter shouldn't have any trailing
* slashes and shouldn't be prefixed with ftp://.
* @param int $port This parameter specifies an alternate port to connect to. If it is
* omitted or set to zero, then the default FTP port, 21, will be used.
* @param int $timeout This parameter specifies the timeout for all subsequent network operations.
* If omitted, the default value is 90 seconds. The timeout can be changed and
* queried at any time with ftp_set_option and
* ftp_get_option.
* @return \FTP\Connection Returns an FTP\Connection instance on success.
* @throws FtpException
*
*/
function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90): \FTP\Connection
{
error_clear_last();
$safeResult = \ftp_ssl_connect($hostname, $port, $timeout);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the system type identifier of the remote FTP server.
*
* @param \FTP\Connection $ftp An FTP\Connection instance.
* @return string Returns the remote system type.
* @throws FtpException
*
*/
function ftp_systype(\FTP\Connection $ftp): string
{
error_clear_last();
$safeResult = \ftp_systype($ftp);
if ($safeResult === false) {
throw FtpException::createFromPhpError();
}
return $safeResult;
}

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.2/functionsList.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,27 @@
<?php
namespace Safe;
use Safe\Exceptions\GettextException;
/**
* The bindtextdomain function sets or gets the path
* for a domain.
*
* @param string $domain The domain.
* @param string $directory The directory path.
* An empty string means the current directory.
* If NULL, the currently set directory is returned.
* @return string The full pathname for the domain currently being set.
* @throws GettextException
*
*/
function bindtextdomain(string $domain, string $directory): string
{
error_clear_last();
$safeResult = \bindtextdomain($domain, $directory);
if ($safeResult === false) {
throw GettextException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.2/gmp.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.2/gnupg.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.2/hash.php vendored Normal file → Executable file
View File

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();
}
}

File diff suppressed because it is too large Load Diff

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 byte.
*
* @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.2/image.php vendored Normal file → Executable file
View File

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

View File

@@ -0,0 +1,717 @@
<?php
namespace Safe;
use Safe\Exceptions\InfoException;
/**
* Set the various assert control options or just query
* their current settings.
*
* @param int $what
* Assert Options
*
*
*
* Option
* INI Setting
* Default value
* Description
*
*
*
*
* ASSERT_ACTIVE
* assert.active
* 1
* enable assert evaluation
*
*
* ASSERT_WARNING
* assert.warning
* 1
* issue a PHP warning for each failed assertion
*
*
* ASSERT_BAIL
* assert.bail
* 0
* terminate execution on failed assertions
*
*
* ASSERT_QUIET_EVAL
* assert.quiet_eval
* 0
*
* disable error_reporting during assertion expression
* evaluation
*
*
*
* ASSERT_CALLBACK
* assert.callback
* (NULL)
* Callback to call on failed assertions
*
*
*
*
* @param mixed $value An optional new value for the option.
*
* The callback function set via ASSERT_CALLBACK or assert.callback should
* have the following signature:
*
* voidassert_callback
* stringfile
* intline
* stringassertion
* stringdescription
*
*
*
* file
*
*
* The file where assert has been called.
*
*
*
*
* line
*
*
* The line where assert has been called.
*
*
*
*
* assertion
*
*
* The assertion that has been passed to assert,
* converted to a string.
*
*
*
*
* description
*
*
* The description that has been passed to assert.
*
*
*
*
* @return mixed Returns the original setting of any options.
* @throws InfoException
*
*/
function assert_options(int $what, $value = null)
{
error_clear_last();
if ($value !== null) {
$safeResult = \assert_options($what, $value);
} else {
$safeResult = \assert_options($what);
}
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Sets the process title visible in tools such as top and
* ps. This function is available only in
* CLI mode.
*
* @param string $title The new title.
* @throws InfoException
*
*/
function cli_set_process_title(string $title): void
{
error_clear_last();
$safeResult = \cli_set_process_title($title);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
}
/**
* Loads the PHP extension given by the parameter
* extension_filename.
*
* Use extension_loaded to test whether a given
* extension is already available or not. This works on both built-in
* extensions and dynamically loaded ones (either through php.ini or
* dl).
*
* @param string $extension_filename This parameter is only the filename of the
* extension to load which also depends on your platform. For example,
* the sockets extension (if compiled
* as a shared module, not the default!) would be called
* sockets.so on Unix platforms whereas it is called
* php_sockets.dll on the Windows platform.
*
* The directory where the extension is loaded from depends on your
* platform:
*
* Windows - If not explicitly set in the php.ini, the extension is
* loaded from C:\php5\ by default.
*
* Unix - If not explicitly set in the php.ini, the default extension
* directory depends on
*
*
*
* whether PHP has been built with --enable-debug
* or not
*
*
*
*
* whether PHP has been built with ZTS (Zend Thread Safety)
* support or not
*
*
*
*
* the current internal ZEND_MODULE_API_NO (Zend
* internal module API number, which is basically the date on which a
* major module API change happened, e.g. 20010901)
*
*
*
* Taking into account the above, the directory then defaults to
* &lt;install-dir&gt;/lib/php/extensions/ &lt;debug-or-not&gt;-&lt;zts-or-not&gt;-ZEND_MODULE_API_NO,
* e.g.
* /usr/local/php/lib/php/extensions/debug-non-zts-20010901
* or
* /usr/local/php/lib/php/extensions/no-debug-zts-20010901.
* @throws InfoException
*
*/
function dl(string $extension_filename): void
{
error_clear_last();
$safeResult = \dl($extension_filename);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
}
/**
* Gets the value of a PHP configuration option.
*
* This function will not return configuration information set when the PHP
* was compiled, or read from an Apache configuration file.
*
* To check whether the system is using a configuration file, try retrieving the
* value of the cfg_file_path configuration setting. If this is available, a
* configuration file is being used.
*
* @param string $option The configuration option name.
* @return mixed Returns the current value of the PHP configuration variable specified by
* option, or FALSE if an error occurs.
* @throws InfoException
*
*/
function get_cfg_var(string $option)
{
error_clear_last();
$safeResult = \get_cfg_var($option);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @return string Returns the path, as a string.
* @throws InfoException
*
*/
function get_include_path(): string
{
error_clear_last();
$safeResult = \get_include_path();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets the time of the last modification of the main script of execution.
*
* If you're interested in getting the last modification time
* of a different file, consider using filemtime.
*
* @return int Returns the time of the last modification of the current
* page. The value returned is a Unix timestamp, suitable for
* feeding to date.
* @throws InfoException
*
*/
function getlastmod(): int
{
error_clear_last();
$safeResult = \getlastmod();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @return int Returns the group ID of the current script.
* @throws InfoException
*
*/
function getmygid(): int
{
error_clear_last();
$safeResult = \getmygid();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets the inode of the current script.
*
* @return int Returns the current script's inode as an integer.
* @throws InfoException
*
*/
function getmyinode(): int
{
error_clear_last();
$safeResult = \getmyinode();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets the current PHP process ID.
*
* @return int Returns the current PHP process ID.
* @throws InfoException
*
*/
function getmypid(): int
{
error_clear_last();
$safeResult = \getmypid();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @return int Returns the user ID of the current script.
* @throws InfoException
*
*/
function getmyuid(): int
{
error_clear_last();
$safeResult = \getmyuid();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Parses options passed to the script.
*
* @param string $short_options
* @param array $long_options
* @param int|null $rest_index
* @return array|array|array This function will return an array of option / argument pairs.
* @throws InfoException
*
*/
function getopt(string $short_options, array $long_options = [], ?int &$rest_index = null): array
{
error_clear_last();
$safeResult = \getopt($short_options, $long_options, $rest_index);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* This is an interface to getrusage(2). It gets data returned
* from the system call.
*
* @param int $mode If mode is 1, getrusage will be called with
* RUSAGE_CHILDREN.
* @return array Returns an associative array containing the data returned from the system
* call. All entries are accessible by using their documented field names.
* Returns FALSE on failure.
* @throws InfoException
*
*/
function getrusage(int $mode = 0): array
{
error_clear_last();
$safeResult = \getrusage($mode);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the value of the configuration option on success.
*
* @param string $option The configuration option name.
* @return string Returns the value of the configuration option as a string on success, or an
* empty string for null values. Returns FALSE if the
* configuration option doesn't exist.
* @throws InfoException
*
*/
function ini_get(string $option): string
{
error_clear_last();
$safeResult = \ini_get($option);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Sets the value of the given configuration option. The configuration option
* will keep this new value during the script's execution, and will be restored
* at the script's ending.
*
* @param string $option Not all the available options can be changed using
* ini_set. There is a list of all available options
* in the appendix.
* @param bool|float|int|null|string $value The new value for the option.
* @return string Returns the old value on success.
* @throws InfoException
*
*/
function ini_set(string $option, $value): string
{
error_clear_last();
$safeResult = \ini_set($option, $value);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @return non-empty-string Returns the interface type, as a lowercase string.
*
* Although not exhaustive, the possible return values include
* apache,
* apache2handler,
* cgi (until PHP 5.3),
* cgi-fcgi, cli, cli-server,
* embed, fpm-fcgi,
* litespeed,
* phpdbg.
* @throws InfoException
*
*/
function php_sapi_name(): string
{
error_clear_last();
$safeResult = \php_sapi_name();
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* This function prints out the credits listing the PHP developers,
* modules, etc. It generates the appropriate HTML codes to insert
* the information in a page.
*
* @param int $flags To generate a custom credits page, you may want to use the
* flags parameter.
*
*
* Pre-defined phpcredits flags
*
*
*
* name
* description
*
*
*
*
* CREDITS_ALL
*
* All the credits, equivalent to using: CREDITS_DOCS +
* CREDITS_GENERAL + CREDITS_GROUP +
* CREDITS_MODULES + CREDITS_FULLPAGE.
* It generates a complete stand-alone HTML page with the appropriate tags.
*
*
*
* CREDITS_DOCS
* The credits for the documentation team
*
*
* CREDITS_FULLPAGE
*
* Usually used in combination with the other flags. Indicates
* that a complete stand-alone HTML page needs to be
* printed including the information indicated by the other
* flags.
*
*
*
* CREDITS_GENERAL
*
* General credits: Language design and concept, PHP authors
* and SAPI module.
*
*
*
* CREDITS_GROUP
* A list of the core developers
*
*
* CREDITS_MODULES
*
* A list of the extension modules for PHP, and their authors
*
*
*
* CREDITS_SAPI
*
* A list of the server API modules for PHP, and their authors
*
*
*
*
*
* @throws InfoException
*
*/
function phpcredits(int $flags = CREDITS_ALL): void
{
error_clear_last();
$safeResult = \phpcredits($flags);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
}
/**
* Outputs a large amount of information about the current state of PHP.
* This includes information about PHP compilation options and extensions,
* the PHP version, server information and environment (if compiled as a
* module), the PHP environment, OS version information, paths, master and
* local values of configuration options, HTTP headers, and the PHP License.
*
* Because every system is setup differently, phpinfo is
* commonly used to check configuration settings and for available
* predefined variables
* on a given system.
*
* phpinfo is also a valuable debugging tool as it
* contains all EGPCS (Environment, GET, POST, Cookie, Server) data.
*
* @param int $flags The output may be customized by passing one or more of the
* following constants bitwise values summed
* together in the optional flags parameter.
* One can also combine the respective constants or bitwise values
* together with the bitwise or operator.
*
*
* phpinfo options
*
*
*
* Name (constant)
* Value
* Description
*
*
*
*
* INFO_GENERAL
* 1
*
* The configuration line, php.ini location, build date, Web
* Server, System and more.
*
*
*
* INFO_CREDITS
* 2
*
* PHP Credits. See also phpcredits.
*
*
*
* INFO_CONFIGURATION
* 4
*
* Current Local and Master values for PHP directives. See
* also ini_get.
*
*
*
* INFO_MODULES
* 8
*
* Loaded modules and their respective settings. See also
* get_loaded_extensions.
*
*
*
* INFO_ENVIRONMENT
* 16
*
* Environment Variable information that's also available in
* $_ENV.
*
*
*
* INFO_VARIABLES
* 32
*
* Shows all
* predefined variables from EGPCS (Environment, GET,
* POST, Cookie, Server).
*
*
*
* INFO_LICENSE
* 64
*
* PHP License information. See also the license FAQ.
*
*
*
* INFO_ALL
* -1
*
* Shows all of the above.
*
*
*
*
*
* @throws InfoException
*
*/
function phpinfo(int $flags = INFO_ALL): void
{
error_clear_last();
$safeResult = \phpinfo($flags);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
}
/**
* Adds assignment to the server environment. The
* environment variable will only exist for the duration of the current
* request. At the end of the request the environment is restored to its
* original state.
*
* @param string $assignment The setting, like "FOO=BAR"
* @throws InfoException
*
*/
function putenv(string $assignment): void
{
error_clear_last();
$safeResult = \putenv($assignment);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
}
/**
* Sets the include_path
* configuration option for the duration of the script.
*
* @param string $include_path The new value for the include_path
* @return string Returns the old include_path on
* success.
* @throws InfoException
*
*/
function set_include_path(string $include_path): string
{
error_clear_last();
$safeResult = \set_include_path($include_path);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
return $safeResult;
}
/**
* Set the number of seconds a script is allowed to run. If this is reached,
* the script returns a fatal error. The default limit is 30 seconds or, if
* it exists, the max_execution_time value defined in the
* php.ini.
*
* When called, set_time_limit restarts the timeout
* counter from zero. In other words, if the timeout is the default 30
* seconds, and 25 seconds into script execution a call such as
* set_time_limit(20) is made, the script will run for a
* total of 45 seconds before timing out.
*
* @param int $seconds The maximum execution time, in seconds. If set to zero, no time limit
* is imposed.
* @throws InfoException
*
*/
function set_time_limit(int $seconds): void
{
error_clear_last();
$safeResult = \set_time_limit($seconds);
if ($safeResult === false) {
throw InfoException::createFromPhpError();
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Safe;
use Safe\Exceptions\InotifyException;
/**
* Initialize an inotify instance for use with
* inotify_add_watch
*
* @return resource A stream resource.
* @throws InotifyException
*
*/
function inotify_init()
{
error_clear_last();
$safeResult = \inotify_init();
if ($safeResult === false) {
throw InotifyException::createFromPhpError();
}
return $safeResult;
}
/**
* inotify_rm_watch removes the watch
* watch_descriptor from the inotify instance
* inotify_instance.
*
* @param resource $inotify_instance Resource returned by
* inotify_init
* @param int $watch_descriptor Watch to remove from the instance
* @throws InotifyException
*
*/
function inotify_rm_watch($inotify_instance, int $watch_descriptor): void
{
error_clear_last();
$safeResult = \inotify_rm_watch($inotify_instance, $watch_descriptor);
if ($safeResult === false) {
throw InotifyException::createFromPhpError();
}
}

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.2/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
* stringpublic_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();
}
}

View File

@@ -0,0 +1,640 @@
<?php
namespace Safe;
use Safe\Exceptions\MbstringException;
/**
* Returns a string containing the character specified by the Unicode code point value,
* encoded in the specified encoding.
*
* This function complements mb_ord.
*
* @param int $codepoint A Unicode codepoint value, e.g. 128024 for U+1F418 ELEPHANT
* @param null|string $encoding The encoding
* parameter is the character encoding. If it is omitted or NULL, the internal character
* encoding value will be used.
* @return string A string containing the requested character, if it can be represented in the specified
* encoding.
* @throws MbstringException
*
*/
function mb_chr(int $codepoint, ?string $encoding = null): string
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \mb_chr($codepoint, $encoding);
} else {
$safeResult = \mb_chr($codepoint);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Converts string from from_encoding,
* or the current internal encoding, to to_encoding.
* If string is an array, all its string values will be
* converted recursively.
*
* @param array|string $string The string or array to be converted.
* @param string $to_encoding The desired encoding of the result.
* @param mixed $from_encoding The current encoding used to interpret string.
* Multiple encodings may be specified as an array or comma separated
* list, in which case the correct encoding will be guessed using the
* same algorithm as mb_detect_encoding.
*
* If from_encoding is NULL or not specified, the
* mbstring.internal_encoding setting
* will be used if set, otherwise the default_charset setting.
*
* See supported encodings
* for valid values of to_encoding
* and from_encoding.
* @return array|string The encoded string or array on success.
* @throws MbstringException
*
*/
function mb_convert_encoding($string, string $to_encoding, $from_encoding = null)
{
error_clear_last();
if ($from_encoding !== null) {
$safeResult = \mb_convert_encoding($string, $to_encoding, $from_encoding);
} else {
$safeResult = \mb_convert_encoding($string, $to_encoding);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Converts
* character encoding of variables var and vars in
* encoding from_encoding to encoding
* to_encoding.
*
* mb_convert_variables join strings in Array
* or Object to detect encoding, since encoding detection tends to
* fail for short strings. Therefore, it is impossible to mix
* encoding in single array or object.
*
* @param string $to_encoding The encoding that the string is being converted to.
* @param array|string $from_encoding from_encoding is specified as an array
* or comma separated string, it tries to detect encoding from
* from-coding. When from_encoding
* is omitted, detect_order is used.
* @param array|object|string $var var is the reference to the
* variable being converted. String, Array and Object are accepted.
* mb_convert_variables assumes all parameters
* have the same encoding.
* @param array|object|string $vars Additional vars.
* @return string The character encoding before conversion for success.
* @throws MbstringException
*
*/
function mb_convert_variables(string $to_encoding, $from_encoding, &$var, ...$vars): string
{
error_clear_last();
$safeResult = \mb_convert_variables($to_encoding, $from_encoding, $var, ...$vars);
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Sets the automatic character
* encoding detection order to encoding.
*
* @param non-empty-list|non-falsy-string|null $encoding encoding is an array or
* comma separated list of character encoding. See supported encodings.
*
* If encoding is omitted or NULL, it returns
* the current character encoding detection order as array.
*
* This setting affects mb_detect_encoding and
* mb_send_mail.
*
* mbstring currently implements the following
* encoding detection filters. If there is an invalid byte sequence
* for the following encodings, encoding detection will fail.
*
* For ISO-8859-*, mbstring
* always detects as ISO-8859-*.
*
* For UTF-16, UTF-32,
* UCS2 and UCS4, encoding
* detection will fail always.
* @return bool|list When setting the encoding detection order, TRUE is returned on success.
*
* When getting the encoding detection order, an ordered array of the encodings is returned.
* @throws MbstringException
*
*/
function mb_detect_order($encoding = null)
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \mb_detect_order($encoding);
} else {
$safeResult = \mb_detect_order();
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns an array of aliases for a known encoding type.
*
* @param string $encoding The encoding type being checked, for aliases.
* @return list Returns a numerically indexed array of encoding aliases on success
* @throws MbstringException
*
*/
function mb_encoding_aliases(string $encoding): array
{
error_clear_last();
$safeResult = \mb_encoding_aliases($encoding);
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Scans string for matches to
* pattern, then replaces the matched text
* with the output of callback function.
*
* The behavior of this function is almost identical to mb_ereg_replace,
* except for the fact that instead of
* replacement parameter, one should specify a
* callback.
*
* @param string $pattern The regular expression pattern.
*
* Multibyte characters may be used in pattern.
* @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.
*
* You'll often need the callback function
* for a mb_ereg_replace_callback in just one place.
* In this case you can use an
* anonymous function to
* declare the callback within the call to
* mb_ereg_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.
* @param string $string The string being checked.
* @param null|string $options The search option. See mb_regex_set_options for explanation.
* @return null|string The resultant string on success.
* If string is not valid for the current encoding, NULL
* is returned.
* @throws MbstringException
*
*/
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, ?string $options = null): ?string
{
error_clear_last();
if ($options !== null) {
$safeResult = \mb_ereg_replace_callback($pattern, $callback, $string, $options);
} else {
$safeResult = \mb_ereg_replace_callback($pattern, $callback, $string);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param string $pattern The regular expression pattern.
*
* Multibyte characters may be used in pattern.
* @param string $replacement The replacement text.
* @param string $string The string being checked.
* @param null|string $options
* @return null|string The resultant string on success.
* If string is not valid for the current encoding, NULL
* is returned.
* @throws MbstringException
*
*/
function mb_ereg_replace(string $pattern, string $replacement, string $string, ?string $options = null): ?string
{
error_clear_last();
if ($options !== null) {
$safeResult = \mb_ereg_replace($pattern, $replacement, $string, $options);
} else {
$safeResult = \mb_ereg_replace($pattern, $replacement, $string);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @return array
* @throws MbstringException
*
*/
function mb_ereg_search_getregs(): array
{
error_clear_last();
$safeResult = \mb_ereg_search_getregs();
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* mb_ereg_search_init sets
* string and pattern
* for a multibyte regular expression. These values are used for
* mb_ereg_search,
* mb_ereg_search_pos, and
* mb_ereg_search_regs.
*
* @param string $string The search string.
* @param null|string $pattern The search pattern.
* @param null|string $options The search option. See mb_regex_set_options for explanation.
* @throws MbstringException
*
*/
function mb_ereg_search_init(string $string, ?string $pattern = null, ?string $options = null): void
{
error_clear_last();
if ($options !== null) {
$safeResult = \mb_ereg_search_init($string, $pattern, $options);
} elseif ($pattern !== null) {
$safeResult = \mb_ereg_search_init($string, $pattern);
} else {
$safeResult = \mb_ereg_search_init($string);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
}
/**
* Returns the matched part of a multibyte regular expression.
*
* @param null|string $pattern The search pattern.
* @param null|string $options The search option. See mb_regex_set_options for explanation.
* @return array
* @throws MbstringException
*
*/
function mb_ereg_search_regs(?string $pattern = null, ?string $options = null): array
{
error_clear_last();
if ($options !== null) {
$safeResult = \mb_ereg_search_regs($pattern, $options);
} elseif ($pattern !== null) {
$safeResult = \mb_ereg_search_regs($pattern);
} else {
$safeResult = \mb_ereg_search_regs();
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param int $offset The position to set. If it is negative, it counts from the end of the string.
* @throws MbstringException
*
*/
function mb_ereg_search_setpos(int $offset): void
{
error_clear_last();
$safeResult = \mb_ereg_search_setpos($offset);
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
}
/**
*
*
* @param string $pattern The regular expression pattern. Multibyte characters may be used. The case will be ignored.
* @param string $replacement The replacement text.
* @param string $string The searched string.
* @param null|string $options
* @return string The resultant string.
* If string is not valid for the current encoding, NULL
* is returned.
* @throws MbstringException
*
*/
function mb_eregi_replace(string $pattern, string $replacement, string $string, ?string $options = null): string
{
error_clear_last();
if ($options !== null) {
$safeResult = \mb_eregi_replace($pattern, $replacement, $string, $options);
} else {
$safeResult = \mb_eregi_replace($pattern, $replacement, $string);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param string $type If type is not specified or is specified as "all",
* "internal_encoding", "http_input",
* "http_output", "http_output_conv_mimetypes",
* "mail_charset", "mail_header_encoding",
* "mail_body_encoding", "illegal_chars",
* "encoding_translation", "language",
* "detect_order", "substitute_character"
* and "strict_detection"
* will be returned.
*
* If type is specified as
* "internal_encoding", "http_input",
* "http_output", "http_output_conv_mimetypes",
* "mail_charset", "mail_header_encoding",
* "mail_body_encoding", "illegal_chars",
* "encoding_translation", "language",
* "detect_order", "substitute_character"
* or "strict_detection"
* the specified setting parameter will be returned.
* @return mixed An array of type information if type
* is not specified, otherwise a specific type.
* @throws MbstringException
*
*/
function mb_get_info(string $type = "all")
{
error_clear_last();
$safeResult = \mb_get_info($type);
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Set/Get the HTTP output character encoding.
* Output after this function is called will be converted from the set internal encoding to encoding.
*
* @param null|string $encoding If encoding is set,
* mb_http_output sets the HTTP output character
* encoding to encoding.
*
* If encoding is omitted,
* mb_http_output returns the current HTTP output
* character encoding.
* @return bool|string If encoding is omitted,
* mb_http_output returns the current HTTP output
* character encoding. Otherwise,
* Returns TRUE on success.
* @throws MbstringException
*
*/
function mb_http_output(?string $encoding = null)
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \mb_http_output($encoding);
} else {
$safeResult = \mb_http_output();
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Set/Get the internal character encoding
*
* @param null|string $encoding encoding is the character encoding name
* used for the HTTP input character encoding conversion, HTTP output
* character encoding conversion, and the default character encoding
* for string functions defined by the mbstring module.
* You should notice that the internal encoding is totally different from the one for multibyte regex.
* @return bool|string If encoding is set, then
* Returns TRUE on success.
* In this case, the character encoding for multibyte regex is NOT changed.
* If encoding is omitted, then
* the current character encoding name is returned.
* @throws MbstringException
*
*/
function mb_internal_encoding(?string $encoding = null)
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \mb_internal_encoding($encoding);
} else {
$safeResult = \mb_internal_encoding();
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the Unicode code point value of the given character.
*
* This function complements mb_chr.
*
* @param string $string A string
* @param null|string $encoding The encoding
* parameter is the character encoding. If it is omitted or NULL, the internal character
* encoding value will be used.
* @return int The Unicode code point for the first character of string.
* @throws MbstringException
*
*/
function mb_ord(string $string, ?string $encoding = null): int
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \mb_ord($string, $encoding);
} else {
$safeResult = \mb_ord($string);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Parses GET/POST/COOKIE data and
* sets global variables. Since PHP does not provide raw POST/COOKIE
* data, it can only be used for GET data for now. It parses URL
* encoded data, detects encoding, converts coding to internal
* encoding and set values to the result array or
* global variables.
*
* @param string $string The URL encoded data.
* @param array|null $result An array containing decoded and character encoded converted values.
* @throws MbstringException
*
*/
function mb_parse_str(string $string, ?array &$result): void
{
error_clear_last();
$safeResult = \mb_parse_str($string, $result);
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
}
/**
* Set/Get character encoding for a multibyte regex.
*
* @param null|string $encoding The encoding
* parameter is the character encoding. If it is omitted or NULL, the internal character
* encoding value will be used.
* @return bool|string
* @throws MbstringException
*
*/
function mb_regex_encoding(?string $encoding = null)
{
error_clear_last();
if ($encoding !== null) {
$safeResult = \mb_regex_encoding($encoding);
} else {
$safeResult = \mb_regex_encoding();
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}
/**
* Sends email. Headers and messages are converted and encoded according
* to the mb_language setting. It's a wrapper function
* for mail, so see also mail for details.
*
* @param string $to The mail addresses being sent to. Multiple
* recipients may be specified by putting a comma between each
* address in to.
* This parameter is not automatically encoded.
* @param string $subject The subject of the mail.
* @param string $message The message of the mail.
* @param array|null|string $additional_headers String or array to be inserted at the end of the email header.
*
* This is typically used to add extra headers (From, Cc, and Bcc).
* Multiple extra headers should be separated with a CRLF (\r\n).
* Validate parameter not to be injected unwanted headers by attackers.
*
* If an array is passed, its keys are the header names and its
* values are the respective header values.
*
* When sending mail, the mail must contain
* a From header. This can be set with the
* additional_headers parameter, or a default
* can be set in php.ini.
*
* Failing to do this will result in an error
* message similar to Warning: mail(): "sendmail_from" not
* set in php.ini or custom "From:" header missing.
* The From header sets also
* Return-Path under Windows.
*
* If messages are not received, try using a LF (\n) only.
* Some Unix mail transfer agents (most notably
* qmail) replace LF by CRLF
* automatically (which leads to doubling CR if CRLF is used).
* This should be a last resort, as it does not comply with
* RFC 2822.
* @param null|string $additional_params additional_params is a MTA command line
* parameter. It is useful when setting the correct Return-Path
* header when using sendmail.
*
* This parameter is escaped by escapeshellcmd internally
* to prevent command execution. escapeshellcmd prevents
* command execution, but allows to add additional parameters. For security reason,
* this parameter should be validated.
*
* Since escapeshellcmd is applied automatically, some characters
* that are allowed as email addresses by internet RFCs cannot be used. Programs
* that are required to use these characters mail cannot be used.
*
* The user that the webserver runs as should be added as a trusted user to the
* sendmail configuration to prevent a 'X-Warning' header from being added
* to the message when the envelope sender (-f) is set using this method.
* For sendmail users, this file is /etc/mail/trusted-users.
* @throws MbstringException
*
*/
function mb_send_mail(string $to, string $subject, string $message, $additional_headers = [], ?string $additional_params = null): void
{
error_clear_last();
if ($additional_params !== null) {
$safeResult = \mb_send_mail($to, $subject, $message, $additional_headers, $additional_params);
} else {
$safeResult = \mb_send_mail($to, $subject, $message, $additional_headers);
}
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
}
/**
*
*
* @param string $pattern The regular expression pattern.
* @param string $string The string being split.
* @param int $limit
* @return list The result as an array.
* @throws MbstringException
*
*/
function mb_split(string $pattern, string $string, int $limit = -1): array
{
error_clear_last();
$safeResult = \mb_split($pattern, $string, $limit);
if ($safeResult === false) {
throw MbstringException::createFromPhpError();
}
return $safeResult;
}

0
vendor/thecodingmachine/safe/generated/8.2/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;
}

0
vendor/thecodingmachine/safe/generated/8.2/mysqli.php vendored Normal file → Executable file
View File

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

0
vendor/thecodingmachine/safe/generated/8.2/oci8.php vendored Normal file → Executable file
View File

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.2/openssl.php vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,279 @@
<?php
namespace Safe;
use Safe\Exceptions\OutcontrolException;
/**
* This function discards the contents of the output buffer.
*
* This function does not destroy the output buffer like
* ob_end_clean does.
*
* The output buffer must be started by
* ob_start with PHP_OUTPUT_HANDLER_CLEANABLE
* flag. Otherwise ob_clean will not work.
*
* @throws OutcontrolException
*
*/
function ob_clean(): void
{
error_clear_last();
$safeResult = \ob_clean();
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}
/**
* This function discards the contents of the topmost output buffer and turns
* off this output buffering. If you want to further process the buffer's
* contents you have to call ob_get_contents before
* ob_end_clean as the buffer contents are discarded
* when ob_end_clean is called.
*
* The output buffer must be started by
* ob_start with PHP_OUTPUT_HANDLER_CLEANABLE
* and PHP_OUTPUT_HANDLER_REMOVABLE
* flags. Otherwise ob_end_clean will not work.
*
* @throws OutcontrolException
*
*/
function ob_end_clean(): void
{
error_clear_last();
$safeResult = \ob_end_clean();
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}
/**
* This function will send the contents of the topmost output buffer (if
* any) and turn this output buffer off. If you want to further
* process the buffer's contents you have to call
* ob_get_contents before
* ob_end_flush as the buffer contents are
* discarded after ob_end_flush is called.
*
* The output buffer must be started by
* ob_start with PHP_OUTPUT_HANDLER_FLUSHABLE
* and PHP_OUTPUT_HANDLER_REMOVABLE
* flags. Otherwise ob_end_flush will not work.
*
* @throws OutcontrolException
*
*/
function ob_end_flush(): void
{
error_clear_last();
$safeResult = \ob_end_flush();
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}
/**
* This function will send the contents of the output buffer (if any). If you
* want to further process the buffer's contents you have to call
* ob_get_contents before ob_flush
* as the buffer contents are discarded after ob_flush
* is called.
*
* This function does not destroy the output buffer like
* ob_end_flush does.
*
* @throws OutcontrolException
*
*/
function ob_flush(): void
{
error_clear_last();
$safeResult = \ob_flush();
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}
/**
* Gets the current buffer contents and delete current output buffer.
*
* ob_get_clean essentially executes both
* ob_get_contents and
* ob_end_clean.
*
* The output buffer must be started by
* ob_start with PHP_OUTPUT_HANDLER_CLEANABLE
* and PHP_OUTPUT_HANDLER_REMOVABLE
* flags. Otherwise ob_get_clean will not work.
*
* @return string Returns the contents of the output buffer and end output buffering.
* If output buffering isn't active then FALSE is returned.
* @throws OutcontrolException
*
*/
function ob_get_clean(): string
{
error_clear_last();
$safeResult = \ob_get_clean();
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
return $safeResult;
}
/**
* This function will turn output buffering on. While output buffering is
* active no output is sent from the script (other than headers), instead the
* output is stored in an internal buffer.
*
* The contents of this internal buffer may be copied into a string variable
* using ob_get_contents. To output what is stored in
* the internal buffer, use ob_end_flush. Alternatively,
* ob_end_clean will silently discard the buffer
* contents.
*
* Output buffers are stackable, that is, you may call
* ob_start while another
* ob_start is active. Just make
* sure that you call ob_end_flush
* the appropriate number of times. If multiple output callback
* functions are active, output is being filtered sequentially
* through each of them in nesting order.
*
* If output buffering is still active when the script ends, PHP outputs the
* contents automatically.
*
* @param array|callable|null|string $callback An optional callback function may be
* specified. This function takes a string as a parameter and should
* return a string. The function will be called when
* the output buffer is flushed (sent) or cleaned (with
* ob_flush, ob_clean or similar
* function) or when the output buffer
* is flushed to the browser at the end of the request. When
* callback is called, it will receive the
* contents of the output buffer as its parameter and is expected to
* return a new output buffer as a result, which will be sent to the
* browser. If the callback is not a
* callable function, this function will return FALSE.
* This is the callback signature:
*
*
* stringhandler
* stringbuffer
* intphase
*
*
*
* buffer
*
*
* Contents of the output buffer.
*
*
*
*
* phase
*
*
* Bitmask of PHP_OUTPUT_HANDLER_* constants.
*
*
*
*
*
* If callback returns FALSE original
* input is sent to the browser.
*
* The callback parameter may be bypassed
* by passing a NULL value.
*
* ob_end_clean, ob_end_flush,
* ob_clean, ob_flush and
* ob_start may not be called from a callback
* function. If you call them from callback function, the behavior is
* undefined. If you would like to delete the contents of a buffer,
* return "" (a null string) from callback function.
* You can't even call functions using the output buffering functions like
* print_r($expression, true) or
* highlight_file($filename, true) from a callback
* function.
*
* ob_gzhandler function exists to
* facilitate sending gz-encoded data to web browsers that support
* compressed web pages. ob_gzhandler determines
* what type of content encoding the browser will accept and will return
* its output accordingly.
* @param int $chunk_size
* @param int $flags
* @throws OutcontrolException
*
*/
function ob_start($callback = null, int $chunk_size = 0, int $flags = PHP_OUTPUT_HANDLER_STDFLAGS): void
{
error_clear_last();
if ($flags !== PHP_OUTPUT_HANDLER_STDFLAGS) {
$safeResult = \ob_start($callback, $chunk_size, $flags);
} elseif ($chunk_size !== 0) {
$safeResult = \ob_start($callback, $chunk_size);
} elseif ($callback !== null) {
$safeResult = \ob_start($callback);
} else {
$safeResult = \ob_start();
}
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}
/**
* This function adds another name/value pair to the URL rewrite mechanism.
* The name and value will be added to URLs (as GET parameter) and forms
* (as hidden input fields) the same way as the session ID when transparent
* URL rewriting is enabled with session.use_trans_sid.
*
* This function's behaviour is controlled by the url_rewriter.tags and
* url_rewriter.hosts php.ini
* parameters.
*
* Note that this function can be successfully called at most once per request.
*
* @param string $name The variable name.
* @param string $value The variable value.
* @throws OutcontrolException
*
*/
function output_add_rewrite_var(string $name, string $value): void
{
error_clear_last();
$safeResult = \output_add_rewrite_var($name, $value);
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}
/**
* This function resets the URL rewriter and removes all rewrite
* variables previously set by the output_add_rewrite_var
* function.
*
* @throws OutcontrolException
*
*/
function output_reset_rewrite_vars(): void
{
error_clear_last();
$safeResult = \output_reset_rewrite_vars();
if ($safeResult === false) {
throw OutcontrolException::createFromPhpError();
}
}

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 array of strings that matched full pattern,
* and $out[1] contains 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 array of strings that matched full pattern,
* and $out[1] contains array of strings enclosed by tags.
*
*
*
* The above example will output:
*
* So, $out[0] contains array of strings that matched full pattern,
* and $out[1] contains 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 array of strings that matched full pattern,
* and $out[1] contains array of strings enclosed by tags.
*
*
*
* The above example will output:
*
* So, $out[0] contains array of strings that matched full pattern,
* and $out[1] contains 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;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,751 @@
<?php
namespace Safe;
use Safe\Exceptions\PosixException;
/**
* posix_access checks the user's permission of a file.
*
* @param string $filename The name of the file to be tested.
* @param int $flags A mask consisting of one or more of POSIX_F_OK,
* POSIX_R_OK, POSIX_W_OK and
* POSIX_X_OK.
*
* POSIX_R_OK, POSIX_W_OK and
* POSIX_X_OK request checking whether the file
* exists and has read, write and execute permissions, respectively.
* POSIX_F_OK just requests checking for the
* existence of the file.
* @throws PosixException
*
*/
function posix_access(string $filename, int $flags = 0): void
{
error_clear_last();
$safeResult = \posix_access($filename, $flags);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Gets information about a group provided its id.
*
* @param int $group_id The group id.
* @return array{name: string, passwd: string, gid: int, members: list} The array elements returned are:
*
* The group information array
*
*
*
* Element
* Description
*
*
*
*
* name
*
* The name element contains the name of the group. This is
* a short, usually less than 16 character "handle" of the
* group, not the real, full name.
*
*
*
* passwd
*
* The passwd element contains the group's password in an
* encrypted format. Often, for example on a system employing
* "shadow" passwords, an asterisk is returned instead.
*
*
*
* gid
*
* Group ID, should be the same as the
* group_id parameter used when calling the
* function, and hence redundant.
*
*
*
* members
*
* This consists of an array of
* string's for all the members in the group.
*
*
*
*
*
* The function returns FALSE on failure.
* @throws PosixException
*
*/
function posix_getgrgid(int $group_id): array
{
error_clear_last();
$safeResult = \posix_getgrgid($group_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets information about a group provided its name.
*
* @param string $name The name of the group
* @return array{name: string, passwd: string, gid: int, members: list} Returns an array on success.
* The array elements returned are:
*
* The group information array
*
*
*
* Element
* Description
*
*
*
*
* name
*
* The name element contains the name of the group. This is
* a short, usually less than 16 character "handle" of the
* group, not the real, full name. This should be the same as
* the name parameter used when
* calling the function, and hence redundant.
*
*
*
* passwd
*
* The passwd element contains the group's password in an
* encrypted format. Often, for example on a system employing
* "shadow" passwords, an asterisk is returned instead.
*
*
*
* gid
*
* Group ID of the group in numeric form.
*
*
*
* members
*
* This consists of an array of
* string's for all the members in the group.
*
*
*
*
*
* @throws PosixException
*
*/
function posix_getgrnam(string $name): array
{
error_clear_last();
$safeResult = \posix_getgrnam($name);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets the group set of the current process.
*
* @return list Returns an array of integers containing the numeric group ids of the group
* set of the current process.
* @throws PosixException
*
*/
function posix_getgroups(): array
{
error_clear_last();
$safeResult = \posix_getgroups();
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns the login name of the user owning the current process.
*
* @return string Returns the login name of the user, as a string.
* @throws PosixException
*
*/
function posix_getlogin(): string
{
error_clear_last();
$safeResult = \posix_getlogin();
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Returns an array of information about the user
* referenced by the given user ID.
*
* @param int $user_id The user identifier.
* @return array{name: string, passwd: string, uid: int, gid: int, gecos: string, dir: string, shell: string} Returns an associative array with the following elements:
*
* The user information array
*
*
*
* Element
* Description
*
*
*
*
* name
*
* The name element contains the username of the user. This is
* a short, usually less than 16 character "handle" of the
* user, not the real, full name.
*
*
*
* passwd
*
* The passwd element contains the user's password in an
* encrypted format. Often, for example on a system employing
* "shadow" passwords, an asterisk is returned instead.
*
*
*
* uid
*
* User ID, should be the same as the
* user_id parameter used when calling the
* function, and hence redundant.
*
*
*
* gid
*
* The group ID of the user. Use the function
* posix_getgrgid to resolve the group
* name and a list of its members.
*
*
*
* gecos
*
* GECOS is an obsolete term that refers to the finger
* information field on a Honeywell batch processing system.
* The field, however, lives on, and its contents have been
* formalized by POSIX. The field contains a comma separated
* list containing the user's full name, office phone, office
* number, and home phone number. On most systems, only the
* user's full name is available.
*
*
*
* dir
*
* This element contains the absolute path to the
* home directory of the user.
*
*
*
* shell
*
* The shell element contains the absolute path to the
* executable of the user's default shell.
*
*
*
*
*
* The function returns FALSE on failure.
* @throws PosixException
*
*/
function posix_getpwuid(int $user_id): array
{
error_clear_last();
$safeResult = \posix_getpwuid($user_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* posix_getrlimit returns an array
* of information about the current resource's soft and hard limits.
*
*
* Each resource has an associated soft and hard limit. The soft
* limit is the value that the kernel enforces for the corresponding
* resource. The hard limit acts as a ceiling for the soft limit.
* An unprivileged process may only set its soft limit to a value
* from 0 to the hard limit, and irreversibly lower its hard limit.
*
* @return array Returns an associative array of elements for each
* limit that is defined. Each limit has a soft and a hard limit.
*
* List of possible limits returned
*
*
*
* Limit name
* Limit description
*
*
*
*
* core
*
* The maximum size of the core file. When 0, not core files are
* created. When core files are larger than this size, they will
* be truncated at this size.
*
*
*
* totalmem
*
* The maximum size of the memory of the process, in bytes.
*
*
*
* virtualmem
*
* The maximum size of the virtual memory for the process, in bytes.
*
*
*
* data
*
* The maximum size of the data segment for the process, in bytes.
*
*
*
* stack
*
* The maximum size of the process stack, in bytes.
*
*
*
* rss
*
* The maximum number of virtual pages resident in RAM
*
*
*
* maxproc
*
* The maximum number of processes that can be created for the
* real user ID of the calling process.
*
*
*
* memlock
*
* The maximum number of bytes of memory that may be locked into RAM.
*
*
*
* cpu
*
* The amount of time the process is allowed to use the CPU.
*
*
*
* filesize
*
* The maximum size of the data segment for the process, in bytes.
*
*
*
* openfiles
*
* One more than the maximum number of open file descriptors.
*
*
*
*
*
* The function returns FALSE on failure.
* @throws PosixException
*
*/
function posix_getrlimit(): array
{
error_clear_last();
$safeResult = \posix_getrlimit();
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Return the session id of the process process_id.
* The session id of a process is the process group id of the session leader.
*
* @param int $process_id The process identifier. If set to 0, the current process is
* assumed. If an invalid process_id is
* specified, then FALSE is returned and an error is set which
* can be checked with posix_get_last_error.
* @return int Returns the identifier, as an int.
* @throws PosixException
*
*/
function posix_getsid(int $process_id): int
{
error_clear_last();
$safeResult = \posix_getsid($process_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Calculates the group access list for the user specified in name.
*
* @param string $username The user to calculate the list for.
* @param int $group_id Typically the group number from the password file.
* @throws PosixException
*
*/
function posix_initgroups(string $username, int $group_id): void
{
error_clear_last();
$safeResult = \posix_initgroups($username, $group_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Send the signal signal to the process with
* the process identifier process_id.
*
* @param int $process_id The process identifier.
* @param int $signal One of the PCNTL signals constants.
* @throws PosixException
*
*/
function posix_kill(int $process_id, int $signal): void
{
error_clear_last();
$safeResult = \posix_kill($process_id, $signal);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* posix_mkfifo creates a special
* FIFO file which exists in the file system and acts as
* a bidirectional communication endpoint for processes.
*
* @param string $filename Path to the FIFO file.
* @param int $permissions The second parameter permissions has to be given in
* octal notation (e.g. 0644). The permission of the newly created
* FIFO also depends on the setting of the current
* umask. The permissions of the created file are
* (mode &amp; ~umask).
* @throws PosixException
*
*/
function posix_mkfifo(string $filename, int $permissions): void
{
error_clear_last();
$safeResult = \posix_mkfifo($filename, $permissions);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Creates a special or ordinary file.
*
* @param string $filename The file to create
* @param int $flags This parameter is constructed by a bitwise OR between file type (one of
* the following constants: POSIX_S_IFREG,
* POSIX_S_IFCHR, POSIX_S_IFBLK,
* POSIX_S_IFIFO or
* POSIX_S_IFSOCK) and permissions.
* @param int $major The major device kernel identifier (required to pass when using
* S_IFCHR or S_IFBLK).
* @param int $minor The minor device kernel identifier.
* @throws PosixException
*
*/
function posix_mknod(string $filename, int $flags, int $major = 0, int $minor = 0): void
{
error_clear_last();
$safeResult = \posix_mknod($filename, $flags, $major, $minor);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Set the effective group ID of the current process. This is a
* privileged function and needs appropriate privileges (usually
* root) on the system to be able to perform this function.
*
* @param int $group_id The group id.
* @throws PosixException
*
*/
function posix_setegid(int $group_id): void
{
error_clear_last();
$safeResult = \posix_setegid($group_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Set the effective user ID of the current process. This is a privileged
* function and needs appropriate privileges (usually root) on
* the system to be able to perform this function.
*
* @param int $user_id The user id.
* @throws PosixException
*
*/
function posix_seteuid(int $user_id): void
{
error_clear_last();
$safeResult = \posix_seteuid($user_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Set the real group ID of the current process. This is a
* privileged function and needs appropriate privileges (usually
* root) on the system to be able to perform this function. The
* appropriate order of function calls is
* posix_setgid first,
* posix_setuid last.
*
* @param int $group_id The group id.
* @throws PosixException
*
*/
function posix_setgid(int $group_id): void
{
error_clear_last();
$safeResult = \posix_setgid($group_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Let the process process_id join the process group
* process_group_id.
*
* @param int $process_id The process id.
* @param int $process_group_id The process group id.
* @throws PosixException
*
*/
function posix_setpgid(int $process_id, int $process_group_id): void
{
error_clear_last();
$safeResult = \posix_setpgid($process_id, $process_group_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* posix_setrlimit sets the soft and hard limits for a
* given system resource.
*
*
* Each resource has an associated soft and hard limit. The soft
* limit is the value that the kernel enforces for the corresponding
* resource. The hard limit acts as a ceiling for the soft limit.
* An unprivileged process may only set its soft limit to a value
* from 0 to the hard limit, and irreversibly lower its hard limit.
*
* @param int $resource The
* resource limit constant
* corresponding to the limit that is being set.
* @param int $soft_limit The soft limit, in whatever unit the resource limit requires, or
* POSIX_RLIMIT_INFINITY.
* @param int $hard_limit The hard limit, in whatever unit the resource limit requires, or
* POSIX_RLIMIT_INFINITY.
* @throws PosixException
*
*/
function posix_setrlimit(int $resource, int $soft_limit, int $hard_limit): void
{
error_clear_last();
$safeResult = \posix_setrlimit($resource, $soft_limit, $hard_limit);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Make the current process a session leader.
*
* @return int Returns the session ids.
* @throws PosixException
*
*/
function posix_setsid(): int
{
error_clear_last();
$safeResult = \posix_setsid();
if ($safeResult === -1) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Set the real user ID of the current process. This is a privileged
* function that needs appropriate privileges (usually root) on
* the system to be able to perform this function.
*
* @param int $user_id The user id.
* @throws PosixException
*
*/
function posix_setuid(int $user_id): void
{
error_clear_last();
$safeResult = \posix_setuid($user_id);
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
}
/**
* Gets information about the current CPU usage.
*
* @return array Returns a hash of strings with information about the current
* process CPU usage. The indices of the hash are:
*
*
*
* ticks - the number of clock ticks that have elapsed since
* reboot.
*
*
*
*
* utime - user time used by the current process.
*
*
*
*
* stime - system time used by the current process.
*
*
*
*
* cutime - user time used by current process and children.
*
*
*
*
* cstime - system time used by current process and children.
*
*
*
* The function returns FALSE on failure.
* @throws PosixException
*
*/
function posix_times(): array
{
error_clear_last();
$safeResult = \posix_times();
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets information about the system.
*
* Posix requires that assumptions must not be made about the
* format of the values, e.g. the assumption that a release may contain
* three digits or anything else returned by this function.
*
* @return array Returns a hash of strings with information about the
* system. The indices of the hash are
*
*
* sysname - operating system name (e.g. Linux)
*
*
* nodename - system name (e.g. valiant)
*
*
* release - operating system release (e.g. 2.2.10)
*
*
* version - operating system version (e.g. #4 Tue Jul 20
* 17:01:36 MEST 1999)
*
*
* machine - system architecture (e.g. i586)
*
*
* domainname - DNS domainname (e.g. example.com)
*
*
*
* domainname is a GNU extension and not part of POSIX.1, so this
* field is only available on GNU systems or when using the GNU
* libc.
*
* The function returns FALSE on failure.
* @throws PosixException
*
*/
function posix_uname(): array
{
error_clear_last();
$safeResult = \posix_uname();
if ($safeResult === false) {
throw PosixException::createFromPhpError();
}
return $safeResult;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,501 @@
<?php
namespace Safe;
use Safe\Exceptions\PspellException;
/**
*
*
* @param int $dictionary An PSpell\Dictionary instance.
* @param string $word The added word.
* @throws PspellException
*
*/
function pspell_add_to_personal(int $dictionary, string $word): void
{
error_clear_last();
$safeResult = \pspell_add_to_personal($dictionary, $word);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary An PSpell\Dictionary instance.
* @param string $word The added word.
* @throws PspellException
*
*/
function pspell_add_to_session(int $dictionary, string $word): void
{
error_clear_last();
$safeResult = \pspell_add_to_session($dictionary, $word);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary An PSpell\Dictionary instance.
* @throws PspellException
*
*/
function pspell_clear_session(int $dictionary): void
{
error_clear_last();
$safeResult = \pspell_clear_session($dictionary);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
* Create a config used to open a dictionary.
*
* pspell_config_create has a very similar syntax to
* pspell_new. In fact, using
* pspell_config_create immediately followed by
* pspell_new_config will produce the exact same result.
* However, after creating a new config, you can also use
* pspell_config_* functions before calling
* pspell_new_config to take advantage of some
* advanced functionality.
*
* For more information and examples, check out inline manual pspell
* website:http://aspell.net/.
*
* @param string $language The language parameter is the language code which consists of the
* two letter ISO 639 language code and an optional two letter ISO
* 3166 country code after a dash or underscore.
* @param string $spelling The spelling parameter is the requested spelling for languages
* with more than one spelling such as English. Known values are
* 'american', 'british', and 'canadian'.
* @param string $jargon The jargon parameter contains extra information to distinguish
* two different words lists that have the same language and
* spelling parameters.
* @param string $encoding The encoding parameter is the encoding that words are expected to
* be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r',
* 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned
* 32'. This parameter is largely untested, so be careful when
* using.
* @return int Returns an PSpell\Config instance on success.
* @throws PspellException
*
*/
function pspell_config_create(string $language, string $spelling = "", string $jargon = "", string $encoding = ""): int
{
error_clear_last();
$safeResult = \pspell_config_create($language, $spelling, $jargon, $encoding);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
return $safeResult;
}
/**
* This function is
* currently not documented; only its argument list is available.
*
*
* @param int $config
* @param string $directory
* @throws PspellException
*
*/
function pspell_config_data_dir(int $config, string $directory): void
{
error_clear_last();
$safeResult = \pspell_config_data_dir($config, $directory);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
* This function is
* currently not documented; only its argument list is available.
*
*
* @param int $config
* @param string $directory
* @throws PspellException
*
*/
function pspell_config_dict_dir(int $config, string $directory): void
{
error_clear_last();
$safeResult = \pspell_config_dict_dir($config, $directory);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $config An PSpell\Config instance.
* @param int $min_length Words less than min_length characters will be skipped.
* @throws PspellException
*
*/
function pspell_config_ignore(int $config, int $min_length): void
{
error_clear_last();
$safeResult = \pspell_config_ignore($config, $min_length);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $config An PSpell\Config instance.
* @param int $mode The mode parameter is the mode in which spellchecker will work.
* There are several modes available:
*
*
*
* PSPELL_FAST - Fast mode (least number of
* suggestions)
*
*
*
*
* PSPELL_NORMAL - Normal mode (more suggestions)
*
*
*
*
* PSPELL_BAD_SPELLERS - Slow mode (a lot of
* suggestions)
*
*
*
* @throws PspellException
*
*/
function pspell_config_mode(int $config, int $mode): void
{
error_clear_last();
$safeResult = \pspell_config_mode($config, $mode);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
* Set a file that contains personal wordlist. The personal wordlist will be
* loaded and used in addition to the standard one after you call
* pspell_new_config. The file is also the file where
* pspell_save_wordlist will save personal wordlist to.
*
* pspell_config_personal should be used on a config
* before calling pspell_new_config.
*
* @param int $config An PSpell\Config instance.
* @param string $filename The personal wordlist. If the file does not exist, it will be created.
* The file should be writable by whoever PHP runs as (e.g. nobody).
* @throws PspellException
*
*/
function pspell_config_personal(int $config, string $filename): void
{
error_clear_last();
$safeResult = \pspell_config_personal($config, $filename);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
* Set a file that contains replacement pairs.
*
* The replacement pairs improve the quality of the spellchecker. When a word
* is misspelled, and a proper suggestion was not found in the list,
* pspell_store_replacement can be used to store a
* replacement pair and then pspell_save_wordlist to
* save the wordlist along with the replacement pairs.
*
* pspell_config_repl should be used on a config
* before calling pspell_new_config.
*
* @param int $config An PSpell\Config instance.
* @param string $filename The file should be writable by whoever PHP runs as (e.g. nobody).
* @throws PspellException
*
*/
function pspell_config_repl(int $config, string $filename): void
{
error_clear_last();
$safeResult = \pspell_config_repl($config, $filename);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
* This function determines whether run-together words will be treated as
* legal compounds. That is, "thecat" will be a legal compound, although
* there should be a space between the two words. Changing this setting only
* affects the results returned by pspell_check;
* pspell_suggest will still return suggestions.
*
* pspell_config_runtogether should be used on a config
* before calling pspell_new_config.
*
* @param int $config An PSpell\Config instance.
* @param bool $allow TRUE if run-together words should be treated as legal compounds,
* FALSE otherwise.
* @throws PspellException
*
*/
function pspell_config_runtogether(int $config, bool $allow): void
{
error_clear_last();
$safeResult = \pspell_config_runtogether($config, $allow);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
* pspell_config_save_repl determines whether
* pspell_save_wordlist will save the replacement pairs
* along with the wordlist. Usually there is no need to use this function
* because if pspell_config_repl is used, the
* replacement pairs will be saved by
* pspell_save_wordlist anyway, and if it is not,
* the replacement pairs will not be saved.
*
* pspell_config_save_repl should be used on a config
* before calling pspell_new_config.
*
* @param int $config An PSpell\Config instance.
* @param bool $save TRUE if replacement pairs should be saved, FALSE otherwise.
* @throws PspellException
*
*/
function pspell_config_save_repl(int $config, bool $save): void
{
error_clear_last();
$safeResult = \pspell_config_save_repl($config, $save);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $config The config parameter is the one returned by
* pspell_config_create when the config was created.
* @return int Returns an PSpell\Dictionary instance on success
* @throws PspellException
*
*/
function pspell_new_config(int $config): int
{
error_clear_last();
$safeResult = \pspell_new_config($config);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
return $safeResult;
}
/**
* For more information and examples, check out inline manual pspell
* website:http://aspell.net/.
*
* @param string $filename The file where words added to the personal list will be stored.
* It should be an absolute filename beginning with '/' because otherwise
* it will be relative to $HOME, which is "/root" for most systems, and
* is probably not what you want.
* @param string $language The language code which consists of the two letter ISO 639 language
* code and an optional two letter ISO 3166 country code after a dash
* or underscore.
* @param string $spelling The requested spelling for languages with more than one spelling such
* as English. Known values are 'american', 'british', and 'canadian'.
* @param string $jargon Extra information to distinguish two different words lists that have
* the same language and spelling parameters.
* @param string $encoding The encoding that words are expected to be in. Valid values are
* utf-8, iso8859-*,
* koi8-r, viscii,
* cp1252, machine unsigned 16,
* machine unsigned 32.
* @param int $mode The mode in which spellchecker will work. There are several modes available:
*
*
*
* PSPELL_FAST - Fast mode (least number of
* suggestions)
*
*
*
*
* PSPELL_NORMAL - Normal mode (more suggestions)
*
*
*
*
* PSPELL_BAD_SPELLERS - Slow mode (a lot of
* suggestions)
*
*
*
*
* PSPELL_RUN_TOGETHER - Consider run-together words
* as legal compounds. That is, "thecat" will be a legal compound,
* although there should be a space between the two words. Changing this
* setting only affects the results returned by
* pspell_check; pspell_suggest
* will still return suggestions.
*
*
*
* Mode is a bitmask constructed from different constants listed above.
* However, PSPELL_FAST,
* PSPELL_NORMAL and
* PSPELL_BAD_SPELLERS are mutually exclusive, so you
* should select only one of them.
* @return int Returns an PSpell\Dictionary instance on success.
* @throws PspellException
*
*/
function pspell_new_personal(string $filename, string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int
{
error_clear_last();
$safeResult = \pspell_new_personal($filename, $language, $spelling, $jargon, $encoding, $mode);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
return $safeResult;
}
/**
* pspell_new opens up a new dictionary and
* returns an PSpell\Dictionary instance for use in other pspell
* functions.
*
* For more information and examples, check out inline manual pspell
* website:http://aspell.net/.
*
* @param string $language The language parameter is the language code which consists of the
* two letter ISO 639 language code and an optional two letter ISO
* 3166 country code after a dash or underscore.
* @param string $spelling The spelling parameter is the requested spelling for languages
* with more than one spelling such as English. Known values are
* 'american', 'british', and 'canadian'.
* @param string $jargon The jargon parameter contains extra information to distinguish
* two different words lists that have the same language and
* spelling parameters.
* @param string $encoding The encoding parameter is the encoding that words are expected to
* be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r',
* 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned
* 32'. This parameter is largely untested, so be careful when
* using.
* @param int $mode The mode parameter is the mode in which spellchecker will work.
* There are several modes available:
*
*
*
* PSPELL_FAST - Fast mode (least number of
* suggestions)
*
*
*
*
* PSPELL_NORMAL - Normal mode (more suggestions)
*
*
*
*
* PSPELL_BAD_SPELLERS - Slow mode (a lot of
* suggestions)
*
*
*
*
* PSPELL_RUN_TOGETHER - Consider run-together words
* as legal compounds. That is, "thecat" will be a legal compound,
* although there should be a space between the two words. Changing this
* setting only affects the results returned by
* pspell_check; pspell_suggest
* will still return suggestions.
*
*
*
* Mode is a bitmask constructed from different constants listed above.
* However, PSPELL_FAST,
* PSPELL_NORMAL and
* PSPELL_BAD_SPELLERS are mutually exclusive, so you
* should select only one of them.
* @return int Returns an PSpell\Dictionary instance on success.
* @throws PspellException
*
*/
function pspell_new(string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int
{
error_clear_last();
$safeResult = \pspell_new($language, $spelling, $jargon, $encoding, $mode);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param int $dictionary An PSpell\Dictionary instance.
* @throws PspellException
*
*/
function pspell_save_wordlist(int $dictionary): void
{
error_clear_last();
$safeResult = \pspell_save_wordlist($dictionary);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary An PSpell\Dictionary instance.
* @param string $misspelled The misspelled word.
* @param string $correct The fixed spelling for the misspelled word.
* @throws PspellException
*
*/
function pspell_store_replacement(int $dictionary, string $misspelled, string $correct): void
{
error_clear_last();
$safeResult = \pspell_store_replacement($dictionary, $misspelled, $correct);
if ($safeResult === false) {
throw PspellException::createFromPhpError();
}
}

View File

@@ -0,0 +1,125 @@
<?php
namespace Safe;
use Safe\Exceptions\ReadlineException;
/**
* This function adds a line to the command line history.
*
* @param string $prompt The line to be added in the history.
* @throws ReadlineException
*
*/
function readline_add_history(string $prompt): void
{
error_clear_last();
$safeResult = \readline_add_history($prompt);
if ($safeResult === false) {
throw ReadlineException::createFromPhpError();
}
}
/**
* Sets up a readline callback interface then prints
* prompt and immediately returns.
* Calling this function twice without removing the previous
* callback interface will automatically and conveniently overwrite the old
* interface.
*
* The callback feature is useful when combined with
* stream_select as it allows interleaving of IO and
* user input, unlike readline.
*
* @param string $prompt The prompt message.
* @param callable $callback The callback function takes one parameter; the
* user input returned.
* @throws ReadlineException
*
*/
function readline_callback_handler_install(string $prompt, callable $callback): void
{
error_clear_last();
$safeResult = \readline_callback_handler_install($prompt, $callback);
if ($safeResult === false) {
throw ReadlineException::createFromPhpError();
}
}
/**
* This function clears the entire command line history.
*
* @throws ReadlineException
*
*/
function readline_clear_history(): void
{
error_clear_last();
$safeResult = \readline_clear_history();
if ($safeResult === false) {
throw ReadlineException::createFromPhpError();
}
}
/**
* This function registers a completion function. This is the same kind of
* functionality you'd get if you hit your tab key while using Bash.
*
* @param callable $callback You must supply the name of an existing function which accepts a
* partial command line and returns an array of possible matches.
* @throws ReadlineException
*
*/
function readline_completion_function(callable $callback): void
{
error_clear_last();
$safeResult = \readline_completion_function($callback);
if ($safeResult === false) {
throw ReadlineException::createFromPhpError();
}
}
/**
* This function reads a command history from a file.
*
* @param null|string $filename Path to the filename containing the command history.
* @throws ReadlineException
*
*/
function readline_read_history(?string $filename = null): void
{
error_clear_last();
if ($filename !== null) {
$safeResult = \readline_read_history($filename);
} else {
$safeResult = \readline_read_history();
}
if ($safeResult === false) {
throw ReadlineException::createFromPhpError();
}
}
/**
* This function writes the command history to a file.
*
* @param null|string $filename Path to the saved file.
* @throws ReadlineException
*
*/
function readline_write_history(?string $filename = null): void
{
error_clear_last();
if ($filename !== null) {
$safeResult = \readline_write_history($filename);
} else {
$safeResult = \readline_write_history();
}
if ($safeResult === false) {
throw ReadlineException::createFromPhpError();
}
}

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

0
vendor/thecodingmachine/safe/generated/8.2/rnp.php vendored Normal file → Executable file
View File

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,545 @@
<?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-z A-Z 0-9 , (comma) and -
* (minus) are allowed.
* @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-z A-Z 0-9 , (comma) and - (minus)!
* @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 output content when session.transid is
* enabled). Once the HTTP cookie is
* sent, session_name raises error.
* 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. For example,
* on Linux, reiserfs may provide better performance than ext2fs.
*
*
*
* On some operating systems, you may want to specify a path on a
* filesystem that handles lots of small files efficiently. For example,
* on Linux, reiserfs may provide better performance than ext2fs.
* @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,45 @@
<?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
* @param int $size The number of bytes to read.
* 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;
}

View File

@@ -0,0 +1,853 @@
<?php
namespace Safe;
use Safe\Exceptions\SocketsException;
/**
* After the socket socket has been created
* using socket_create, bound to a name with
* socket_bind, and told to listen for connections
* with socket_listen, this function will accept
* incoming connections on that socket. Once a successful connection
* is made, a new Socket instance is returned,
* which may be used for communication. If there are multiple connections
* queued on the socket, the first will be used. If there are no pending
* connections, socket_accept will block until
* a connection becomes present. If socket
* has been made non-blocking using
* socket_set_blocking or
* socket_set_nonblock, FALSE will be returned.
*
* The Socket instance returned by
* socket_accept may not be used to accept new
* connections. The original listening socket
* socket, however, remains open and may be
* reused.
*
* @param \Socket $socket A Socket instance created with socket_create.
* @return \Socket Returns a new Socket instance on success. The actual
* error code can be retrieved by calling
* socket_last_error. This error code may be passed to
* socket_strerror to get a textual explanation of the
* error.
* @throws SocketsException
*
*/
function socket_accept(\Socket $socket): \Socket
{
error_clear_last();
$safeResult = \socket_accept($socket);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Create a Socket instance, and bind it to the provided AddressInfo. The return
* value of this function may be used with socket_listen.
*
* @param \AddressInfo $address AddressInfo instance created from socket_addrinfo_lookup.
* @return \Socket Returns a Socket instance on success.
* @throws SocketsException
*
*/
function socket_addrinfo_bind(\AddressInfo $address): \Socket
{
error_clear_last();
$safeResult = \socket_addrinfo_bind($address);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Create a Socket instance, and connect it to the provided AddressInfo instance. The return
* value of this function may be used with the rest of the socket functions.
*
* @param \AddressInfo $address AddressInfo instance created from socket_addrinfo_lookup
* @return \Socket Returns a Socket instance on success.
* @throws SocketsException
*
*/
function socket_addrinfo_connect(\AddressInfo $address): \Socket
{
error_clear_last();
$safeResult = \socket_addrinfo_connect($address);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Lookup different ways we can connect to host. The returned array contains
* a set of AddressInfo instances that we can bind to using socket_addrinfo_bind.
*
* @param string $host Hostname to search.
* @param mixed $service The service to connect to. If service is a numeric string, it designates the port.
* Otherwise it designates a network service name, which is mapped to a port by the operating system.
* @param array $hints Hints provide criteria for selecting addresses returned. You may specify the
* hints as defined by getaddrinfo.
* @return \AddressInfo[] Returns an array of AddressInfo instances that can be used with the other socket_addrinfo functions.
* On failure, FALSE is returned.
* @throws SocketsException
*
*/
function socket_addrinfo_lookup(string $host, $service = null, array $hints = []): array
{
error_clear_last();
if ($hints !== []) {
$safeResult = \socket_addrinfo_lookup($host, $service, $hints);
} elseif ($service !== null) {
$safeResult = \socket_addrinfo_lookup($host, $service);
} else {
$safeResult = \socket_addrinfo_lookup($host);
}
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Binds the name given in address to the socket
* described by socket. This has to be done before
* a connection is be established using socket_connect
* or socket_listen.
*
* @param \Socket $socket A Socket instance created with socket_create.
* @param string $address If the socket is of the AF_INET family, the
* address is an IP in dotted-quad notation
* (e.g. 127.0.0.1).
*
* If the socket is of the AF_UNIX family, the
* address is the path of a
* Unix-domain socket (e.g. /tmp/my.sock).
* @param int $port The port parameter is only used when
* binding an AF_INET socket, and designates
* the port on which to listen for connections.
* @throws SocketsException
*
*/
function socket_bind(\Socket $socket, string $address, int $port = 0): void
{
error_clear_last();
$safeResult = \socket_bind($socket, $address, $port);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* Initiate a connection to address using the Socket instance
* socket, which must be Socket
* instance created with socket_create.
*
* @param \Socket $socket A Socket instance created with
* socket_create.
* @param string $address The address parameter is either an IPv4 address
* in dotted-quad notation (e.g. 127.0.0.1) if
* socket is AF_INET, a valid
* IPv6 address (e.g. ::1) if IPv6 support is enabled and
* socket is AF_INET6
* or the pathname of a Unix domain socket, if the socket family is
* AF_UNIX.
* @param int|null $port The port parameter is only used and is mandatory
* when connecting to an AF_INET or an
* AF_INET6 socket, and designates
* the port on the remote host to which a connection should be made.
* @throws SocketsException
*
*/
function socket_connect(\Socket $socket, string $address, ?int $port = null): void
{
error_clear_last();
if ($port !== null) {
$safeResult = \socket_connect($socket, $address, $port);
} else {
$safeResult = \socket_connect($socket, $address);
}
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* socket_create_listen creates a new Socket instance of
* type AF_INET listening on all
* local interfaces on the given port waiting for new connections.
*
* This function is meant to ease the task of creating a new socket which
* only listens to accept new connections.
*
* @param int $port The port on which to listen on all interfaces.
* @param int $backlog The backlog parameter defines the maximum length
* the queue of pending connections may grow to.
* SOMAXCONN may be passed as
* backlog parameter, see
* socket_listen for more information.
* @return \Socket socket_create_listen returns a new Socket instance
* on success. The error code can be retrieved with
* socket_last_error. This code may be passed to
* socket_strerror to get a textual explanation of the
* error.
* @throws SocketsException
*
*/
function socket_create_listen(int $port, int $backlog = 128): \Socket
{
error_clear_last();
$safeResult = \socket_create_listen($port, $backlog);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* socket_create_pair creates two connected and
* indistinguishable sockets, and stores them in pair.
* This function is commonly used in IPC (InterProcess Communication).
*
* @param int $domain The domain parameter specifies the protocol
* family to be used by the socket. See socket_create
* for the full list.
* @param int $type The type parameter selects the type of communication
* to be used by the socket. See socket_create for the
* full list.
* @param int $protocol The protocol parameter sets the specific
* protocol within the specified domain to be used
* when communicating on the returned socket. The proper value can be retrieved by
* name by using getprotobyname. If
* the desired protocol is TCP, or UDP the corresponding constants
* SOL_TCP, and SOL_UDP
* can also be used.
*
* See socket_create for the full list of supported
* protocols.
* @param \Socket[]|null $pair Reference to an array in which the two Socket instances will be inserted.
* @throws SocketsException
*
*/
function socket_create_pair(int $domain, int $type, int $protocol, ?array &$pair): void
{
error_clear_last();
$safeResult = \socket_create_pair($domain, $type, $protocol, $pair);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* Creates and returns a Socket instance, also referred to as an endpoint
* of communication. A typical network connection is made up of 2 sockets, one
* performing the role of the client, and another performing the role of the server.
*
* @param int $domain The domain parameter specifies the protocol
* family to be used by the socket.
* @param int $type The type parameter selects the type of communication
* to be used by the socket.
* @param int $protocol The protocol parameter sets the specific
* protocol within the specified domain to be used
* when communicating on the returned socket. The proper value can be
* retrieved by name by using getprotobyname. If
* the desired protocol is TCP, or UDP the corresponding constants
* SOL_TCP, and SOL_UDP
* can also be used.
* @return \Socket socket_create returns a Socket instance on success. The actual error code can be retrieved by calling
* socket_last_error. This error code may be passed to
* socket_strerror to get a textual explanation of the
* error.
* @throws SocketsException
*
*/
function socket_create(int $domain, int $type, int $protocol): \Socket
{
error_clear_last();
$safeResult = \socket_create($domain, $type, $protocol);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param \Socket $socket
* @return resource Return resource.
* @throws SocketsException
*
*/
function socket_export_stream(\Socket $socket)
{
error_clear_last();
$safeResult = \socket_export_stream($socket);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* The socket_get_option function retrieves the value for
* the option specified by the option parameter for the
* specified socket.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @param int $level The level parameter specifies the protocol
* level at which the option resides. For example, to retrieve options at
* the socket level, a level parameter of
* SOL_SOCKET would be used. Other levels, such as
* TCP, can be used by
* specifying the protocol number of that level. Protocol numbers can be
* found by using the getprotobyname function.
* @param int $option Reports whether the socket lingers on
* socket_close if data is present. By default,
* when the socket is closed, it attempts to send all unsent data.
* In the case of a connection-oriented socket,
* socket_close will wait for its peer to
* acknowledge the data.
*
* If l_onoff is non-zero and
* l_linger is zero, all the
* unsent data will be discarded and RST (reset) is sent to the
* peer in the case of a connection-oriented socket.
*
* On the other hand, if l_onoff is
* non-zero and l_linger is non-zero,
* socket_close will block until all the data
* is sent or the time specified in l_linger
* elapses. If the socket is non-blocking,
* socket_close will fail and return an error.
* @return mixed Returns the value of the given option.
* @throws SocketsException
*
*/
function socket_get_option(\Socket $socket, int $level, int $option)
{
error_clear_last();
$safeResult = \socket_get_option($socket, $level, $option);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Queries the remote side of the given socket which may either result in
* host/port or in a Unix filesystem path, dependent on its type.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @param null|string $address If the given socket is of type AF_INET or
* AF_INET6, socket_getpeername
* will return the peers (remote) IP address in
* appropriate notation (e.g. 127.0.0.1 or
* fe80::1) in the address
* parameter and, if the optional port parameter is
* present, also the associated port.
*
* If the given socket is of type AF_UNIX,
* socket_getpeername will return the Unix filesystem
* path (e.g. /var/run/daemon.sock) in the
* address parameter.
* @param int|null $port If given, this will hold the port associated to
* address.
* @throws SocketsException
*
*/
function socket_getpeername(\Socket $socket, ?string &$address, ?int &$port = null): void
{
error_clear_last();
$safeResult = \socket_getpeername($socket, $address, $port);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
*
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @param null|string $address If the given socket is of type AF_INET
* or AF_INET6, socket_getsockname
* will return the local IP address in appropriate notation (e.g.
* 127.0.0.1 or fe80::1) in the
* address parameter and, if the optional
* port parameter is present, also the associated port.
*
* If the given socket is of type AF_UNIX,
* socket_getsockname will return the Unix filesystem
* path (e.g. /var/run/daemon.sock) in the
* address parameter.
* @param int|null $port If provided, this will hold the associated port.
* @throws SocketsException
*
*/
function socket_getsockname(\Socket $socket, ?string &$address, ?int &$port = null): void
{
error_clear_last();
$safeResult = \socket_getsockname($socket, $address, $port);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* Imports a stream that encapsulates a socket into a socket extension resource.
*
* @param resource $stream The stream resource to import.
* @return \Socket Returns FALSE on failure.
* @throws SocketsException
*
*/
function socket_import_stream($stream): \Socket
{
error_clear_last();
$safeResult = \socket_import_stream($stream);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* After the socket socket has been created
* using socket_create and bound to a name with
* socket_bind, it may be told to listen for incoming
* connections on socket.
*
* socket_listen is applicable only to sockets of
* type SOCK_STREAM or
* SOCK_SEQPACKET.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_addrinfo_bind
* @param int $backlog A maximum of backlog incoming connections will be
* queued for processing. If a connection request arrives with the queue
* full the client may receive an error with an indication of
* ECONNREFUSED, or, if the underlying protocol supports
* retransmission, the request may be ignored so that retries may succeed.
*
* The maximum number passed to the backlog
* parameter highly depends on the underlying platform. On Linux, it is
* silently truncated to SOMAXCONN. On win32, if
* passed SOMAXCONN, the underlying service provider
* responsible for the socket will set the backlog to a maximum
* reasonable value. There is no standard provision to
* find out the actual backlog value on this platform.
* @throws SocketsException
*
*/
function socket_listen(\Socket $socket, int $backlog = 0): void
{
error_clear_last();
$safeResult = \socket_listen($socket, $backlog);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* The function socket_read reads from the Socket instance
* socket created by the
* socket_create or
* socket_accept functions.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @param int $length The maximum number of bytes read is specified by the
* length parameter. Otherwise you can use
* \r, \n,
* or \0 to end reading (depending on the mode
* parameter, see below).
* @param int $mode Optional mode parameter is a named constant:
*
*
*
* PHP_BINARY_READ (Default) - use the system
* recv() function. Safe for reading binary data.
*
*
*
*
* PHP_NORMAL_READ - reading stops at
* \n or \r.
*
*
*
* @return string socket_read returns the data as a string on success (including if the remote host has closed the
* connection). The error code can be retrieved with
* socket_last_error. This code may be passed to
* socket_strerror to get a textual representation of
* the error.
* @throws SocketsException
*
*/
function socket_read(\Socket $socket, int $length, int $mode = PHP_BINARY_READ): string
{
error_clear_last();
$safeResult = \socket_read($socket, $length, $mode);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* The function socket_send sends
* length bytes to the socket
* socket from data.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @param string $data A buffer containing the data that will be sent to the remote host.
* @param int $length The number of bytes that will be sent to the remote host from
* data.
* @param int $flags The value of flags can be any combination of
* the following flags, joined with the binary OR (|)
* operator.
*
* Possible values for flags
*
*
*
* MSG_OOB
*
* Send OOB (out-of-band) data.
*
*
*
* MSG_EOR
*
* Indicate a record mark. The sent data completes the record.
*
*
*
* MSG_EOF
*
* Close the sender side of the socket and include an appropriate
* notification of this at the end of the sent data. The sent data
* completes the transaction.
*
*
*
* MSG_DONTROUTE
*
* Bypass routing, use direct interface.
*
*
*
*
*
* @return int socket_send returns the number of bytes sent.
* @throws SocketsException
*
*/
function socket_send(\Socket $socket, string $data, int $length, int $flags): int
{
error_clear_last();
$safeResult = \socket_send($socket, $data, $length, $flags);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param \Socket $socket
* @param array $message
* @param int $flags
* @return int Returns the number of bytes sent.
* @throws SocketsException
*
*/
function socket_sendmsg(\Socket $socket, array $message, int $flags = 0): int
{
error_clear_last();
$safeResult = \socket_sendmsg($socket, $message, $flags);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* The function socket_sendto sends
* length bytes from data
* through the socket socket to the
* port at the address address.
*
* @param \Socket $socket A Socket instance created using socket_create.
* @param string $data The sent data will be taken from buffer data.
* @param int $length length bytes from data will be
* sent.
* @param int $flags The value of flags can be any combination of
* the following flags, joined with the binary OR (|)
* operator.
*
* Possible values for flags
*
*
*
* MSG_OOB
*
* Send OOB (out-of-band) data.
*
*
*
* MSG_EOR
*
* Indicate a record mark. The sent data completes the record.
*
*
*
* MSG_EOF
*
* Close the sender side of the socket and include an appropriate
* notification of this at the end of the sent data. The sent data
* completes the transaction.
*
*
*
* MSG_DONTROUTE
*
* Bypass routing, use direct interface.
*
*
*
*
*
* @param string $address IP address of the remote host.
* @param int|null $port port is the remote port number at which the data
* will be sent.
* @return int socket_sendto returns the number of bytes sent to the
* remote host.
* @throws SocketsException
*
*/
function socket_sendto(\Socket $socket, string $data, int $length, int $flags, string $address, ?int $port = null): int
{
error_clear_last();
if ($port !== null) {
$safeResult = \socket_sendto($socket, $data, $length, $flags, $address, $port);
} else {
$safeResult = \socket_sendto($socket, $data, $length, $flags, $address);
}
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* The socket_set_block function removes the
* O_NONBLOCK flag on the socket specified by the
* socket parameter.
*
* When an operation (e.g. receive, send, connect, accept, ...) is performed on
* a blocking socket, the script will pause its execution until it receives
* a signal or it can perform the operation.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @throws SocketsException
*
*/
function socket_set_block(\Socket $socket): void
{
error_clear_last();
$safeResult = \socket_set_block($socket);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* The socket_set_nonblock function sets the
* O_NONBLOCK flag on the socket specified by
* the socket parameter.
*
* When an operation (e.g. receive, send, connect, accept, ...) is performed on
* a non-blocking socket, the script will not pause its execution until it receives a
* signal or it can perform the operation. Rather, if the operation would result
* in a block, the called function will fail.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @throws SocketsException
*
*/
function socket_set_nonblock(\Socket $socket): void
{
error_clear_last();
$safeResult = \socket_set_nonblock($socket);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* The socket_set_option function sets the option
* specified by the option parameter, at the
* specified protocol level, to the value pointed to
* by the value parameter for the
* socket.
*
* @param \Socket $socket A Socket instance created with socket_create
* or socket_accept.
* @param int $level The level parameter specifies the protocol
* level at which the option resides. For example, to set options at
* the socket level, a level parameter of
* SOL_SOCKET would be used. Other levels, such as
* TCP, can be used by specifying the protocol number of that level.
* Protocol numbers can be found by using the
* getprotobyname function.
* @param int $option The available socket options are the same as those for the
* socket_get_option function.
* @param array|int|string $value The option value.
* @throws SocketsException
*
*/
function socket_set_option(\Socket $socket, int $level, int $option, $value): void
{
error_clear_last();
$safeResult = \socket_set_option($socket, $level, $option, $value);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* The socket_shutdown function allows you to stop
* incoming, outgoing or all data (the default) from being sent through the
* socket
*
* @param \Socket $socket A Socket instance created with socket_create.
* @param int $mode The value of mode can be one of the following:
*
* possible values for mode
*
*
*
* 0
*
* Shutdown socket reading
*
*
*
* 1
*
* Shutdown socket writing
*
*
*
* 2
*
* Shutdown socket reading and writing
*
*
*
*
*
* @throws SocketsException
*
*/
function socket_shutdown(\Socket $socket, int $mode = 2): void
{
error_clear_last();
$safeResult = \socket_shutdown($socket, $mode);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}
/**
* Exports the WSAPROTOCOL_INFO structure into shared memory and returns
* an identifier to be used with socket_wsaprotocol_info_import. The
* exported ID is only valid for the given process_id.
*
* @param \Socket $socket A Socket instance.
* @param int $process_id The ID of the process which will import the socket.
* @return string Returns an identifier to be used for the import
* @throws SocketsException
*
*/
function socket_wsaprotocol_info_export(\Socket $socket, int $process_id): string
{
error_clear_last();
$safeResult = \socket_wsaprotocol_info_export($socket, $process_id);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Imports a socket which has formerly been exported from another process.
*
* @param string $info_id The ID which has been returned by a former call to
* socket_wsaprotocol_info_export.
* @return \Socket Returns a Socket instance on success
* @throws SocketsException
*
*/
function socket_wsaprotocol_info_import(string $info_id): \Socket
{
error_clear_last();
$safeResult = \socket_wsaprotocol_info_import($info_id);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
return $safeResult;
}
/**
* Releases the shared memory corresponding to the given info_id.
*
* @param string $info_id The ID which has been returned by a former call to
* socket_wsaprotocol_info_export.
* @throws SocketsException
*
*/
function socket_wsaprotocol_info_release(string $info_id): void
{
error_clear_last();
$safeResult = \socket_wsaprotocol_info_release($info_id);
if ($safeResult === false) {
throw SocketsException::createFromPhpError();
}
}

0
vendor/thecodingmachine/safe/generated/8.2/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,136 @@
<?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 call __autoload by default.
* @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 call __autoload by default.
* @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 call __autoload by default.
* @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.
* @param bool $throw This parameter specifies whether
* spl_autoload_register should throw
* exceptions when the callback
* cannot be registered.
* @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;
}

0
vendor/thecodingmachine/safe/generated/8.2/ssh2.php vendored Normal file → Executable file
View File

0
vendor/thecodingmachine/safe/generated/8.2/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();
}
}

File diff suppressed because it is too large Load Diff

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;
}

View File

@@ -0,0 +1,716 @@
<?php
namespace Safe;
use Safe\Exceptions\XmlException;
/**
* Frees the given XML parser.
*
* @param \XMLParser $parser
* @throws XmlException
*
*/
function xml_parser_free(\XMLParser $parser): void
{
error_clear_last();
$safeResult = \xml_parser_free($parser);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the character data handler function for the XML parser
* parser.
*
* @param \XMLParser $parser A reference to the XML parser to set up character data handler function.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* two parameters:
*
* handler
* XMLParserparser
* stringdata
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* data
*
*
* The second parameter, data, contains
* the character data as a string.
*
*
*
*
*
* Character data handler is called for every piece of a text in the XML
* document. It can be called multiple times inside each fragment (e.g.
* for non-ASCII strings).
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_character_data_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_character_data_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the default handler function for the XML parser
* parser.
*
* @param \XMLParser $parser A reference to the XML parser to set up default handler function.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* two parameters:
*
* handler
* XMLParserparser
* stringdata
*
*
*
*
* parser
*
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
*
* data
*
*
*
* The second parameter, data, contains
* the character data.This may be the XML declaration,
* document type declaration, entities or other data for which
* no other handler exists.
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_default_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_default_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the element handler functions for the XML parser.
* start_handler and
* end_handler are strings containing
* the names of functions that must exist when xml_parse
* is called for parser.
*
* @param \XMLParser $parser A reference to the XML parser to set up start and end element handler functions.
* @param callable $start_handler The function named by start_handler
* must accept three parameters:
*
* start_element_handler
* XMLParserparser
* stringname
* arrayattribs
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* name
*
*
* The second parameter, name, contains the name
* of the element for which this handler is called.If case-folding is in effect for this
* parser, the element name will be in uppercase letters.
*
*
*
*
* attribs
*
*
* The third parameter, attribs, contains an
* associative array with the element's attributes (if any).The keys
* of this array are the attribute names, the values are the attribute
* values.Attribute names are case-folded on the same criteria as
* element names.Attribute values are not
* case-folded.
*
*
* The original order of the attributes can be retrieved by walking
* through attribs the normal way, using
* each.The first key in the array was the first
* attribute, and so on.
*
*
*
*
* @param callable $end_handler
* @throws XmlException
*
*/
function xml_set_element_handler(\XMLParser $parser, callable $start_handler, callable $end_handler): void
{
error_clear_last();
$safeResult = \xml_set_element_handler($parser, $start_handler, $end_handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Set a handler to be called when leaving the scope of a namespace
* declaration. This will be called, for each namespace declaration, after
* the handler for the end tag of the element in which the namespace was
* declared.
*
* @param \XMLParser $parser A reference to the XML parser.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* two parameters, and should return an integer value. If the
* value returned from the handler is FALSE (which it will be if no
* value is returned), the XML parser will stop parsing and
* xml_get_error_code will return
* XML_ERROR_EXTERNAL_ENTITY_HANDLING.
*
* handler
* XMLParserparser
* stringprefix
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* prefix
*
*
* The prefix is a string used to reference the namespace within an XML object.
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_end_namespace_decl_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_end_namespace_decl_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the external entity reference handler function for the XML parser
* parser.
*
* @param \XMLParser $parser A reference to the XML parser to set up external entity reference handler function.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* five parameters, and should return an integer value.If the
* value returned from the handler is FALSE (which it will be if no
* value is returned), the XML parser will stop parsing and
* xml_get_error_code will return
* XML_ERROR_EXTERNAL_ENTITY_HANDLING.
*
* handler
* XMLParserparser
* stringopen_entity_names
* stringbase
* stringsystem_id
* stringpublic_id
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* open_entity_names
*
*
* The second parameter, open_entity_names, is a
* space-separated list of the names of the entities that are open for
* the parse of this entity (including the name of the referenced
* entity).
*
*
*
*
* base
*
*
* This is the base for resolving the system identifier
* (system_id) of the external entity.Currently
* this parameter will always be set to an empty string.
*
*
*
*
* system_id
*
*
* The fourth parameter, system_id, is the
* system identifier as specified in the entity declaration.
*
*
*
*
* public_id
*
*
* The fifth parameter, public_id, is the
* public identifier as specified in the entity declaration, or
* an empty string if none was specified; the whitespace in the
* public identifier will have been normalized as required by
* the XML spec.
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_external_entity_ref_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_external_entity_ref_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the notation declaration handler function for the XML parser
* parser.
*
* A notation declaration is part of the document's DTD and has the
* following format:
*
* name
* { systemId | publicId?>
* ]]>
*
* See section 4.7 of the XML 1.0
* spec for the definition of notation declarations.
*
* @param \XMLParser $parser A reference to the XML parser to set up notation declaration handler function.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* five parameters:
*
* handler
* XMLParserparser
* stringnotation_name
* stringbase
* stringsystem_id
* stringpublic_id
*
*
*
*
* parser
*
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* notation_name
*
*
* This is the notation's name, as per
* the notation format described above.
*
*
*
*
*
* base
*
*
*
* This is the base for resolving the system identifier
* (system_id) of the notation declaration.
* Currently this parameter will always be set to an empty string.
*
*
*
*
* system_id
*
*
* System identifier of the external notation declaration.
*
*
*
*
*
* public_id
*
*
*
* Public identifier of the external notation declaration.
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_notation_decl_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_notation_decl_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* This function allows to use parser inside
* object. All callback functions could be set with
* xml_set_element_handler etc and assumed to be
* methods of object.
*
* @param \XMLParser $parser A reference to the XML parser to use inside the object.
* @param object $object The object where to use the XML parser.
* @throws XmlException
*
*/
function xml_set_object(\XMLParser $parser, object $object): void
{
error_clear_last();
$safeResult = \xml_set_object($parser, $object);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the processing instruction (PI) handler function for the XML parser
* parser.
*
* A processing instruction has the following format:
*
* &lt;?target
* data?&gt;
*
*
* You can put PHP code into such a tag, but be aware of one limitation: in
* an XML PI, the PI end tag (?&gt;) can not be quoted,
* so this character sequence should not appear in the PHP code you embed
* with PIs in XML documents.If it does, the rest of the PHP code, as well
* as the "real" PI end tag, will be treated as character data.
*
* @param \XMLParser $parser A reference to the XML parser to set up processing instruction (PI) handler function.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* three parameters:
*
* handler
* XMLParserparser
* stringtarget
* stringdata
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* target
*
*
* The second parameter, target, contains the PI
* target.
*
*
*
*
* data
*
*
* The third parameter, data, contains the PI
* data.
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_processing_instruction_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_processing_instruction_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Set a handler to be called when a namespace is declared. Namespace
* declarations occur inside start tags. But the namespace declaration start
* handler is called before the start tag handler for each namespace declared
* in that start tag.
*
* @param \XMLParser $parser A reference to the XML parser.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept
* three parameters, and should return an integer value. If the
* value returned from the handler is FALSE (which it will be if no
* value is returned), the XML parser will stop parsing and
* xml_get_error_code will return
* XML_ERROR_EXTERNAL_ENTITY_HANDLING.
*
* handler
* XMLParserparser
* stringprefix
* stringuri
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the handler.
*
*
*
*
* prefix
*
*
* The prefix is a string used to reference the namespace within an XML object.
*
*
*
*
* uri
*
*
* Uniform Resource Identifier (URI) of namespace.
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_start_namespace_decl_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_start_namespace_decl_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}
/**
* Sets the unparsed entity declaration handler function for the XML parser
* parser.
*
* The handler will be called if the XML parser
* encounters an external entity declaration with an NDATA declaration, like
* the following:
*
* name {publicId | systemId}
* NDATA notationName
* ]]>
*
*
* See section 4.2.2 of
* the XML 1.0 spec for the definition of notation declared
* external entities.
*
* @param \XMLParser $parser A reference to the XML parser to set up unparsed entity declaration handler function.
* @param callable $handler handler is a string containing the name of a
* function that must exist when xml_parse is called
* for parser.
*
* The function named by handler must accept six
* parameters:
*
* handler
* XMLParserparser
* stringentity_name
* stringbase
* stringsystem_id
* stringpublic_id
* stringnotation_name
*
*
*
* parser
*
*
* The first parameter, parser, is a
* reference to the XML parser calling the
* handler.
*
*
*
*
* entity_name
*
*
* The name of the entity that is about to be defined.
*
*
*
*
* base
*
*
* This is the base for resolving the system identifier
* (systemId) of the external entity.Currently
* this parameter will always be set to an empty string.
*
*
*
*
* system_id
*
*
* System identifier for the external entity.
*
*
*
*
* public_id
*
*
* Public identifier for the external entity.
*
*
*
*
* notation_name
*
*
* Name of the notation of this entity (see
* xml_set_notation_decl_handler).
*
*
*
*
*
* If a handler function is set to an empty string, or FALSE, the handler
* in question is disabled.
* @throws XmlException
*
*/
function xml_set_unparsed_entity_decl_handler(\XMLParser $parser, callable $handler): void
{
error_clear_last();
$safeResult = \xml_set_unparsed_entity_decl_handler($parser, $handler);
if ($safeResult === false) {
throw XmlException::createFromPhpError();
}
}

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 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_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
* @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_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;
}

View File

@@ -0,0 +1,713 @@
<?php
namespace Safe;
use Safe\Exceptions\ZlibException;
/**
* Incrementally deflates data in the specified context.
*
* @param \DeflateContext $context A context created with deflate_init.
* @param string $data A chunk of data to compress.
* @param int $flush_mode One of ZLIB_BLOCK,
* ZLIB_NO_FLUSH,
* ZLIB_PARTIAL_FLUSH,
* ZLIB_SYNC_FLUSH (default),
* ZLIB_FULL_FLUSH, ZLIB_FINISH.
* Normally you will want to set ZLIB_NO_FLUSH to
* maximize compression, and ZLIB_FINISH to terminate
* with the last chunk of data. See the zlib manual for a
* detailed description of these constants.
* @return string Returns a chunk of compressed data.
* @throws ZlibException
*
*/
function deflate_add(\DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string
{
error_clear_last();
$safeResult = \deflate_add($context, $data, $flush_mode);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Initializes an incremental deflate context using the specified
* encoding.
*
* Note that the window option here only sets the window size
* of the algorithm, differently from the zlib filters where the same parameter
* also sets the encoding to use; the encoding must be set with the
* encoding parameter.
*
* Limitation: there is currently no way to set the header information on a GZIP
* compressed stream, which are set as follows: GZIP signature
* (\x1f\x8B); compression method (\x08
* == DEFLATE); 6 zero bytes; the operating system set to the current system
* (\x00 = Windows, \x03 = Unix, etc.)
*
* @param int $encoding One of the ZLIB_ENCODING_* constants.
* @param array $options An associative array which may contain the following elements:
*
*
* level
*
*
* The compression level in range -1..9; defaults to -1.
*
*
*
*
* memory
*
*
* The compression memory level in range 1..9; defaults to 8.
*
*
*
*
* window
*
*
* The zlib window size (logarithmic) in range 8..15;
* defaults to 15.
* zlib changes a window size of 8 to 9,
* and as of zlib 1.2.8 fails with a warning, if a window size of 8
* is requested for ZLIB_ENCODING_RAW or ZLIB_ENCODING_GZIP.
*
*
*
*
* strategy
*
*
* One of ZLIB_FILTERED,
* ZLIB_HUFFMAN_ONLY, ZLIB_RLE,
* ZLIB_FIXED or
* ZLIB_DEFAULT_STRATEGY (the default).
*
*
*
*
* dictionary
*
*
* A string or an array of strings
* of the preset dictionary (default: no preset dictionary).
*
*
*
*
*
* The compression level in range -1..9; defaults to -1.
*
* The compression memory level in range 1..9; defaults to 8.
*
* The zlib window size (logarithmic) in range 8..15;
* defaults to 15.
* zlib changes a window size of 8 to 9,
* and as of zlib 1.2.8 fails with a warning, if a window size of 8
* is requested for ZLIB_ENCODING_RAW or ZLIB_ENCODING_GZIP.
*
* One of ZLIB_FILTERED,
* ZLIB_HUFFMAN_ONLY, ZLIB_RLE,
* ZLIB_FIXED or
* ZLIB_DEFAULT_STRATEGY (the default).
*
* A string or an array of strings
* of the preset dictionary (default: no preset dictionary).
* @return \DeflateContext Returns a deflate context resource (zlib.deflate) on
* success.
* @throws ZlibException
*
*/
function deflate_init(int $encoding, array $options = []): \DeflateContext
{
error_clear_last();
$safeResult = \deflate_init($encoding, $options);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Closes the given gz-file pointer.
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @throws ZlibException
*
*/
function gzclose($stream): void
{
error_clear_last();
$safeResult = \gzclose($stream);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
}
/**
* This function compresses the given string using the ZLIB
* data format.
*
* For details on the ZLIB compression algorithm see the document
* "ZLIB Compressed Data Format
* Specification version 3.3" (RFC 1950).
*
* @param string $data The data to compress.
* @param int $level The level of compression. Can be given as 0 for no compression up to 9
* for maximum compression.
*
* If -1 is used, the default compression of the zlib library is used which is 6.
* @param int $encoding One of ZLIB_ENCODING_* constants.
* @return string The compressed string.
* @throws ZlibException
*
*/
function gzcompress(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_DEFLATE): string
{
error_clear_last();
$safeResult = \gzcompress($data, $level, $encoding);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* This function returns a decoded version of the input
* data.
*
* @param string $data The data to decode, encoded by gzencode.
* @param int $max_length The maximum length of data to decode.
* @return string The decoded string, or.
* @throws ZlibException
*
*/
function gzdecode(string $data, int $max_length = 0): string
{
error_clear_last();
$safeResult = \gzdecode($data, $max_length);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* This function compresses the given string using the DEFLATE
* data format.
*
* For details on the DEFLATE compression algorithm see the document
* "DEFLATE Compressed Data Format
* Specification version 1.3" (RFC 1951).
*
* @param string $data The data to deflate.
* @param int $level The level of compression. Can be given as 0 for no compression up to 9
* for maximum compression. If not given, the default compression level will
* be the default compression level of the zlib library.
* @param int $encoding One of ZLIB_ENCODING_* constants.
* @return string The deflated string.
* @throws ZlibException
*
*/
function gzdeflate(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_RAW): string
{
error_clear_last();
$safeResult = \gzdeflate($data, $level, $encoding);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* This function returns a compressed version of the input
* data compatible with the output of the
* gzip program.
*
* For more information on the GZIP file format, see the document:
* GZIP file format specification
* version 4.3 (RFC 1952).
*
* @param string $data The data to encode.
* @param int $level The level of compression. Can be given as 0 for no compression up to 9
* for maximum compression. If not given, the default compression level will
* be the default compression level of the zlib library.
* @param int $encoding The encoding mode. Can be FORCE_GZIP (the default)
* or FORCE_DEFLATE.
*
* FORCE_DEFLATE generates
* RFC 1950 compliant output, consisting of a zlib header, the deflated
* data, and an Adler checksum.
* @return string The encoded string.
* @throws ZlibException
*
*/
function gzencode(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_GZIP): string
{
error_clear_last();
$safeResult = \gzencode($data, $level, $encoding);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* This function is identical to readgzfile, except that
* it returns the file in an array.
*
* @param string $filename The file name.
* @param int $use_include_path You can set this optional parameter to 1, if you
* want to search for the file in the include_path too.
* @return list An array containing the file, one line per cell, empty lines included, and with newlines still attached.
* @throws ZlibException
*
*/
function gzfile(string $filename, int $use_include_path = 0): array
{
error_clear_last();
$safeResult = \gzfile($filename, $use_include_path);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Gets a (uncompressed) string of up to length - 1 bytes read from the given
* file pointer. Reading ends when length - 1 bytes have been read, on a
* newline, or on EOF (whichever comes first).
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @param int|null $length The length of data to get.
* @return string The uncompressed string.
* @throws ZlibException
*
*/
function gzgets($stream, ?int $length = null): string
{
error_clear_last();
if ($length !== null) {
$safeResult = \gzgets($stream, $length);
} else {
$safeResult = \gzgets($stream);
}
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* This function inflates a deflated string.
*
* @param string $data The data compressed by gzdeflate.
* @param int $max_length The maximum length of decoded data.
* @return string The original uncompressed data.
*
* The function will return an error if the uncompressed data is more than
* 32768 times the length of the compressed input data
* or, unless max_length is 0, more than the optional parameter max_length.
* @throws ZlibException
*
*/
function gzinflate(string $data, int $max_length = 0): string
{
error_clear_last();
$safeResult = \gzinflate($data, $max_length);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Opens a gzip (.gz) file for reading or writing.
*
* gzopen can be used to read a file which is
* not in gzip format; in this case gzread will
* directly read from the file without decompression.
*
* @param string $filename The file name.
* @param string $mode As in fopen (rb or
* wb) but can also include a compression level
* (wb9) or a strategy: f for
* filtered data as in wb6f, h for
* Huffman only compression as in wb1h.
* (See the description of deflateInit2
* in zlib.h for
* more information about the strategy parameter.)
* @param int $use_include_path You can set this optional parameter to 1, if you
* want to search for the file in the include_path too.
* @return resource Returns a file pointer to the file opened, after that, everything you read
* from this file descriptor will be transparently decompressed and what you
* write gets compressed.
*
* If the open fails, the function returns FALSE.
* @throws ZlibException
*
*/
function gzopen(string $filename, string $mode, int $use_include_path = 0)
{
error_clear_last();
$safeResult = \gzopen($filename, $mode, $use_include_path);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Reads to EOF on the given gz-file pointer from the current position and
* writes the (uncompressed) results to standard output.
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @return int The number of uncompressed characters read from gz
* and passed through to the input.
* @throws ZlibException
*
*/
function gzpassthru($stream): int
{
error_clear_last();
$safeResult = \gzpassthru($stream);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* gzread reads up to length bytes
* from the given gz-file pointer. Reading stops when
* length (uncompressed) bytes have been read
* or EOF is reached, whichever comes first.
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @param int $length The number of bytes to read.
* @return string The data that have been read.
* @throws ZlibException
*
*/
function gzread($stream, int $length): string
{
error_clear_last();
$safeResult = \gzread($stream, $length);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Sets the file position indicator of the given gz-file pointer to the
* beginning of the file stream.
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @throws ZlibException
*
*/
function gzrewind($stream): void
{
error_clear_last();
$safeResult = \gzrewind($stream);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
}
/**
* Gets the position of the given file pointer; i.e., its offset into the
* uncompressed file stream.
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @return int The position of the file pointer or FALSE if an error occurs.
* @throws ZlibException
*
*/
function gztell($stream): int
{
error_clear_last();
$safeResult = \gztell($stream);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* This function uncompress a compressed string.
*
* @param string $data The data compressed by gzcompress.
* @param int $max_length The maximum length of data to decode.
* @return string The original uncompressed data.
*
* The function will return an error if the uncompressed data is more than
* 32768 times the length of the compressed input data
* or more than the optional parameter max_length.
* @throws ZlibException
*
*/
function gzuncompress(string $data, int $max_length = 0): string
{
error_clear_last();
$safeResult = \gzuncompress($data, $max_length);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* gzwrite writes the contents of
* data to the given gz-file.
*
* @param resource $stream The gz-file pointer. It must be valid, and must point to a file
* successfully opened by gzopen.
* @param string $data The string to write.
* @param int|null $length The number of uncompressed bytes to write. 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 (uncompressed) bytes written to the given gz-file
* stream.
* @throws ZlibException
*
*/
function gzwrite($stream, string $data, ?int $length = null): int
{
error_clear_last();
if ($length !== null) {
$safeResult = \gzwrite($stream, $data, $length);
} else {
$safeResult = \gzwrite($stream, $data);
}
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
*
*
* @param \InflateContext $context
* @return int Returns number of bytes read so far.
* @throws ZlibException
*
*/
function inflate_get_read_len(\InflateContext $context): int
{
error_clear_last();
$safeResult = \inflate_get_read_len($context);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Usually returns either ZLIB_OK or ZLIB_STREAM_END.
*
* @param \InflateContext $context
* @return int Returns decompression status.
* @throws ZlibException
*
*/
function inflate_get_status(\InflateContext $context): int
{
error_clear_last();
$safeResult = \inflate_get_status($context);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Incrementally inflates encoded data in the specified context.
*
* Limitation: header information from GZIP compressed data are not made
* available.
*
* @param \InflateContext $context A context created with inflate_init.
* @param string $data A chunk of compressed data.
* @param int $flush_mode One of ZLIB_BLOCK,
* ZLIB_NO_FLUSH,
* ZLIB_PARTIAL_FLUSH,
* ZLIB_SYNC_FLUSH (default),
* ZLIB_FULL_FLUSH, ZLIB_FINISH.
* Normally you will want to set ZLIB_NO_FLUSH to
* maximize compression, and ZLIB_FINISH to terminate
* with the last chunk of data. See the zlib manual for a
* detailed description of these constants.
* @return string Returns a chunk of uncompressed data.
* @throws ZlibException
*
*/
function inflate_add(\InflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string
{
error_clear_last();
$safeResult = \inflate_add($context, $data, $flush_mode);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Initialize an incremental inflate context with the specified
* encoding.
*
* @param int $encoding One of the ZLIB_ENCODING_* constants.
* @param array $options An associative array which may contain the following elements:
*
*
* level
*
*
* The compression level in range -1..9; defaults to -1.
*
*
*
*
* memory
*
*
* The compression memory level in range 1..9; defaults to 8.
*
*
*
*
* window
*
*
* The zlib window size (logarithmic) in range 8..15; defaults to 15.
*
*
*
*
* strategy
*
*
* One of ZLIB_FILTERED,
* ZLIB_HUFFMAN_ONLY, ZLIB_RLE,
* ZLIB_FIXED or
* ZLIB_DEFAULT_STRATEGY (the default).
*
*
*
*
* dictionary
*
*
* A string or an array of strings
* of the preset dictionary (default: no preset dictionary).
*
*
*
*
*
* The compression level in range -1..9; defaults to -1.
*
* The compression memory level in range 1..9; defaults to 8.
*
* The zlib window size (logarithmic) in range 8..15; defaults to 15.
*
* One of ZLIB_FILTERED,
* ZLIB_HUFFMAN_ONLY, ZLIB_RLE,
* ZLIB_FIXED or
* ZLIB_DEFAULT_STRATEGY (the default).
*
* A string or an array of strings
* of the preset dictionary (default: no preset dictionary).
* @return \InflateContext Returns an inflate context resource (zlib.inflate) on
* success.
* @throws ZlibException
*
*/
function inflate_init(int $encoding, array $options = []): \InflateContext
{
error_clear_last();
$safeResult = \inflate_init($encoding, $options);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Reads a file, decompresses it and writes it to standard output.
*
* readgzfile can be used to read a file which is not in
* gzip format; in this case readgzfile will directly
* read from the file without decompression.
*
* @param string $filename The file name. This file will be opened from the filesystem and its
* contents written to standard output.
* @param int $use_include_path You can set this optional parameter to 1, if you
* want to search for the file in the include_path too.
* @return 0|positive-int Returns the number of (uncompressed) bytes read from the file on success
* @throws ZlibException
*
*/
function readgzfile(string $filename, int $use_include_path = 0): int
{
error_clear_last();
$safeResult = \readgzfile($filename, $use_include_path);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}
/**
* Uncompress any raw/gzip/zlib encoded data.
*
* @param string $data
* @param int $max_length
* @return string Returns the uncompressed data.
* @throws ZlibException
*
*/
function zlib_decode(string $data, int $max_length = 0): string
{
error_clear_last();
$safeResult = \zlib_decode($data, $max_length);
if ($safeResult === false) {
throw ZlibException::createFromPhpError();
}
return $safeResult;
}