diff options
Diffstat (limited to 'vendor/thecodingmachine/safe/generated')
78 files changed, 11118 insertions, 8936 deletions
diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/PdfException.php b/vendor/thecodingmachine/safe/generated/Exceptions/GettextException.php index bcf36b3ce..0228ce234 100644 --- a/vendor/thecodingmachine/safe/generated/Exceptions/PdfException.php +++ b/vendor/thecodingmachine/safe/generated/Exceptions/GettextException.php @@ -1,7 +1,7 @@ <?php namespace Safe\Exceptions; -class PdfException extends \ErrorException implements SafeExceptionInterface +class GettextException extends \ErrorException implements SafeExceptionInterface { public static function createFromPhpError(): self { diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/IngresiiException.php b/vendor/thecodingmachine/safe/generated/Exceptions/IngresiiException.php deleted file mode 100644 index ca40822e9..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/IngresiiException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class IngresiiException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/MsqlException.php b/vendor/thecodingmachine/safe/generated/Exceptions/MsqlException.php deleted file mode 100644 index c67314ea8..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/MsqlException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class MsqlException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/MysqliException.php b/vendor/thecodingmachine/safe/generated/Exceptions/MysqliException.php deleted file mode 100644 index 4cadf6ca1..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/MysqliException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class MysqliException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/MysqlndMsException.php b/vendor/thecodingmachine/safe/generated/Exceptions/MysqlndMsException.php deleted file mode 100644 index 5e9b55944..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/MysqlndMsException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class MysqlndMsException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/MysqlndQcException.php b/vendor/thecodingmachine/safe/generated/Exceptions/MysqlndQcException.php deleted file mode 100644 index 4db9f4911..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/MysqlndQcException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class MysqlndQcException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/PasswordException.php b/vendor/thecodingmachine/safe/generated/Exceptions/PasswordException.php deleted file mode 100644 index f0edba123..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/PasswordException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class PasswordException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/Exceptions/SimplexmlException.php b/vendor/thecodingmachine/safe/generated/Exceptions/SimplexmlException.php deleted file mode 100644 index 67804e133..000000000 --- a/vendor/thecodingmachine/safe/generated/Exceptions/SimplexmlException.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -namespace Safe\Exceptions; - -class SimplexmlException extends \ErrorException implements SafeExceptionInterface -{ - public static function createFromPhpError(): self - { - $error = error_get_last(); - return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); - } -} diff --git a/vendor/thecodingmachine/safe/generated/apache.php b/vendor/thecodingmachine/safe/generated/apache.php index e71c32d7b..2bb3632a9 100644 --- a/vendor/thecodingmachine/safe/generated/apache.php +++ b/vendor/thecodingmachine/safe/generated/apache.php @@ -26,8 +26,6 @@ function apache_get_version(): string * Retrieve an Apache environment variable specified by * variable. * - * This function requires Apache 2 otherwise it's undefined. - * * @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 @@ -46,18 +44,46 @@ function apache_getenv(string $variable, bool $walk_to_top = false): string /** - * Fetches all HTTP request headers from the current request. Works in the - * Apache, FastCGI, CLI, FPM and NSAPI server module - * in Netscape/iPlanet/SunONE webservers. - * - * @return array An associative array of all the HTTP headers in the current request. + * 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_request_headers(): array +function apache_lookup_uri(string $filename): object { error_clear_last(); - $result = \apache_request_headers(); + $result = \apache_lookup_uri($filename); if ($result === false) { throw ApacheException::createFromPhpError(); } @@ -66,31 +92,27 @@ function apache_request_headers(): array /** - * apache_reset_timeout resets the Apache write timer, - * which defaults to 300 seconds. With set_time_limit(0); - * ignore_user_abort(true) and periodic - * apache_reset_timeout calls, Apache can theoretically - * run forever. - * - * This function requires Apache 1. + * 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_reset_timeout(): void +function apache_request_headers(): array { error_clear_last(); - $result = \apache_reset_timeout(); + $result = \apache_request_headers(); if ($result === false) { throw ApacheException::createFromPhpError(); } + return $result; } /** * Fetch all HTTP response headers. Works in the - * Apache, FastCGI, CLI, FPM and NSAPI server module - * in Netscape/iPlanet/SunONE webservers. + * Apache, FastCGI, CLI, and FPM webservers. * * @return array An array of all Apache response headers on success. * @throws ApacheException @@ -163,14 +185,14 @@ function getallheaders(): array * To run the sub-request, all buffers are terminated and flushed to the * browser, pending headers are sent too. * - * @param string $filename The file that the virtual command will be performed on. + * @param string $uri The file that the virtual command will be performed on. * @throws ApacheException * */ -function virtual(string $filename): void +function virtual(string $uri): void { error_clear_last(); - $result = \virtual($filename); + $result = \virtual($uri); if ($result === false) { throw ApacheException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/array.php b/vendor/thecodingmachine/safe/generated/array.php index 80c90ff81..39a77b5e4 100644 --- a/vendor/thecodingmachine/safe/generated/array.php +++ b/vendor/thecodingmachine/safe/generated/array.php @@ -5,140 +5,11 @@ namespace Safe; use Safe\Exceptions\ArrayException; /** - * Creates an array by using the values from the - * keys array as keys and the values from the - * values array as the corresponding values. - * - * @param array $keys Array of keys to be used. Illegal values for key will be - * converted to string. - * @param array $values Array of values to be used - * @return array Returns the combined array, FALSE if the number of elements - * for each array isn't equal. - * @throws ArrayException - * - */ -function array_combine(array $keys, array $values): array -{ - error_clear_last(); - $result = \array_combine($keys, $values); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - -/** - * array_flip returns an array in flip - * order, i.e. keys from array become values and values - * from array become keys. - * - * Note that the values of array need to be valid - * keys, i.e. they need to be either integer or - * string. A warning will be emitted if a value has the wrong - * type, and the key/value pair in question will not be included - * in the result. - * - * If a value has several occurrences, the latest key will be - * used as its value, and all others will be lost. - * - * @param array $array An array of key/value pairs to be flipped. - * @return array Returns the flipped array on success. - * @throws ArrayException - * - */ -function array_flip(array $array): array -{ - error_clear_last(); - $result = \array_flip($array); - if ($result === null) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - -/** - * array_replace_recursive replaces the values of - * array1 with the same values from all the following - * arrays. If a key from the first array exists in the second array, its value - * will be replaced by the value from the second array. If the key exists in the - * second array, and not the first, it will be created in the first array. - * If a key only exists in the first array, it will be left as is. - * If several arrays are passed for replacement, they will be processed - * in order, the later array overwriting the previous values. - * - * array_replace_recursive is recursive : it will recurse into - * arrays and apply the same process to the inner value. - * - * When the value in the first array is scalar, it will be replaced - * by the value in the second array, may it be scalar or array. - * When the value in the first array and the second array - * are both arrays, array_replace_recursive will replace - * their respective value recursively. - * - * @param array $array1 The array in which elements are replaced. - * @param array $params Optional. Arrays from which elements will be extracted. - * @return array Returns an array. - * @throws ArrayException - * - */ -function array_replace_recursive(array $array1, array ...$params): array -{ - error_clear_last(); - if ($params !== []) { - $result = \array_replace_recursive($array1, ...$params); - } else { - $result = \array_replace_recursive($array1); - } - if ($result === null) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - -/** - * array_replace replaces the values of - * array1 with values having the same keys in each of the following - * arrays. If a key from the first array exists in the second array, its value - * will be replaced by the value from the second array. If the key exists in the - * second array, and not the first, it will be created in the first array. - * If a key only exists in the first array, it will be left as is. - * If several arrays are passed for replacement, they will be processed - * in order, the later arrays overwriting the previous values. - * - * array_replace is not recursive : it will replace - * values in the first array by whatever type is in the second array. - * - * @param array $array1 The array in which elements are replaced. - * @param array $params Arrays from which elements will be extracted. - * Values from later arrays overwrite the previous values. - * @return array Returns an array. - * @throws ArrayException - * - */ -function array_replace(array $array1, array ...$params): array -{ - error_clear_last(); - if ($params !== []) { - $result = \array_replace($array1, ...$params); - } else { - $result = \array_replace($array1); - } - if ($result === null) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - -/** * Applies the user-defined callback function to each * element of the array. This function will recurse * into deeper arrays. * - * @param array $array The input array. + * @param array|object $array The input array. * @param callable $callback Typically, callback takes on two parameters. * The array parameter's value being the first, and * the key/index second. @@ -149,168 +20,20 @@ function array_replace(array $array1, array ...$params): array * reference. Then, * any changes made to those elements will be made in the * original array itself. - * @param mixed $userdata If the optional userdata parameter is supplied, + * @param mixed $arg If the optional arg parameter is supplied, * it will be passed as the third parameter to the * callback. * @throws ArrayException * */ -function array_walk_recursive(array &$array, callable $callback, $userdata = null): void -{ - error_clear_last(); - $result = \array_walk_recursive($array, $callback, $userdata); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * This function sorts an array such that array indices maintain their - * correlation with the array elements they are associated with. - * - * This is used mainly when sorting associative arrays where the actual - * element order is significant. - * - * @param array $array The input array. - * @param int $sort_flags You may modify the behavior of the sort using the optional parameter - * sort_flags, for details see - * sort. - * @throws ArrayException - * - */ -function arsort(array &$array, int $sort_flags = SORT_REGULAR): void -{ - error_clear_last(); - $result = \arsort($array, $sort_flags); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * This function sorts an array such that array indices maintain - * their correlation with the array elements they are associated - * with. This is used mainly when sorting associative arrays where - * the actual element order is significant. - * - * @param array $array The input array. - * @param int $sort_flags You may modify the behavior of the sort using the optional - * parameter sort_flags, for details - * see sort. - * @throws ArrayException - * - */ -function asort(array &$array, int $sort_flags = SORT_REGULAR): void -{ - error_clear_last(); - $result = \asort($array, $sort_flags); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * Sorts an array by key in reverse order, maintaining key to data - * correlations. This is useful mainly for associative arrays. - * - * @param array $array The input array. - * @param int $sort_flags You may modify the behavior of the sort using the optional parameter - * sort_flags, for details see - * sort. - * @throws ArrayException - * - */ -function krsort(array &$array, int $sort_flags = SORT_REGULAR): void -{ - error_clear_last(); - $result = \krsort($array, $sort_flags); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * Sorts an array by key, maintaining key to data correlations. This is - * useful mainly for associative arrays. - * - * @param array $array The input array. - * @param int $sort_flags You may modify the behavior of the sort using the optional - * parameter sort_flags, for details - * see sort. - * @throws ArrayException - * - */ -function ksort(array &$array, int $sort_flags = SORT_REGULAR): void -{ - error_clear_last(); - $result = \ksort($array, $sort_flags); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * natcasesort is a case insensitive version of - * natsort. - * - * This function implements a sort algorithm that orders - * alphanumeric strings in the way a human being would while maintaining - * key/value associations. This is described as a "natural ordering". - * - * @param array $array The input array. - * @throws ArrayException - * - */ -function natcasesort(array &$array): void +function array_walk_recursive(&$array, callable $callback, $arg = null): void { error_clear_last(); - $result = \natcasesort($array); - if ($result === false) { - throw ArrayException::createFromPhpError(); + if ($arg !== null) { + $result = \array_walk_recursive($array, $callback, $arg); + } else { + $result = \array_walk_recursive($array, $callback); } -} - - -/** - * This function implements a sort algorithm that orders alphanumeric strings - * in the way a human being would while maintaining key/value associations. - * This is described as a "natural ordering". An example of the difference - * between this algorithm and the regular computer string sorting algorithms - * (used in sort) can be seen in the example below. - * - * @param array $array The input array. - * @throws ArrayException - * - */ -function natsort(array &$array): void -{ - error_clear_last(); - $result = \natsort($array); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * This function sorts an array in reverse order (highest to lowest). - * - * @param array $array The input array. - * @param int $sort_flags You may modify the behavior of the sort using the optional - * parameter sort_flags, for details see - * sort. - * @throws ArrayException - * - */ -function rsort(array &$array, int $sort_flags = SORT_REGULAR): void -{ - error_clear_last(); - $result = \rsort($array, $sort_flags); if ($result === false) { throw ArrayException::createFromPhpError(); } @@ -334,131 +57,3 @@ function shuffle(array &$array): void throw ArrayException::createFromPhpError(); } } - - -/** - * This function sorts an array. Elements will be arranged from - * lowest to highest when this function has completed. - * - * @param array $array The input array. - * @param int $sort_flags The optional second parameter sort_flags - * may be used to modify the sorting behavior using these values: - * - * Sorting type flags: - * - * - * SORT_REGULAR - compare items normally; - * the details are described in the comparison operators section - * - * - * SORT_NUMERIC - compare items numerically - * - * - * SORT_STRING - compare items as strings - * - * - * - * SORT_LOCALE_STRING - compare items as - * strings, based on the current locale. It uses the locale, - * which can be changed using setlocale - * - * - * - * - * SORT_NATURAL - compare items as strings - * using "natural ordering" like natsort - * - * - * - * - * SORT_FLAG_CASE - can be combined - * (bitwise OR) with - * SORT_STRING or - * SORT_NATURAL to sort strings case-insensitively - * - * - * - * @throws ArrayException - * - */ -function sort(array &$array, int $sort_flags = SORT_REGULAR): void -{ - error_clear_last(); - $result = \sort($array, $sort_flags); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * This function sorts an array such that array indices maintain their - * correlation with the array elements they are associated with, using a - * user-defined comparison function. - * - * This is used mainly when sorting associative arrays where the actual - * element order is significant. - * - * @param array $array The input array. - * @param callable $value_compare_func See usort and uksort for - * examples of user-defined comparison functions. - * @throws ArrayException - * - */ -function uasort(array &$array, callable $value_compare_func): void -{ - error_clear_last(); - $result = \uasort($array, $value_compare_func); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * uksort will sort the keys of an array using a - * user-supplied comparison function. If the array you wish to sort - * needs to be sorted by some non-trivial criteria, you should use - * this function. - * - * @param array $array The input array. - * @param callable $key_compare_func The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. - * Note that before PHP 7.0.0 this integer had to be in the range from -2147483648 to 2147483647. - * @throws ArrayException - * - */ -function uksort(array &$array, callable $key_compare_func): void -{ - error_clear_last(); - $result = \uksort($array, $key_compare_func); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} - - -/** - * This function will sort an array by its values using a user-supplied - * comparison function. If the array you wish to sort needs to be sorted by - * some non-trivial criteria, you should use this function. - * - * @param array $array The input array. - * @param callable $value_compare_func The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. - * Note that before PHP 7.0.0 this integer had to be in the range from -2147483648 to 2147483647. - * - * Returning non-integer values from the comparison - * function, such as float, will result in an internal cast to - * integer of the callback's return value. So values such as - * 0.99 and 0.1 will both be cast to an integer value of 0, which will - * compare such values as equal. - * @throws ArrayException - * - */ -function usort(array &$array, callable $value_compare_func): void -{ - error_clear_last(); - $result = \usort($array, $value_compare_func); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } -} diff --git a/vendor/thecodingmachine/safe/generated/bzip2.php b/vendor/thecodingmachine/safe/generated/bzip2.php index 77302aa00..8087c748a 100644 --- a/vendor/thecodingmachine/safe/generated/bzip2.php +++ b/vendor/thecodingmachine/safe/generated/bzip2.php @@ -23,8 +23,9 @@ function bzclose($bz): void /** - * Forces a write of all buffered bzip2 data for the file pointer - * bz. + * 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. diff --git a/vendor/thecodingmachine/safe/generated/calendar.php b/vendor/thecodingmachine/safe/generated/calendar.php index aae699923..a5b03905e 100644 --- a/vendor/thecodingmachine/safe/generated/calendar.php +++ b/vendor/thecodingmachine/safe/generated/calendar.php @@ -5,21 +5,24 @@ namespace Safe; use Safe\Exceptions\CalendarException; /** - * This function will return a Unix timestamp corresponding to the - * Julian Day given in jday or FALSE if - * jday is outside of the allowed range. The time returned is - * UTC. + * 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 $jday A julian day number between 2440588 and 106751993607888 - * on 64bit systems, or between 2440588 and 2465443 on 32bit systems. - * @return int The unix timestamp for the start (midnight, not noon) of the given Julian day. + * @param int $timestamp A unix timestamp to convert. + * @return int A julian day number as integer. * @throws CalendarException * */ -function jdtounix(int $jday): int +function unixtojd(int $timestamp = null): int { error_clear_last(); - $result = \jdtounix($jday); + if ($timestamp !== null) { + $result = \unixtojd($timestamp); + } else { + $result = \unixtojd(); + } if ($result === false) { throw CalendarException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/classobj.php b/vendor/thecodingmachine/safe/generated/classobj.php index 98147ac26..dd2535aef 100644 --- a/vendor/thecodingmachine/safe/generated/classobj.php +++ b/vendor/thecodingmachine/safe/generated/classobj.php @@ -6,19 +6,19 @@ use Safe\Exceptions\ClassobjException; /** * Creates an alias named alias - * based on the user defined class original. + * based on the user defined class class. * The aliased class is exactly the same as the original class. * - * @param string $original 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 $original, string $alias, bool $autoload = true): void +function class_alias(string $class, string $alias, bool $autoload = true): void { error_clear_last(); - $result = \class_alias($original, $alias, $autoload); + $result = \class_alias($class, $alias, $autoload); if ($result === false) { throw ClassobjException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/com.php b/vendor/thecodingmachine/safe/generated/com.php index 53643f9d7..68e058f2d 100644 --- a/vendor/thecodingmachine/safe/generated/com.php +++ b/vendor/thecodingmachine/safe/generated/com.php @@ -5,34 +5,55 @@ 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(); + $result = \com_create_guid(); + if ($result === false) { + throw ComException::createFromPhpError(); + } + return $result; +} + + +/** * Instructs COM to sink events generated by - * comobject into the PHP object - * sinkobject. + * 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 $comobject - * @param object $sinkobject sinkobject should be an instance of a class with + * @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 $sinkinterface PHP will attempt to use the default dispinterface type specified by - * the typelibrary associated with comobject, but + * @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 - * sinkinterface to the name of the dispinterface + * sink_interface to the name of the dispinterface * that you want to use. * @throws ComException * */ -function com_event_sink(object $comobject, object $sinkobject, $sinkinterface = null): void +function com_event_sink(object $variant, object $sink_object, $sink_interface = null): void { error_clear_last(); - if ($sinkinterface !== null) { - $result = \com_event_sink($comobject, $sinkobject, $sinkinterface); + if ($sink_interface !== null) { + $result = \com_event_sink($variant, $sink_object, $sink_interface); } else { - $result = \com_event_sink($comobject, $sinkobject); + $result = \com_event_sink($variant, $sink_object); } if ($result === false) { throw ComException::createFromPhpError(); @@ -44,15 +65,15 @@ function com_event_sink(object $comobject, object $sinkobject, $sinkinterface = * 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 configuration setting to pre-load and + * 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 you have turned on , then + * 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_name typelib_name can be one of the following: + * @param string $typelib typelib can be one of the following: * * * @@ -86,16 +107,16 @@ function com_event_sink(object $comobject, object $sinkobject, $sinkinterface = * * The type library name, e.g. Microsoft OLE DB ActiveX Data * Objects 1.0 Library. - * @param bool $case_sensitive The case_sensitive behaves inversely to + * @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_name, bool $case_sensitive = true): void +function com_load_typelib(string $typelib, bool $case_insensitive = true): void { error_clear_last(); - $result = \com_load_typelib($typelib_name, $case_sensitive); + $result = \com_load_typelib($typelib, $case_insensitive); if ($result === false) { throw ComException::createFromPhpError(); } @@ -108,20 +129,68 @@ function com_load_typelib(string $typelib_name, bool $case_sensitive = true): vo * 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 $comobject comobject should be either an instance of a COM + * @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 string $dispinterface The name of an IDispatch descendant interface that you want to display. - * @param bool $wantsink If set to TRUE, the corresponding sink interface will be displayed + * @param 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 $comobject, string $dispinterface = null, bool $wantsink = false): void +function com_print_typeinfo(object $variant, string $dispatch_interface = null, bool $display_sink = false): void { error_clear_last(); - $result = \com_print_typeinfo($comobject, $dispinterface, $wantsink); + if ($display_sink !== false) { + $result = \com_print_typeinfo($variant, $dispatch_interface, $display_sink); + } elseif ($dispatch_interface !== null) { + $result = \com_print_typeinfo($variant, $dispatch_interface); + } else { + $result = \com_print_typeinfo($variant); + } if ($result === 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(); + $result = \variant_date_to_timestamp($variant); + if ($result === null) { + throw ComException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \variant_round($value, $decimals); + if ($result === null) { + throw ComException::createFromPhpError(); + } + return $result; +} diff --git a/vendor/thecodingmachine/safe/generated/cubrid.php b/vendor/thecodingmachine/safe/generated/cubrid.php index f19f2d56e..559bc9735 100644 --- a/vendor/thecodingmachine/safe/generated/cubrid.php +++ b/vendor/thecodingmachine/safe/generated/cubrid.php @@ -5,6 +5,433 @@ namespace Safe; use Safe\Exceptions\CubridException; /** + * The cubrid_bind function is used to bind values to a + * corresponding named or question mark placeholder in the SQL statement that + * was passed to cubrid_prepare. If + * bind_value_type is not given, string will be the + * default. + * + * The following table shows the types of substitute values. + * + * + * CUBRID Bind Date Types + * + * + * + * Support + * Bind Type + * Corresponding SQL Type + * + * + * + * + * Supported + * STRING + * CHAR, VARCHAR + * + * + * + * NCHAR + * NCHAR, NVARCHAR + * + * + * + * BIT + * BIT, VARBIT + * + * + * + * NUMERIC or NUMBER + * SHORT, INT, NUMERIC + * + * + * + * FLOAT + * FLOAT + * + * + * + * DOUBLE + * DOUBLE + * + * + * + * TIME + * TIME + * + * + * + * DATE + * DATE + * + * + * + * TIMESTAMP + * TIMESTAMP + * + * + * + * OBJECT + * OBJECT + * + * + * + * ENUM + * ENUM + * + * + * + * BLOB + * BLOB + * + * + * + * CLOB + * CLOB + * + * + * + * NULL + * NULL + * + * + * Not supported + * SET + * SET + * + * + * + * MULTISET + * MULTISET + * + * + * + * SEQUENCE + * SEQUENCE + * + * + * + * + * + * @param resource $req_identifier Request identifier as a result of + * cubrid_prepare. + * @param int $bind_index Location of binding parameters. It starts with 1. + * @param mixed $bind_value Actual value for binding. + * @param string $bind_value_type A type of the value to bind. (It is omitted by default. + * Thus, the system internally uses string by default. However, you need to + * specify the exact type of the value as an argument when they are NCHAR, + * BIT, or BLOB/CLOB). + * @throws CubridException + * + */ +function cubrid_bind($req_identifier, int $bind_index, $bind_value, string $bind_value_type = null): void +{ + error_clear_last(); + if ($bind_value_type !== null) { + $result = \cubrid_bind($req_identifier, $bind_index, $bind_value, $bind_value_type); + } else { + $result = \cubrid_bind($req_identifier, $bind_index, $bind_value); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_col_size function is used to get the + * number of elements in a collection type (set, multiset, sequence) + * attribute. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID the instance that you want to work with. + * @param string $attr_name Name of the attribute that you want to work with. + * @return int Number of elements, when process is successful. + * @throws CubridException + * + */ +function cubrid_col_size($conn_identifier, string $oid, string $attr_name): int +{ + error_clear_last(); + $result = \cubrid_col_size($conn_identifier, $oid, $attr_name); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_column_names function is used to get the + * column names of the query result by using req_identifier. + * + * @param resource $req_identifier Request identifier. + * @return array Array of string values containing the column names, when process is successful. + * @throws CubridException + * + */ +function cubrid_column_names($req_identifier): array +{ + error_clear_last(); + $result = \cubrid_column_names($req_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_column_types function gets column types of + * query results by using req_identifier. + * + * @param resource $req_identifier Request identifier. + * @return array Array of string values containing the column types, when process is successful. + * @throws CubridException + * + */ +function cubrid_column_types($req_identifier): array +{ + error_clear_last(); + $result = \cubrid_column_types($req_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_commit function is used to execute commit + * on the transaction pointed by conn_identifier, + * currently in progress. Connection to the server is closed after the + * cubrid_commit function is called; However, + * the connection handle is still valid. + * + * In CUBRID PHP, auto-commit mode is disabled by default for transaction management. + * You can set it by using cubrid_set_autocommit. + * You can get its status by using cubrid_get_autocommit. Before you start a transaction, + * remember to disable the auto-commit mode. + * + * @param resource $conn_identifier Connection identifier. + * @throws CubridException + * + */ +function cubrid_commit($conn_identifier): void +{ + error_clear_last(); + $result = \cubrid_commit($conn_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_connect_with_url function is used to + * establish the environment for connecting to your server by using connection + * information passed with an url string argument. If the HA feature is + * enabled in CUBRID, you must specify the connection information of the + * standby server, which is used for failover when failure occurs, in the url + * string argument of this function. If the user name and password is not + * given, then the "PUBLIC" connection will be made by default. + * + * <url> ::= CUBRID:<host>:<db_name>:<db_user>:<db_password>:[?<properties>] + * + * <properties> ::= <property> [&<property>] + * + * <properties> ::= alhosts=<alternative_hosts>[ &rctime=<time>] + * + * <properties> ::= login_timeout=<milli_sec> + * + * <properties> ::= query_timeout=<milli_sec> + * + * <properties> ::= disconnect_on_query_timeout=true|false + * + * <alternative_hosts> ::= <standby_broker1_host>:<port> [,<standby_broker2_host>:<port>] + * + * <host> := HOSTNAME | IP_ADDR + * + * <time> := SECOND + * + * <milli_sec> := MILLI SECOND + * + * + * host : A host name or IP address of the master database + * db_name : A name of the database + * db_user : A name of the database user + * db_password : A database user password + * + * alhosts : Specifies the broker information of the standby server, which is + * used for failover when it is impossible to connect to the active server. + * You can specify multiple brokers for failover, and the connection to the brokers + * is attempted in the order listed in alhosts + * + * rctime : An interval between the attempts to connect to the active broker in + * which failure occurred. After a failure occurs, the system connects to the + * broker specified by althosts (failover), terminates the transaction, and then + * attempts to connect to the active broker of the master database at every rctime. + * The default value is 600 seconds. + * + * login_timeout : Timeout value (unit: msec.) for database login. The default + * value is 0, which means infinite postponement. + * + * + * query_timeout : Timeout value (unit: msec.) for query request. Upon timeout, + * a message to cancel requesting a query transferred to server is sent. The return + * value can depend on the disconnect_on_query_timeout configuration; even though the + * message to cancel a request is sent to server, that request may succeed. + * + * + * disconnect_on_query_timeout : Configures a value whether to immediately return + * an error of function being executed upon timeout. The default value is false. + * + * + * + * @param string $conn_url A character string that contains server connection information. + * @param string $userid User name for the database. + * @param string $passwd User password. + * @param bool $new_link If a second call is made to + * cubrid_connect_with_url with the same arguments, + * no new connection will be established, but instead, the connection + * identifier of the already opened connection will be returned. The + * new_link parameter modifies this behavior and + * makes cubrid_connect_with_url always open a new + * connection, even if cubrid_connect_with_url was + * called before with the same parameters. + * @return resource Connection identifier, when process is successful. + * @throws CubridException + * + */ +function cubrid_connect_with_url(string $conn_url, string $userid = null, string $passwd = null, bool $new_link = false) +{ + error_clear_last(); + if ($new_link !== false) { + $result = \cubrid_connect_with_url($conn_url, $userid, $passwd, $new_link); + } elseif ($passwd !== null) { + $result = \cubrid_connect_with_url($conn_url, $userid, $passwd); + } elseif ($userid !== null) { + $result = \cubrid_connect_with_url($conn_url, $userid); + } else { + $result = \cubrid_connect_with_url($conn_url); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_connect function is used to establish the + * environment for connecting to your server by using your server address, + * port number, database name, user name, and password. If the user name and + * password is not given, then the "PUBLIC" connection will be made by + * default. + * + * @param string $host Host name or IP address of CUBRID CAS server. + * @param int $port Port number of CUBRID CAS server (BROKER_PORT configured in $CUBRID/conf/cubrid_broker.conf). + * @param string $dbname Name of database. + * @param string $userid User name for the database. If not given, the default + * value is "public". + * @param string $passwd User password. If not given, the default value is "". + * @param bool $new_link If a second call is made to + * cubrid_connect with the same arguments, no new + * connection will be established, but instead, the connection identifier + * of the already opened connection will be returned. The + * new_link parameter modifies this behavior and + * makes cubrid_connect always open a new connection, + * even if cubrid_connect was called before with the + * same parameters. + * @return resource Connection identifier, when process is successful. + * @throws CubridException + * + */ +function cubrid_connect(string $host, int $port, string $dbname, string $userid = null, string $passwd = null, bool $new_link = false) +{ + error_clear_last(); + if ($new_link !== false) { + $result = \cubrid_connect($host, $port, $dbname, $userid, $passwd, $new_link); + } elseif ($passwd !== null) { + $result = \cubrid_connect($host, $port, $dbname, $userid, $passwd); + } elseif ($userid !== null) { + $result = \cubrid_connect($host, $port, $dbname, $userid); + } else { + $result = \cubrid_connect($host, $port, $dbname); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_current_oid function is used to get the + * oid of the current cursor location from the query result. To use + * cubrid_current_oid, the query executed must be a + * updatable query, and the CUBRID_INCLUDE_OID option must be included during + * the query execution. + * + * @param resource $req_identifier Request identifier. + * @return string Oid of current cursor location, when process is successful. + * @throws CubridException + * + */ +function cubrid_current_oid($req_identifier): string +{ + error_clear_last(); + $result = \cubrid_current_oid($req_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_disconnect function closes the connection + * handle and disconnects from server. If any request handle is not closed at this point, + * it will be closed. It is similar to the CUBRID MySQL compatible function cubrid_close. + * + * @param resource $conn_identifier Connection identifier. + * @throws CubridException + * + */ +function cubrid_disconnect($conn_identifier = null): void +{ + error_clear_last(); + if ($conn_identifier !== null) { + $result = \cubrid_disconnect($conn_identifier); + } else { + $result = \cubrid_disconnect(); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_drop function is used to delete an + * instance from database by using the oid of the instance. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid Oid of the instance that you want to delete. + * @throws CubridException + * + */ +function cubrid_drop($conn_identifier, string $oid): void +{ + error_clear_last(); + $result = \cubrid_drop($conn_identifier, $oid); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** * This function frees the memory occupied by the result data. It returns * TRUE on success. Note that it can only frees the * client fetch buffer now, and if you want free all memory, use function @@ -30,9 +457,7 @@ function cubrid_free_result($req_identifier): void * cubrid_client_encoding. * * @param resource $conn_identifier The CUBRID connection. - * @return string A string that represents the CUBRID connection charset; on success. - * - * FALSE on failure. + * @return string A string that represents the CUBRID connection charset on success. * @throws CubridException * */ @@ -48,11 +473,31 @@ function cubrid_get_charset($conn_identifier): string /** - * This function returns a string that represents the client library version. + * The cubrid_get_class_name function is used to get the + * class name from oid. It doesn't work when selecting data from the system tables, + * for example db_class. * - * @return string A string that represents the client library version; on success. + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance that you want to check the existence. + * @return string Class name when process is successful. + * @throws CubridException * - * FALSE on failure. + */ +function cubrid_get_class_name($conn_identifier, string $oid): string +{ + error_clear_last(); + $result = \cubrid_get_class_name($conn_identifier, $oid); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * This function returns a string that represents the client library version. + * + * @return string A string that represents the client library version on success. * @throws CubridException * */ @@ -68,9 +513,8 @@ function cubrid_get_client_info(): string /** - * This function returns the CUBRID database parameters or it returns FALSE on - * failure. It returns an associative array with the values for the following - * parameters: + * This function returns the CUBRID database parameters. + * It returns an associative array with the values for the following parameters: * * * PARAM_ISOLATION_LEVEL @@ -178,8 +622,6 @@ function cubrid_get_client_info(): string * @param resource $conn_identifier The CUBRID connection. If the connection identifier is not specified, * the last link opened by cubrid_connect is assumed. * @return array An associative array with CUBRID database parameters; on success. - * - * FALSE on failure. * @throws CubridException * */ @@ -195,12 +637,30 @@ function cubrid_get_db_parameter($conn_identifier): array /** + * The cubrid_get_query_timeout function is used to get + * the query timeout of the request. + * + * @param resource $req_identifier Request identifier. + * @return int Returns the query timeout value in milliseconds of the current request on success. + * @throws CubridException + * + */ +function cubrid_get_query_timeout($req_identifier): int +{ + error_clear_last(); + $result = \cubrid_get_query_timeout($req_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** * This function returns a string that represents the CUBRID server version. * * @param resource $conn_identifier The CUBRID connection. - * @return string A string that represents the CUBRID server version; on success. - * - * FALSE on failure. + * @return string A string that represents the CUBRID server version on success. * @throws CubridException * */ @@ -248,6 +708,199 @@ function cubrid_insert_id($conn_identifier = null): string /** + * cubrid_lob_close is used to close all BLOB/CLOB + * returned from cubrid_lob_get. + * + * @param array $lob_identifier_array LOB identifier array returned from cubrid_lob_get. + * @throws CubridException + * + */ +function cubrid_lob_close(array $lob_identifier_array): void +{ + error_clear_last(); + $result = \cubrid_lob_close($lob_identifier_array); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * cubrid_lob_export is used to get BLOB/CLOB data from CUBRID database, and saves its contents to a file. + * To use this function, you must use cubrid_lob_get first to get BLOB/CLOB info from CUBRID. + * + * @param resource $conn_identifier Connection identifier. + * @param resource $lob_identifier LOB identifier. + * @param string $path_name Path name of the file. + * @throws CubridException + * + */ +function cubrid_lob_export($conn_identifier, $lob_identifier, string $path_name): void +{ + error_clear_last(); + $result = \cubrid_lob_export($conn_identifier, $lob_identifier, $path_name); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * cubrid_lob_get is used to get BLOB/CLOB meta info from CUBRID database, + * CUBRID gets BLOB/CLOB by executing the SQL statement, and returns all LOBs as a resource array. + * Be sure that the SQL retrieves only one column and its data type is BLOB or CLOB. + * + * Remember to use cubrid_lob_close to release the LOBs if you don't need it any more. + * + * @param resource $conn_identifier Connection identifier. + * @param string $sql SQL statement to be executed. + * @return array Return an array of LOB resources, when process is successful. + * @throws CubridException + * + */ +function cubrid_lob_get($conn_identifier, string $sql): array +{ + error_clear_last(); + $result = \cubrid_lob_get($conn_identifier, $sql); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * cubrid_lob_send reads BLOB/CLOB data and passes it straight through to the browser. + * To use this function, you must use cubrid_lob_get first to get BLOB/CLOB info from CUBRID. + * + * @param resource $conn_identifier Connection identifier. + * @param resource $lob_identifier LOB identifier. + * @throws CubridException + * + */ +function cubrid_lob_send($conn_identifier, $lob_identifier): void +{ + error_clear_last(); + $result = \cubrid_lob_send($conn_identifier, $lob_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * cubrid_lob_size is used to get BLOB/CLOB data size. + * + * @param resource $lob_identifier LOB identifier. + * @return string A string representing LOB data size, when process is successful. + * @throws CubridException + * + */ +function cubrid_lob_size($lob_identifier): string +{ + error_clear_last(); + $result = \cubrid_lob_size($lob_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_lob2_bind function is used to bind BLOB/CLOB datas + * to a corresponding question mark placeholder in the SQL statement that was passed + * to cubrid_prepare. If bind_value_type + * is not given, string will be "BLOB" as the default. But if you use + * cubrid_lob2_new before, bind_value_type + * will be consistent with type in cubrid_lob2_new as the default. + * + * @param resource $req_identifier Request identifier as a result of cubrid_prepare. + * @param int $bind_index Location of binding parameters. It starts with 1. + * @param mixed $bind_value Actual value for binding. + * @param string $bind_value_type It must be "BLOB" or "CLOB" and it won't be case-sensitive. If it not be given, the default value is "BLOB". + * @throws CubridException + * + */ +function cubrid_lob2_bind($req_identifier, int $bind_index, $bind_value, string $bind_value_type = null): void +{ + error_clear_last(); + if ($bind_value_type !== null) { + $result = \cubrid_lob2_bind($req_identifier, $bind_index, $bind_value, $bind_value_type); + } else { + $result = \cubrid_lob2_bind($req_identifier, $bind_index, $bind_value); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_lob2_close function is used to close LOB object + * returned from cubrid_lob2_new or got from the result set. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @throws CubridException + * + */ +function cubrid_lob2_close($lob_identifier): void +{ + error_clear_last(); + $result = \cubrid_lob2_close($lob_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_lob2_export function is used to save the + * contents of BLOB/CLOB data to a file. To use this function, you must use + * cubrid_lob2_new or fetch a lob object from CUBRID + * database first. If the file already exists, the operation will fail. + * This function will not influence the cursor position of the lob object. + * It operates the entire lob object. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @param string $file_name File name you want to store BLOB/CLOB data. It also supports the path of the file. + * @throws CubridException + * + */ +function cubrid_lob2_export($lob_identifier, string $file_name): void +{ + error_clear_last(); + $result = \cubrid_lob2_export($lob_identifier, $file_name); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_lob2_import function is used to save the + * contents of BLOB/CLOB data from a file. To use this function, you must use + * cubrid_lob2_new or fetch a lob object from CUBRID database + * first. If the file already exists, the operation will fail. + * This function will not influence the cursor position of the lob object. + * It operates the entire lob object. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @param string $file_name File name you want to import BLOB/CLOB data. It also supports the path of the file. + * @throws CubridException + * + */ +function cubrid_lob2_import($lob_identifier, string $file_name): void +{ + error_clear_last(); + $result = \cubrid_lob2_import($lob_identifier, $file_name); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** * The cubrid_lob2_new function is used to create a lob object (both BLOB and CLOB). * This function should be used before you bind a lob object. * @@ -256,8 +909,6 @@ function cubrid_insert_id($conn_identifier = null): string * cubrid_connect_with_url is assumed. * @param string $type It may be "BLOB" or "CLOB", it won't be case-sensitive. The default value is "BLOB". * @return resource Lob identifier when it is successful. - * - * FALSE on failure. * @throws CubridException * */ @@ -279,12 +930,108 @@ function cubrid_lob2_new($conn_identifier = null, string $type = "BLOB") /** + * The cubrid_lob2_read function reads len bytes from the + * LOB data and returns the bytes read. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @param int $len Length from buffer you want to read from the lob data. + * @return string Returns the contents as a string, FALSE when there is no more data. + * @throws CubridException + * + */ +function cubrid_lob2_read($lob_identifier, int $len): string +{ + error_clear_last(); + $result = \cubrid_lob2_read($lob_identifier, $len); + if ($result === null) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_lob2_seek function is used to move the cursor + * position of a lob object by the value set in the offset + * argument, to the direction set in the origin argument. + * + * To set the origin argument, you can use CUBRID_CURSOR_FIRST + * to set the cursor position moving forward offset units from + * the first beginning. In this case, offset must be a positive value. + * + * If you use CUBRID_CURSOR_CURRENT for origin, you can move + * forward or backward. and offset can be positive or negative. + * + * If you use CUBRID_CURSOR_LAST for origin, you can move + * backward offset units from the end of LOB object and + * offset only can be positive. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @param int $offset Number of units you want to move the cursor. + * @param int $origin This parameter can be the following values: + * + * CUBRID_CURSOR_FIRST: move forward from the first beginning. + * + * CUBRID_CURSOR_CURRENT: move forward or backward from the current position. + * + * CUBRID_CURSOR_LAST: move backward at the end of LOB object. + * @throws CubridException + * + */ +function cubrid_lob2_seek($lob_identifier, int $offset, int $origin = CUBRID_CURSOR_CURRENT): void +{ + error_clear_last(); + $result = \cubrid_lob2_seek($lob_identifier, $offset, $origin); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_lob2_seek64 function is used to move the cursor + * position of a lob object by the value set in the offset + * argument, to the direction set in the origin argument. + * If the offset you want to move is larger than an integer + * data can be stored, you can use this function. + * + * To set the origin argument, you can use CUBRID_CURSOR_FIRST + * to set the cursor position moving forward offset units from + * the first beginning. In this case, offset must be a positive value. + * + * If you use CUBRID_CURSOR_CURRENT for origin, you can move + * forward or backward. and offset can be positive or negative. + * + * If you use CUBRID_CURSOR_LAST for origin, you can move backward + * offset units from the end of LOB object and offset only can be positive. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @param string $offset Number of units you want to move the cursor. + * @param int $origin This parameter can be the following values: + * + * CUBRID_CURSOR_FIRST: move forward from the first beginning. + * + * CUBRID_CURSOR_CURRENT: move forward or backward from the current position. + * + * CUBRID_CURSOR_LAST: move backward at the end of LOB object. + * @throws CubridException + * + */ +function cubrid_lob2_seek64($lob_identifier, string $offset, int $origin = CUBRID_CURSOR_CURRENT): void +{ + error_clear_last(); + $result = \cubrid_lob2_seek64($lob_identifier, $offset, $origin); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** * The cubrid_lob2_size function is used to get the size of a lob object. * * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. * @return int It will return the size of the LOB object when it processes successfully. - * - * FALSE on failure. * @throws CubridException * */ @@ -307,8 +1054,6 @@ function cubrid_lob2_size($lob_identifier): int * * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. * @return string It will return the size of the LOB object as a string when it processes successfully. - * - * FALSE on failure. * @throws CubridException * */ @@ -328,8 +1073,6 @@ function cubrid_lob2_size64($lob_identifier): string * * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. * @return int It will return the cursor position on the LOB object when it processes successfully. - * - * FALSE on failure. * @throws CubridException * */ @@ -352,8 +1095,6 @@ function cubrid_lob2_tell($lob_identifier): int * * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. * @return string It will return the cursor position on the LOB object as a string when it processes successfully. - * - * FALSE on failure. * @throws CubridException * */ @@ -369,6 +1110,867 @@ function cubrid_lob2_tell64($lob_identifier): string /** + * The cubrid_lob2_write function reads as much as data + * from buf and stores it to the LOB object. Note that + * this function can only append characters now. + * + * @param resource $lob_identifier Lob identifier as a result of cubrid_lob2_new or get from the result set. + * @param string $buf Data that need to be written to the lob object. + * @throws CubridException + * + */ +function cubrid_lob2_write($lob_identifier, string $buf): void +{ + error_clear_last(); + $result = \cubrid_lob2_write($lob_identifier, $buf); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_lock_read function is used to put read + * lock on the instance pointed by given oid. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance that you want to put read lock on. + * @throws CubridException + * + */ +function cubrid_lock_read($conn_identifier, string $oid): void +{ + error_clear_last(); + $result = \cubrid_lock_read($conn_identifier, $oid); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_lock_write function is used to put write + * lock on the instance pointed by the given oid. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance that you want to put write lock on. + * @throws CubridException + * + */ +function cubrid_lock_write($conn_identifier, string $oid): void +{ + error_clear_last(); + $result = \cubrid_lock_write($conn_identifier, $oid); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_move_cursor function is used to move the + * current cursor location of req_identifier by the + * value set in the offset argument, to the direction + * set in the origin argument. To set the + * origin argument, you can use CUBRID_CURSOR_FIRST + * for the first part of the result, CUBRID_CURSOR_CURRENT for the current + * location of the result, or CUBRID_CURSOR_LAST for the last part of the + * result. If origin argument is not explicitly + * designated, then the function uses CUBRID_CURSOR_CURRENT as its default + * value. + * + * If the value of cursor movement range goes over the valid limit, then the + * cursor moves to the next location after the valid range for the cursor. + * For example, if you move 20 units in the result with the size of 10, then + * the cursor will move to 11th place and return CUBRID_NO_MORE_DATA. + * + * @param resource $req_identifier Request identifier. + * @param int $offset Number of units you want to move the cursor. + * @param int $origin Location where you want to move the cursor from CUBRID_CURSOR_FIRST, CUBRID_CURSOR_CURRENT, CUBRID_CURSOR_LAST. + * @return int Returns TRUE on success. + * @throws CubridException + * + */ +function cubrid_move_cursor($req_identifier, int $offset, int $origin = CUBRID_CURSOR_CURRENT): int +{ + error_clear_last(); + $result = \cubrid_move_cursor($req_identifier, $offset, $origin); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_next_result function is used to get + * results of next query if multiple SQL statements are executed and + * CUBRID_EXEC_QUERY_ALL flag is set upon + * cubrid_execute. + * + * @param resource $result result comes from a call to cubrid_execute + * @throws CubridException + * + */ +function cubrid_next_result($result): void +{ + error_clear_last(); + $result = \cubrid_next_result($result); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * Establishes a persistent connection to a CUBRID server. + * + * cubrid_pconnect_with_url acts very much like + * cubrid_connect_with_url with two major differences. + * + * First, when connecting, the function would first try to find a (persistent) + * link that's already open with the same host, port, dbname and userid. If + * one is found, an identifier for it will be returned instead of opening a + * new connection. + * + * Second, the connection to the SQL server will not be closed when the + * execution of the script ends. Instead, the link will remain open for + * future use (cubrid_close or + * cubrid_disconnect will not close links established by + * cubrid_pconnect_with_url). + * + * This type of link is therefore called 'persistent'. + * + * <url> ::= CUBRID:<host>:<db_name>:<db_user>:<db_password>:[?<properties>] + * + * <properties> ::= <property> [&<property>] + * + * <properties> ::= alhosts=<alternative_hosts>[ &rctime=<time>] + * + * <properties> ::= login_timeout=<milli_sec> + * + * <properties> ::= query_timeout=<milli_sec> + * + * <properties> ::= disconnect_on_query_timeout=true|false + * + * <alternative_hosts> ::= <standby_broker1_host>:<port> [,<standby_broker2_host>:<port>] + * + * <host> := HOSTNAME | IP_ADDR + * + * <time> := SECOND + * + * <milli_sec> := MILLI SECOND + * + * + * host : A host name or IP address of the master database + * db_name : A name of the database + * db_user : A name of the database user + * db_password : A database user password + * + * alhosts : Specifies the broker information of the standby server, which is + * used for failover when it is impossible to connect to the active server. + * You can specify multiple brokers for failover, and the connection to the brokers + * is attempted in the order listed in alhosts + * + * rctime : An interval between the attempts to connect to the active broker in + * which failure occurred. After a failure occurs, the system connects to the + * broker specified by althosts (failover), terminates the transaction, and then + * attempts to connect to the active broker of the master database at every rctime. + * The default value is 600 seconds. + * + * login_timeout : Timeout value (unit: msec.) for database login. The default + * value is 0, which means infinite postponement. + * + * + * query_timeout : Timeout value (unit: msec.) for query request. Upon timeout, + * a message to cancel requesting a query transferred to server is sent. The return + * value can depend on the disconnect_on_query_timeout configuration; even though the + * message to cancel a request is sent to server, that request may succeed. + * + * + * disconnect_on_query_timeout : Configures a value whether to immediately return + * an error of function being executed upon timeout. The default value is false. + * + * + * + * @param string $conn_url A character string that contains server connection information. + * @param string $userid User name for the database. + * @param string $passwd User password. + * @return resource Connection identifier, when process is successful. + * @throws CubridException + * + */ +function cubrid_pconnect_with_url(string $conn_url, string $userid = null, string $passwd = null) +{ + error_clear_last(); + if ($passwd !== null) { + $result = \cubrid_pconnect_with_url($conn_url, $userid, $passwd); + } elseif ($userid !== null) { + $result = \cubrid_pconnect_with_url($conn_url, $userid); + } else { + $result = \cubrid_pconnect_with_url($conn_url); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * Establishes a persistent connection to a CUBRID server. + * + * cubrid_pconnect acts very much like + * cubrid_connect with two major differences. + * + * First, when connecting, the function would first try to find a (persistent) + * link that's already open with the same host, port, dbname and userid. If + * one is found, an identifier for it will be returned instead of opening a + * new connection. + * + * Second, the connection to the SQL server will not be closed when the + * execution of the script ends. Instead, the link will remain open for + * future use (cubrid_close or + * cubrid_disconnect will not close links established by + * cubrid_pconnect). + * + * This type of link is therefore called 'persistent'. + * + * @param string $host Host name or IP address of CUBRID CAS server. + * @param int $port Port number of CUBRID CAS server (BROKER_PORT configured in $CUBRID/conf/cubrid_broker.conf). + * @param string $dbname Name of database. + * @param string $userid User name for the database. + * @param string $passwd User password. + * @return resource Connection identifier, when process is successful. + * @throws CubridException + * + */ +function cubrid_pconnect(string $host, int $port, string $dbname, string $userid = null, string $passwd = null) +{ + error_clear_last(); + if ($passwd !== null) { + $result = \cubrid_pconnect($host, $port, $dbname, $userid, $passwd); + } elseif ($userid !== null) { + $result = \cubrid_pconnect($host, $port, $dbname, $userid); + } else { + $result = \cubrid_pconnect($host, $port, $dbname); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_prepare function is a sort of API which represents SQL statements + * compiled previously to a given connection handle. This pre-compiled SQL statement will be included + * in the cubrid_prepare. + * + * Accordingly, you can use this statement effectively to execute several times repeatedly or to + * process long data. Only a single statement can be used and a parameter may put a question mark (?) + * to appropriate area in the SQL statement. Add a parameter when you bind a value in the VALUES + * clause of INSERT statement or in the WHERE clause. Note that it is allowed to bind a value to a + * MARK(?) by using the cubrid_bind function only. + * + * @param resource $conn_identifier Connection identifier. + * @param string $prepare_stmt Prepare query. + * @param int $option OID return option CUBRID_INCLUDE_OID. + * @return resource Request identifier, if process is successful. + * @throws CubridException + * + */ +function cubrid_prepare($conn_identifier, string $prepare_stmt, int $option = 0) +{ + error_clear_last(); + $result = \cubrid_prepare($conn_identifier, $prepare_stmt, $option); + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_put function is used to update an + * attribute of the instance of the given oid. + * + * You can update single attribute by using string data type to set + * attr. In such case, you can use integer, + * floating point or string type data for the value + * argument. To update multiple number of attributes, you can disregard the + * attr argument, and set + * value argument with associative array data type. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance that you want to update. + * @param string $attr Name of the attribute that you want to update. + * @param mixed $value New value that you want to assign to the attribute. + * @throws CubridException + * + */ +function cubrid_put($conn_identifier, string $oid, string $attr = null, $value = null): void +{ + error_clear_last(); + if ($value !== null) { + $result = \cubrid_put($conn_identifier, $oid, $attr, $value); + } elseif ($attr !== null) { + $result = \cubrid_put($conn_identifier, $oid, $attr); + } else { + $result = \cubrid_put($conn_identifier, $oid); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_rollback function executes rollback on the + * transaction pointed by conn_identifier, currently in + * progress. + * + * Connection to server is closed after calling + * cubrid_rollback. Connection handle, however, is + * still valid. + * + * @param resource $conn_identifier Connection identifier. + * @throws CubridException + * + */ +function cubrid_rollback($conn_identifier): void +{ + error_clear_last(); + $result = \cubrid_rollback($conn_identifier); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_schema function is used to get the + * requested schema information from database. To get information about specific class, + * set the class_name, to get information about specific attribute + * (can be used only with CUBRID_SCH_ATTR_PRIVILEGE), + * set the attr_name. + * + * The result of the cubrid_schema function is returned as a two-dimensional + * array (column (associative array) * row (numeric array)). The following + * tables shows types of schema and the column structure of the result array to + * be returned based on the schema type. + * + * + * Result Composition of Each Type + * + * + * + * Schema + * Column Number + * Column Name + * Value + * + * + * + * + * CUBRID_SCH_CLASS + * 1 + * NAME + * + * + * + * + * 2 + * TYPE + * 0:system class 1:vclass 2:class + * + * + * + * CUBRID_SCH_VCLASS + * 1 + * NAME + * + * + * + * + * 2 + * TYPE + * 1:vclass + * + * + * + * CUBRID_SCH_QUERY_SPEC + * 1 + * QUERY_SPEC + * + * + * + * + * CUBRID_SCH_ATTRIBUTE / CUBRID_SCH_CLASS_ATTRIBUTE + * 1 + * ATTR_NAME + * + * + * + * + * 2 + * DOMAIN + * + * + * + * + * 3 + * SCALE + * + * + * + * + * 4 + * PRECISION + * + * + * + * + * 5 + * INDEXED + * 1:indexed + * + * + * + * 6 + * NOT NULL + * 1:not null + * + * + * + * 7 + * SHARED + * 1:shared + * + * + * + * 8 + * UNIQUE + * 1:unique + * + * + * + * 9 + * DEFAULT + * + * + * + * + * 10 + * ATTR_ORDER + * base:1 + * + * + * + * 11 + * CLASS_NAME + * + * + * + * + * 12 + * SOURCE_CLASS + * + * + * + * + * 13 + * IS_KEY + * 1:key + * + * + * + * CUBRID_SCH_METHOD / CUBRID_SCH_CLASS_METHOD + * 1 + * NAME + * + * + * + * + * 2 + * RET_DOMAIN + * + * + * + * + * 3 + * ARG_DOMAIN + * + * + * + * + * CUBRID_SCH_METHOD_FILE + * 1 + * METHOD_FILE + * + * + * + * + * CUBRID_SCH_SUPERCLASS / CUBRID_SCH_DIRECT_SUPER_CLASS / CUBRID_SCH_SUBCLASS + * 1 + * CLASS_NAME + * + * + * + * + * 2 + * TYPE + * 0:system class 1:vclass 2:class + * + * + * + * CUBRID_SCH_CONSTRAINT + * 1 + * TYPE + * 0:unique 1:index 2:reverse unique 3:reverse index + * + * + * + * 2 + * NAME + * + * + * + * + * 3 + * ATTR_NAME + * + * + * + * + * 4 + * NUM_PAGES + * + * + * + * + * 5 + * NUM_KEYS + * + * + * + * + * 6 + * PRIMARY_KEY + * 1:primary key + * + * + * + * 7 + * KEY_ORDER + * base:1 + * + * + * + * CUBRID_SCH_TRIGGER + * 1 + * NAME + * + * + * + * + * 2 + * STATUS + * + * + * + * + * 3 + * EVENT + * + * + * + * + * 4 + * TARGET_CLASS + * + * + * + * + * 5 + * TARGET_ATTR + * + * + * + * + * 6 + * ACTION_TIME + * + * + * + * + * 7 + * ACTION + * + * + * + * + * 8 + * PRIORITY + * + * + * + * + * 9 + * CONDITION_TIME + * + * + * + * + * 10 + * CONDITION + * + * + * + * + * CUBRID_SCH_CLASS_PRIVILEGE / CUBRID_SCH_ATTR_PRIVILEGE + * 1 + * CLASS_NAME / ATTR_NAME + * + * + * + * + * 2 + * PRIVILEGE + * + * + * + * + * 3 + * GRANTABLE + * + * + * + * + * CUBRID_SCH_PRIMARY_KEY + * 1 + * CLASS_NAME + * + * + * + * + * 2 + * ATTR_NAME + * + * + * + * + * 3 + * KEY_SEQ + * base:1 + * + * + * + * 4 + * KEY_NAME + * + * + * + * + * CUBRID_SCH_IMPORTED_KEYS / CUBRID_SCH_EXPORTED_KEYS / CUBRID_SCH_CROSS_REFERENCE + * 1 + * PKTABLE_NAME + * + * + * + * + * 2 + * PKCOLUMN_NAME + * + * + * + * + * 3 + * FKTABLE_NAME + * base:1 + * + * + * + * 4 + * FKCOLUMN_NAME + * + * + * + * + * 5 + * KEY_SEQ + * base:1 + * + * + * + * 6 + * UPDATE_ACTION + * 0:cascade 1:restrict 2:no action 3:set null + * + * + * + * 7 + * DELETE_ACTION + * 0:cascade 1:restrict 2:no action 3:set null + * + * + * + * 8 + * FK_NAME + * + * + * + * + * 9 + * PK_NAME + * + * + * + * + * + * + * @param resource $conn_identifier Connection identifier. + * @param int $schema_type Schema data that you want to know. + * @param string $class_name Class you want to know the schema of. + * @param string $attr_name Attribute you want to know the schema of. + * @return array Array containing the schema information, when process is successful. + * @throws CubridException + * + */ +function cubrid_schema($conn_identifier, int $schema_type, string $class_name = null, string $attr_name = null): array +{ + error_clear_last(); + if ($attr_name !== null) { + $result = \cubrid_schema($conn_identifier, $schema_type, $class_name, $attr_name); + } elseif ($class_name !== null) { + $result = \cubrid_schema($conn_identifier, $schema_type, $class_name); + } else { + $result = \cubrid_schema($conn_identifier, $schema_type); + } + if ($result === false) { + throw CubridException::createFromPhpError(); + } + return $result; +} + + +/** + * The cubrid_seq_drop function is used to delete an + * element you request from the given sequence type attribute in the + * database. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance you want to work with. + * @param string $attr_name Name of the attribute that you want to delete an element from. + * @param int $index Index of the element that you want to delete (1-based). + * @throws CubridException + * + */ +function cubrid_seq_drop($conn_identifier, string $oid, string $attr_name, int $index): void +{ + error_clear_last(); + $result = \cubrid_seq_drop($conn_identifier, $oid, $attr_name, $index); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_col_insert function is used to insert an + * element to a sequence type attribute in a requested location. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance you want to work with. + * @param string $attr_name Name of the attribute you want to insert an instance to. + * @param int $index Location of the element, you want to insert the element to (1-based). + * @param string $seq_element Content of the element that you want to insert. + * @throws CubridException + * + */ +function cubrid_seq_insert($conn_identifier, string $oid, string $attr_name, int $index, string $seq_element): void +{ + error_clear_last(); + $result = \cubrid_seq_insert($conn_identifier, $oid, $attr_name, $index, $seq_element); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_seq_put function is used to update the + * content of the requested element in a sequent type attribute using OID. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance you want to work with. + * @param string $attr_name Name of the attribute that you want to update an element. + * @param int $index Index (1-based) of the element that you want to update. + * @param string $seq_element New content that you want to use for the update. + * @throws CubridException + * + */ +function cubrid_seq_put($conn_identifier, string $oid, string $attr_name, int $index, string $seq_element): void +{ + error_clear_last(); + $result = \cubrid_seq_put($conn_identifier, $oid, $attr_name, $index, $seq_element); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_set_add function is used to insert a + * single element to a set type attribute (set, multiset, sequence) you + * requested. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance you want to work with. + * @param string $attr_name Name of the attribute you want to insert an element. + * @param string $set_element Content of the element you want to insert. + * @throws CubridException + * + */ +function cubrid_set_add($conn_identifier, string $oid, string $attr_name, string $set_element): void +{ + error_clear_last(); + $result = \cubrid_set_add($conn_identifier, $oid, $attr_name, $set_element); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_set_autocommit function is used to set the + * CUBRID database auto-commit mode of the current database connection. + * + * In CUBRID PHP, auto-commit mode is disabled by default for transaction + * management. When auto-commit mode is truned from off to on, any pending work is + * automatically committed. + * + * @param resource $conn_identifier Connection identifier. + * @param bool $mode Auto-commit mode. The following constants can be used: + * + * + * CUBRID_AUTOCOMMIT_FALSE + * CUBRID_AUTOCOMMIT_TRUE + * + * @throws CubridException + * + */ +function cubrid_set_autocommit($conn_identifier, bool $mode): void +{ + error_clear_last(); + $result = \cubrid_set_autocommit($conn_identifier, $mode); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** * The cubrid_set_db_parameter function is used to set * the CUBRID database parameters. It can set the following CUBRID database * parameters: @@ -393,3 +1995,44 @@ function cubrid_set_db_parameter($conn_identifier, int $param_type, int $param_v throw CubridException::createFromPhpError(); } } + + +/** + * The cubrid_set_drop function is used to delete an + * element that you request from the given set type (set, multiset) attribute + * of the database. + * + * @param resource $conn_identifier Connection identifier. + * @param string $oid OID of the instance you want to work with. + * @param string $attr_name Name of the attribute you want to delete an element from. + * @param string $set_element Content of the element you want to delete. + * @throws CubridException + * + */ +function cubrid_set_drop($conn_identifier, string $oid, string $attr_name, string $set_element): void +{ + error_clear_last(); + $result = \cubrid_set_drop($conn_identifier, $oid, $attr_name, $set_element); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} + + +/** + * The cubrid_set_query_timeout function is used to set + * the timeout time of query execution. + * + * @param resource $req_identifier Request identifier. + * @param int $timeout Timeout time in milliseconds. + * @throws CubridException + * + */ +function cubrid_set_query_timeout($req_identifier, int $timeout): void +{ + error_clear_last(); + $result = \cubrid_set_query_timeout($req_identifier, $timeout); + if ($result === false) { + throw CubridException::createFromPhpError(); + } +} diff --git a/vendor/thecodingmachine/safe/generated/curl.php b/vendor/thecodingmachine/safe/generated/curl.php index 53f925536..3c89871c3 100644 --- a/vendor/thecodingmachine/safe/generated/curl.php +++ b/vendor/thecodingmachine/safe/generated/curl.php @@ -5,21 +5,41 @@ namespace Safe; use Safe\Exceptions\CurlException; /** + * Copies a cURL handle keeping the same preferences. + * + * @param \CurlHandle $handle A cURL handle returned by + * curl_init. + * @return \CurlHandle Returns a new cURL handle. + * @throws CurlException + * + */ +function curl_copy_handle(\CurlHandle $handle): \CurlHandle +{ + error_clear_last(); + $result = \curl_copy_handle($handle); + if ($result === false) { + throw CurlException::createFromPhpError($handle); + } + return $result; +} + + +/** * This function URL encodes the given string according to RFC 3986. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @param string $str The string to be encoded. + * @param string $string The string to be encoded. * @return string Returns escaped string. * @throws CurlException * */ -function curl_escape($ch, string $str): string +function curl_escape(\CurlHandle $handle, string $string): string { error_clear_last(); - $result = \curl_escape($ch, $str); + $result = \curl_escape($handle, $string); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError($handle); } return $result; } @@ -31,7 +51,7 @@ function curl_escape($ch, string $str): string * This function should be called after initializing a cURL session and all * the options for the session are set. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @return bool|string Returns TRUE on success. However, if the CURLOPT_RETURNTRANSFER * option is set, it will return @@ -39,12 +59,12 @@ function curl_escape($ch, string $str): string * @throws CurlException * */ -function curl_exec($ch) +function curl_exec(\CurlHandle $handle) { error_clear_last(); - $result = \curl_exec($ch); + $result = \curl_exec($handle); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError($handle); } return $result; } @@ -53,9 +73,9 @@ function curl_exec($ch) /** * Gets information about the last transfer. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @param int $opt This may be one of the following constants: + * @param int $option This may be one of the following constants: * * * @@ -65,7 +85,7 @@ function curl_exec($ch) * * * CURLINFO_HTTP_CODE - The last response code. - * As of PHP 5.5.0 and cURL 7.10.8, this is a legacy alias of + * As of cURL 7.10.8, this is a legacy alias of * CURLINFO_RESPONSE_CODE * * @@ -367,9 +387,9 @@ function curl_exec($ch) * * * - * @return mixed If opt is given, returns its value. + * @return mixed If option is given, returns its value. * Otherwise, returns an associative array with the following elements - * (which correspond to opt): + * (which correspond to option): * * * @@ -512,16 +532,16 @@ function curl_exec($ch) * @throws CurlException * */ -function curl_getinfo($ch, int $opt = null) +function curl_getinfo(\CurlHandle $handle, int $option = null) { error_clear_last(); - if ($opt !== null) { - $result = \curl_getinfo($ch, $opt); + if ($option !== null) { + $result = \curl_getinfo($handle, $option); } else { - $result = \curl_getinfo($ch); + $result = \curl_getinfo($handle); } if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError($handle); } return $result; } @@ -538,34 +558,18 @@ function curl_getinfo($ch, int $opt = null) * * The file protocol is disabled by cURL if * open_basedir is set. - * @return resource Returns a cURL handle on success, FALSE on errors. + * @return \CurlHandle Returns a cURL handle on success, FALSE on errors. * @throws CurlException * */ -function curl_init(string $url = null) +function curl_init(string $url = null): \CurlHandle { error_clear_last(); - $result = \curl_init($url); - if ($result === false) { - throw CurlException::createFromPhpError(); + if ($url !== null) { + $result = \curl_init($url); + } else { + $result = \curl_init(); } - return $result; -} - - -/** - * Return an integer containing the last multi curl error number. - * - * @param resource $mh A cURL multi handle returned by - * curl_multi_init. - * @return int Return an integer containing the last multi curl error number. - * @throws CurlException - * - */ -function curl_multi_errno($mh): int -{ - error_clear_last(); - $result = \curl_multi_errno($mh); if ($result === false) { throw CurlException::createFromPhpError(); } @@ -580,12 +584,12 @@ function curl_multi_errno($mh): int * * Repeated calls to this function will return a new result each time, until a FALSE is returned * as a signal that there is no more to get at this point. The integer pointed to with - * msgs_in_queue will contain the number of remaining messages after this + * queued_messages will contain the number of remaining messages after this * function was called. * - * @param resource $mh A cURL multi handle returned by + * @param \CurlMultiHandle $multi_handle A cURL multi handle returned by * curl_multi_init. - * @param int|null $msgs_in_queue Number of messages that are still in the queue + * @param int|null $queued_messages Number of messages that are still in the queue * @return array On success, returns an associative array for the message, FALSE on failure. * * @@ -618,12 +622,12 @@ function curl_multi_errno($mh): int * @throws CurlException * */ -function curl_multi_info_read($mh, ?int &$msgs_in_queue = null): array +function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_messages = null): array { error_clear_last(); - $result = \curl_multi_info_read($mh, $msgs_in_queue); + $result = \curl_multi_info_read($multi_handle, $queued_messages); if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromPhpError($multi_handle); } return $result; } @@ -632,11 +636,11 @@ function curl_multi_info_read($mh, ?int &$msgs_in_queue = null): array /** * Allows the processing of multiple cURL handles asynchronously. * - * @return resource Returns a cURL multi handle resource on success, FALSE on failure. + * @return \CurlMultiHandle Returns a cURL multi handle on success, FALSE on failure. * @throws CurlException * */ -function curl_multi_init() +function curl_multi_init(): \CurlMultiHandle { error_clear_last(); $result = \curl_multi_init(); @@ -648,9 +652,154 @@ function curl_multi_init() /** + * + * + * @param \CurlMultiHandle $multi_handle + * @param int $option One of the CURLMOPT_* constants. + * @param mixed $value The value to be set on option. + * + * value should be an int for the + * following values of the option parameter: + * + * + * + * + * Option + * Set value to + * + * + * + * + * CURLMOPT_PIPELINING + * + * Pass 1 to enable or 0 to disable. Enabling pipelining on a multi + * handle will make it attempt to perform HTTP Pipelining as far as + * possible for transfers using this handle. This means that if you add + * a second request that can use an already existing connection, the + * second request will be "piped" on the same connection. + * As of cURL 7.43.0, the value is a bitmask, and you can also pass 2 to try to multiplex the new + * transfer over an existing HTTP/2 connection if possible. + * Passing 3 instructs cURL to ask for pipelining and multiplexing + * independently of each other. + * As of cURL 7.62.0, setting the pipelining bit has no effect. + * Instead of integer literals, you can also use the CURLPIPE_* + * constants if available. + * + * + * + * CURLMOPT_MAXCONNECTS + * + * Pass a number that will be used as the maximum amount of + * simultaneously open connections that libcurl may cache. + * By default the size will be enlarged to fit four times the number + * of handles added via curl_multi_add_handle. + * When the cache is full, curl closes the oldest one in the cache + * to prevent the number of open connections from increasing. + * + * + * + * CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE + * + * Pass a number that specifies the chunk length threshold for pipelining + * in bytes. + * + * + * + * CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE + * + * Pass a number that specifies the size threshold for pipelining + * penalty in bytes. + * + * + * + * CURLMOPT_MAX_HOST_CONNECTIONS + * + * Pass a number that specifies the maximum number of connections to a + * single host. + * + * + * + * CURLMOPT_MAX_PIPELINE_LENGTH + * + * Pass a number that specifies the maximum number of requests in a + * pipeline. + * + * + * + * CURLMOPT_MAX_TOTAL_CONNECTIONS + * + * Pass a number that specifies the maximum number of simultaneously + * open connections. + * + * + * + * CURLMOPT_PUSHFUNCTION + * + * Pass a callable that will be registered to handle server + * pushes and should have the following signature: + * + * intpushfunction + * resourceparent_ch + * resourcepushed_ch + * arrayheaders + * + * + * + * parent_ch + * + * + * The parent cURL handle (the request the client made). + * + * + * + * + * pushed_ch + * + * + * A new cURL handle for the pushed request. + * + * + * + * + * headers + * + * + * The push promise headers. + * + * + * + * + * The push function is supposed to return either + * CURL_PUSH_OK if it can handle the push, or + * CURL_PUSH_DENY to reject it. + * + * + * + * + * + * + * The parent cURL handle (the request the client made). + * + * A new cURL handle for the pushed request. + * + * The push promise headers. + * @throws CurlException + * + */ +function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): void +{ + error_clear_last(); + $result = \curl_multi_setopt($multi_handle, $option, $value); + if ($result === false) { + throw CurlException::createFromPhpError($multi_handle); + } +} + + +/** * Sets an option on the given cURL session handle. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @param int $option The CURLOPT_XXX option to set. * @param mixed $value The value to be set on option. @@ -677,18 +826,6 @@ function curl_multi_init() * * * - * CURLOPT_BINARYTRANSFER - * - * TRUE to return the raw output when - * CURLOPT_RETURNTRANSFER is used. - * - * - * From PHP 5.1.3, this option has no effect: the raw output will - * always be returned when - * CURLOPT_RETURNTRANSFER is used. - * - * - * * CURLOPT_COOKIESESSION * * TRUE to mark this as a new cookie "session". It will force libcurl @@ -709,7 +846,6 @@ function curl_multi_init() * * * Added in cURL 7.19.1. - * Available since PHP 5.3.2. * Requires CURLOPT_VERBOSE to be on to have an effect. * * @@ -722,7 +858,6 @@ function curl_multi_init() * * * Added in 7.15.2. - * Available since PHP 5.5.0. * * * @@ -819,9 +954,8 @@ function curl_multi_init() * * TRUE to follow any * "Location: " header that the server sends as - * part of the HTTP header (note this is recursive, PHP will follow as - * many "Location: " headers that it is sent, - * unless CURLOPT_MAXREDIRS is set). + * part of the HTTP header. + * See also CURLOPT_MAXREDIRS. * * * @@ -889,7 +1023,7 @@ function curl_multi_init() * the number of small packets on the network. * * - * Available since PHP 5.2.1 for versions compiled with libcurl 7.11.2 or + * Available for versions compiled with libcurl 7.11.2 or * greater. * * @@ -925,7 +1059,7 @@ function curl_multi_init() * TRUE to track the handle's request string. * * - * Available since PHP 5.1.3. The CURLINFO_ + * The CURLINFO_ * prefix is intentional. * * @@ -963,7 +1097,7 @@ function curl_multi_init() * FALSE to get the raw HTTP response body. * * - * Available as of PHP 5.5.0 if built against libcurl >= 7.16.2. + * Available if built against libcurl >= 7.16.2. * * * @@ -1082,21 +1216,6 @@ function curl_multi_init() * * * - * CURLOPT_SAFE_UPLOAD - * - * TRUE to disable support for the @ prefix for - * uploading files in CURLOPT_POSTFIELDS, which - * means that values starting with @ can be safely - * passed as fields. CURLFile may be used for - * uploads instead. - * - * - * Added in PHP 5.5.0 with FALSE as the default value. PHP 5.6.0 - * changes the default value to TRUE. PHP 7 removes this option; - * the CURLFile interface must be used to upload files. - * - * - * * CURLOPT_SASL_IR * * TRUE to enable sending the initial response in the first packet. @@ -1165,6 +1284,18 @@ function curl_multi_init() * * * + * CURLOPT_SAFE_UPLOAD + * + * Always TRUE, what disables support for the @ prefix for + * uploading files in CURLOPT_POSTFIELDS, which + * means that values starting with @ can be safely + * passed as fields. CURLFile may be used for + * uploads instead. + * + * + * + * + * * CURLOPT_SUPPRESS_CONNECT_HEADERS * * TRUE to suppress proxy CONNECT response headers from the user callback functions @@ -1248,7 +1379,7 @@ function curl_multi_init() * PHP automatically sets this option to TRUE, this should only be * changed for debugging purposes. * - * value should be an integer for the + * value should be an int for the * following values of the option parameter: * * @@ -1271,21 +1402,6 @@ function curl_multi_init() * * * - * CURLOPT_CLOSEPOLICY - * - * One of the CURLCLOSEPOLICY_* values. - * - * - * This option is deprecated, as it was never implemented in cURL and - * never had any effect. - * - * - * - * - * Removed in PHP 5.6.0. - * - * - * * CURLOPT_CONNECTTIMEOUT * * The number of seconds to wait while trying to connect. Use 0 to @@ -1305,7 +1421,7 @@ function curl_multi_init() * timeouts with a minimum timeout allowed of one second. * * - * Added in cURL 7.16.2. Available since PHP 5.2.3. + * Added in cURL 7.16.2. * * * @@ -1472,6 +1588,9 @@ function curl_multi_init() * * The maximum amount of HTTP redirections to follow. Use this option * alongside CURLOPT_FOLLOWLOCATION. + * Default value of 20 is set to prevent infinite redirects. + * Setting to -1 allows inifinite redirects, and 0 + * refuses all redirects. * * * @@ -1493,7 +1612,7 @@ function curl_multi_init() * specific type of redirect occurs. * * - * Added in cURL 7.19.1. Available since PHP 5.3.2. + * Added in cURL 7.19.1. * * * @@ -1640,10 +1759,11 @@ function curl_multi_init() * * CURLOPT_SSL_VERIFYHOST * - * 1 to check the existence of a common name in the - * SSL peer certificate. 2 to check the existence of - * a common name and also verify that it matches the hostname - * provided. 0 to not check the names. In production environments the value of this option + * 2 to verify that a Common Name field or a Subject Alternate Name + * field in the SSL peer certificate matches the provided hostname. + * 0 to not check the names. + * 1 should not be used. + * In production environments the value of this option * should be kept at 2 (default value). * * @@ -1760,7 +1880,7 @@ function curl_multi_init() * supports them. If set to 0 (default) keepalive probes are disabled. * * - * Added in cURL 7.25.0. Available since PHP 5.5.0. + * Added in cURL 7.25.0. * * * @@ -1772,7 +1892,7 @@ function curl_multi_init() * The default is 60. * * - * Added in cURL 7.25.0. Available since PHP 5.5.0. + * Added in cURL 7.25.0. * * * @@ -1784,7 +1904,7 @@ function curl_multi_init() * The default is 60. * * - * Added in cURL 7.25.0. Available since PHP 5.5.0. + * Added in cURL 7.25.0. * * * @@ -1797,10 +1917,13 @@ function curl_multi_init() * a "304 Not Modified" header will be returned * assuming CURLOPT_HEADER is TRUE. * Use CURL_TIMECOND_IFUNMODSINCE for the reverse - * effect. CURL_TIMECOND_IFMODSINCE is the - * default. + * effect. Use CURL_TIMECOND_NONE to ignore + * CURLOPT_TIMEVALUE and always return the page. + * CURL_TIMECOND_NONE is the default. * * + * Before cURL 7.46.0 the default was + * CURL_TIMECOND_IFMODSINCE. * * * @@ -1822,15 +1945,14 @@ function curl_multi_init() * timeouts with a minimum timeout allowed of one second. * * - * Added in cURL 7.16.2. Available since PHP 5.2.3. + * Added in cURL 7.16.2. * * * * CURLOPT_TIMEVALUE * * The time in seconds since January 1st, 1970. The time will be used - * by CURLOPT_TIMECONDITION. By default, - * CURL_TIMECOND_IFMODSINCE is used. + * by CURLOPT_TIMECONDITION. * * * @@ -1857,7 +1979,7 @@ function curl_multi_init() * Defaults to unlimited speed. * * - * Added in cURL 7.15.5. Available since PHP 5.4.0. + * Added in cURL 7.15.5. * * * @@ -1869,7 +1991,7 @@ function curl_multi_init() * Defaults to unlimited speed. * * - * Added in cURL 7.15.5. Available since PHP 5.4.0. + * Added in cURL 7.15.5. * * * @@ -1910,15 +2032,12 @@ function curl_multi_init() * CURLFTPMETHOD_SINGLECWD. * * - * Added in cURL 7.15.1. Available since PHP 5.3.0. - * + * Added in cURL 7.15.1. * * * * * - * This option is deprecated, as it was never implemented in cURL and - * never had any effect. * * The HTTP authentication method(s) to use. The options are: * CURLAUTH_BASIC, @@ -2074,7 +2193,7 @@ function curl_multi_init() * "RELOAD" loads all cookies from the files specified by CURLOPT_COOKIEFILE. * * - * Available since PHP 5.5.0 and cURL 7.14.1. + * Available since cURL 7.14.1. * * * @@ -2239,10 +2358,7 @@ function curl_multi_init() * * * The full data to post in a HTTP "POST" operation. - * To post a file, prepend a filename with @ and - * use the full path. The filetype can be explicitly specified by - * following the filename with the type in the format - * ';type=mimetype'. This parameter can either be + * This parameter can either be * passed as a urlencoded string like 'para1=val1&para2=val2&...' * or as an array with the field name as key and field data as value. * If value is an array, the @@ -2250,15 +2366,8 @@ function curl_multi_init() * multipart/form-data. * * - * As of PHP 5.2.0, value must be an array if - * files are passed to this option with the @ prefix. - * - * - * As of PHP 5.5.0, the @ prefix is deprecated and - * files can be sent using CURLFile. The - * @ prefix can be disabled for safe passing of - * values beginning with @ by setting the - * CURLOPT_SAFE_UPLOAD option to TRUE. + * Files can be sent using CURLFile or CURLStringFile, + * in which case value must be an array. * * * @@ -2479,7 +2588,7 @@ function curl_multi_init() * * CURLOPT_PROXY_TLSAUTH_USERNAME * - * Tusername to use for the HTTPS proxy TLS authentication method specified with the + * The username to use for the HTTPS proxy TLS authentication method specified with the * CURLOPT_PROXY_TLSAUTH_TYPE option. Requires that the * CURLOPT_PROXY_TLSAUTH_PASSWORD option to also be set. * @@ -2709,7 +2818,16 @@ function curl_multi_init() * The user name to use in authentication. * * - * Added in cURL 7.19.1. Available since PHP 5.5.0. + * Added in cURL 7.19.1. + * + * + * + * CURLOPT_PASSWORD + * + * The password to use in authentication. + * + * + * Added in cURL 7.19.1. * * * @@ -2864,7 +2982,7 @@ function curl_multi_init() * * * - * Added in cURL 7.21.3. Available since PHP 5.5.0. + * Added in cURL 7.21.3. * * * @@ -3031,12 +3149,12 @@ function curl_multi_init() * @throws CurlException * */ -function curl_setopt($ch, int $option, $value): void +function curl_setopt(\CurlHandle $handle, int $option, $value): void { error_clear_last(); - $result = \curl_setopt($ch, $option, $value); + $result = \curl_setopt($handle, $option, $value); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError($handle); } } @@ -3044,17 +3162,18 @@ function curl_setopt($ch, int $option, $value): void /** * Return an integer containing the last share curl error number. * - * @param resource $sh A cURL share handle returned by curl_share_init. + * @param \CurlShareHandle $share_handle A cURL share handle returned by + * curl_share_init. * @return int Returns an integer containing the last share curl error number. * @throws CurlException * */ -function curl_share_errno($sh): int +function curl_share_errno(\CurlShareHandle $share_handle): int { error_clear_last(); - $result = \curl_share_errno($sh); + $result = \curl_share_errno($share_handle); if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromPhpError($share_handle); } return $result; } @@ -3063,7 +3182,8 @@ function curl_share_errno($sh): int /** * Sets an option on the given cURL share handle. * - * @param resource $sh A cURL share handle returned by curl_share_init. + * @param \CurlShareHandle $share_handle A cURL share handle returned by + * curl_share_init. * @param int $option * * @@ -3088,7 +3208,7 @@ function curl_share_errno($sh): int * * * - * @param string $value + * @param mixed $value * * * @@ -3125,12 +3245,12 @@ function curl_share_errno($sh): int * @throws CurlException * */ -function curl_share_setopt($sh, int $option, string $value): void +function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value): void { error_clear_last(); - $result = \curl_share_setopt($sh, $option, $value); + $result = \curl_share_setopt($share_handle, $option, $value); if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromPhpError($share_handle); } } @@ -3138,19 +3258,19 @@ function curl_share_setopt($sh, int $option, string $value): void /** * This function decodes the given URL encoded string. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @param string $str The URL encoded string to be decoded. + * @param string $string The URL encoded string to be decoded. * @return string Returns decoded string. * @throws CurlException * */ -function curl_unescape($ch, string $str): string +function curl_unescape(\CurlHandle $handle, string $string): string { error_clear_last(); - $result = \curl_unescape($ch, $str); + $result = \curl_unescape($handle, $string); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError($handle); } return $result; } diff --git a/vendor/thecodingmachine/safe/generated/datetime.php b/vendor/thecodingmachine/safe/generated/datetime.php index 01bfa9364..9840ef5c6 100644 --- a/vendor/thecodingmachine/safe/generated/datetime.php +++ b/vendor/thecodingmachine/safe/generated/datetime.php @@ -9,11 +9,11 @@ use Safe\Exceptions\DatetimeException; * * @param string $format Format accepted by DateTime::createFromFormat. * @param string $datetime String representing the date/time. - * @return array Returns associative array with detailed info about given date/time. + * @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns associative array with detailed info about given date/time. * @throws DatetimeException * */ -function date_parse_from_format(string $format, string $datetime): array +function date_parse_from_format(string $format, string $datetime): ?array { error_clear_last(); $result = \date_parse_from_format($format, $datetime); @@ -25,16 +25,30 @@ function date_parse_from_format(string $format, string $datetime): array /** - * + * date_parse parses the given + * datetime string according to the same rules as + * strtotime and + * DateTimeImmutable::__construct. Instead of returning a + * Unix timestamp (with strtotime) or a + * DateTimeImmutable object (with + * DateTimeImmutable::__construct, it returns an + * associative array with the information that it could detect in the given + * datetime string. + * + * If no information about a certain group of elements can be found, these + * array elements will be set to FALSE or are missing. If needed for + * constructing a timestamp or DateTimeImmutable object from + * the same datetime string, more fields can be set to + * a non-FALSE value. See the examples for cases where that happens. * * @param string $datetime Date/time in format accepted by * DateTimeImmutable::__construct. - * @return array Returns array with information about the parsed date/time + * @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns array with information about the parsed date/time * on success. * @throws DatetimeException * */ -function date_parse(string $datetime): array +function date_parse(string $datetime): ?array { error_clear_last(); $result = \date_parse($datetime); @@ -180,7 +194,7 @@ function date_sun_info(int $timestamp, float $latitude, float $longitude): array * * * SUNFUNCS_RET_TIMESTAMP - * returns the result as integer (timestamp) + * returns the result as int (timestamp) * 1095034606 * * @@ -233,10 +247,10 @@ function date_sun_info(int $timestamp, float $latitude, float $longitude): array * @throws DatetimeException * */ -function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0) +function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = null) { error_clear_last(); - if ($utcOffset !== 0) { + if ($utcOffset !== null) { $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset); } elseif ($zenith !== null) { $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith); @@ -283,7 +297,7 @@ function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, f * * * SUNFUNCS_RET_TIMESTAMP - * returns the result as integer (timestamp) + * returns the result as int (timestamp) * 1095034606 * * @@ -336,10 +350,10 @@ function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, f * @throws DatetimeException * */ -function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0) +function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = null) { error_clear_last(); - if ($utcOffset !== 0) { + if ($utcOffset !== null) { $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset); } elseif ($zenith !== null) { $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith); @@ -359,14 +373,19 @@ function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, fl /** * Returns a string formatted according to the given format string using the - * given integer timestamp or the current time - * if no timestamp is given. In other words, timestamp + * given integer timestamp (Unix timestamp) or the current time + * if no timestamp is given. In other words, timestamp * is optional and defaults to the value of time. * + * Unix timestamps do not handle timezones. Use the + * DateTimeImmutable class, and its + * DateTimeInterface::format formatting method to + * format date/time information with a timezone attached. + * * @param string $format Format accepted by DateTimeInterface::format. * @param int $timestamp The optional timestamp parameter is an - * integer Unix timestamp that defaults to the current - * local time if a timestamp is not given. In other + * int Unix timestamp that defaults to the current + * local time if timestamp is omitted or NULL. In other * words, it defaults to the value of time. * @return string Returns a formatted date string. If a non-numeric value is used for * timestamp, FALSE is returned and an @@ -390,28 +409,219 @@ function date(string $format, int $timestamp = null): string /** - * Identical to the date function except that - * the time returned is Greenwich Mean Time (GMT). + * Identical to mktime except the passed parameters represents a + * GMT date. gmmktime internally uses mktime + * so only times valid in derived local time can be used. + * + * Like mktime, arguments may be left out in order + * from right to left, with any omitted arguments being set to the + * current corresponding GMT value. + * + * @param int $hour The number of the hour relative to the start of the day determined by + * month, day and year. + * Negative values reference the hour before midnight of the day in question. + * Values greater than 23 reference the appropriate hour in the following day(s). + * @param int $minute The number of the minute relative to the start of the hour. + * Negative values reference the minute in the previous hour. + * Values greater than 59 reference the appropriate minute in the following hour(s). + * @param int $second The number of seconds relative to the start of the minute. + * Negative values reference the second in the previous minute. + * Values greater than 59 reference the appropriate second in the following minute(s). + * @param int $month The number of the month relative to the end of the previous year. + * Values 1 to 12 reference the normal calendar months of the year in question. + * Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. + * Values greater than 12 reference the appropriate month in the following year(s). + * @param int $day The number of the day relative to the end of the previous month. + * Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. + * Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. + * Values greater than the number of days in the relevant month reference the appropriate day in the following month(s). + * @param int $year The year + * @return int Returns a int Unix timestamp on success. + * @throws DatetimeException + * + */ +function gmmktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int +{ + error_clear_last(); + if ($year !== null) { + $result = \gmmktime($hour, $minute, $second, $month, $day, $year); + } elseif ($day !== null) { + $result = \gmmktime($hour, $minute, $second, $month, $day); + } elseif ($month !== null) { + $result = \gmmktime($hour, $minute, $second, $month); + } elseif ($second !== null) { + $result = \gmmktime($hour, $minute, $second); + } elseif ($minute !== null) { + $result = \gmmktime($hour, $minute); + } else { + $result = \gmmktime($hour); + } + if ($result === false) { + throw DatetimeException::createFromPhpError(); + } + return $result; +} + + +/** + * Behaves the same as strftime except that the + * time returned is Greenwich Mean Time (GMT). For example, when run + * in Eastern Standard Time (GMT -0500), the first line below prints + * "Dec 31 1998 20:00:00", while the second prints "Jan 01 1999 + * 01:00:00". * - * @param string $format The format of the outputted date string. See the formatting - * options for the date function. + * @param string $format See description in strftime. * @param int $timestamp The optional timestamp parameter is an - * integer Unix timestamp that defaults to the current - * local time if a timestamp is not given. In other + * int Unix timestamp that defaults to the current + * local time if timestamp is omitted or NULL. In other * words, it defaults to the value of time. - * @return string Returns a formatted date string. If a non-numeric value is used for - * timestamp, FALSE is returned and an - * E_WARNING level error is emitted. + * @return string Returns a string formatted according to the given format string + * using the given timestamp or the current + * local time if no timestamp is given. Month and weekday names and + * other language dependent strings respect the current locale set + * with setlocale. + * On failure, FALSE is returned. * @throws DatetimeException * */ -function gmdate(string $format, int $timestamp = null): string +function gmstrftime(string $format, int $timestamp = null): string { error_clear_last(); if ($timestamp !== null) { - $result = \gmdate($format, $timestamp); + $result = \gmstrftime($format, $timestamp); } else { - $result = \gmdate($format); + $result = \gmstrftime($format); + } + if ($result === false) { + throw DatetimeException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns a number formatted according to the given format string using the + * given integer timestamp or the current local time + * if no timestamp is given. In other words, timestamp + * is optional and defaults to the value of time. + * + * Unlike the function date, idate + * accepts just one char in the format parameter. + * + * @param string $format + * The following characters are recognized in the + * format parameter string + * + * + * + * format character + * Description + * + * + * + * + * B + * Swatch Beat/Internet Time + * + * + * d + * Day of the month + * + * + * h + * Hour (12 hour format) + * + * + * H + * Hour (24 hour format) + * + * + * i + * Minutes + * + * + * I (uppercase i) + * returns 1 if DST is activated, + * 0 otherwise + * + * + * L (uppercase l) + * returns 1 for leap year, + * 0 otherwise + * + * + * m + * Month number + * + * + * N + * ISO-8601 day of the week (1 for Monday + * through 7 for Sunday) + * + * + * o + * ISO-8601 year (4 digits) + * + * + * s + * Seconds + * + * + * t + * Days in current month + * + * + * U + * Seconds since the Unix Epoch - January 1 1970 00:00:00 UTC - + * this is the same as time + * + * + * w + * Day of the week (0 on Sunday) + * + * + * W + * ISO-8601 week number of year, weeks starting on + * Monday + * + * + * y + * Year (1 or 2 digits - check note below) + * + * + * Y + * Year (4 digits) + * + * + * z + * Day of the year + * + * + * Z + * Timezone offset in seconds + * + * + * + * + * @param int $timestamp The optional timestamp parameter is an + * int Unix timestamp that defaults to the current + * local time if timestamp is omitted or NULL. In other + * words, it defaults to the value of time. + * @return int Returns an int on success. + * + * As idate always returns an int and + * as they can't start with a "0", idate may return + * fewer digits than you would expect. See the example below. + * @throws DatetimeException + * + */ +function idate(string $format, int $timestamp = null): int +{ + error_clear_last(); + if ($timestamp !== null) { + $result = \idate($format, $timestamp); + } else { + $result = \idate($format); } if ($result === false) { throw DatetimeException::createFromPhpError(); @@ -452,16 +662,14 @@ function gmdate(string $format, int $timestamp = null): string * with values between 0-69 mapping to 2000-2069 and 70-100 to * 1970-2000. On systems where time_t is a 32bit signed integer, as * most common today, the valid range for year - * is somewhere between 1901 and 2038. However, before PHP 5.1.0 this - * range was limited from 1970 to 2038 on some systems (e.g. Windows). + * is somewhere between 1901 and 2038. * @return int mktime returns the Unix timestamp of the arguments * given. - * If the arguments are invalid, the function returns FALSE (before PHP 5.1 - * it returned -1). + * If the arguments are invalid, the function returns FALSE. * @throws DatetimeException * */ -function mktime(int $hour = null, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int +function mktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int { error_clear_last(); if ($year !== null) { @@ -474,10 +682,336 @@ function mktime(int $hour = null, int $minute = null, int $second = null, int $m $result = \mktime($hour, $minute, $second); } elseif ($minute !== null) { $result = \mktime($hour, $minute); - } elseif ($hour !== null) { + } else { $result = \mktime($hour); + } + if ($result === false) { + throw DatetimeException::createFromPhpError(); + } + return $result; +} + + +/** + * Format the time and/or date according to locale settings. Month and weekday + * names and other language-dependent strings respect the current locale set + * with setlocale. + * + * Not all conversion specifiers may be supported by your C library, in which + * case they will not be supported by PHP's strftime. + * Additionally, not all platforms support negative timestamps, so your + * date range may be limited to no earlier than the Unix epoch. This means that + * %e, %T, %R and, %D (and possibly others) - as well as dates prior to + * Jan 1, 1970 - will not work on Windows, some Linux + * distributions, and a few other operating systems. For Windows systems, a + * complete overview of supported conversion specifiers can be found at + * MSDN. + * + * @param string $format + * The following characters are recognized in the + * format parameter string + * + * + * + * format + * Description + * Example returned values + * + * + * + * + * Day + * --- + * --- + * + * + * %a + * An abbreviated textual representation of the day + * Sun through Sat + * + * + * %A + * A full textual representation of the day + * Sunday through Saturday + * + * + * %d + * Two-digit day of the month (with leading zeros) + * 01 to 31 + * + * + * %e + * + * Day of the month, with a space preceding single digits. Not + * implemented as described on Windows. See below for more information. + * + * 1 to 31 + * + * + * %j + * Day of the year, 3 digits with leading zeros + * 001 to 366 + * + * + * %u + * ISO-8601 numeric representation of the day of the week + * 1 (for Monday) through 7 (for Sunday) + * + * + * %w + * Numeric representation of the day of the week + * 0 (for Sunday) through 6 (for Saturday) + * + * + * Week + * --- + * --- + * + * + * %U + * Week number of the given year, starting with the first + * Sunday as the first week + * 13 (for the 13th full week of the year) + * + * + * %V + * ISO-8601:1988 week number of the given year, starting with + * the first week of the year with at least 4 weekdays, with Monday + * being the start of the week + * 01 through 53 (where 53 + * accounts for an overlapping week) + * + * + * %W + * A numeric representation of the week of the year, starting + * with the first Monday as the first week + * 46 (for the 46th week of the year beginning + * with a Monday) + * + * + * Month + * --- + * --- + * + * + * %b + * Abbreviated month name, based on the locale + * Jan through Dec + * + * + * %B + * Full month name, based on the locale + * January through December + * + * + * %h + * Abbreviated month name, based on the locale (an alias of %b) + * Jan through Dec + * + * + * %m + * Two digit representation of the month + * 01 (for January) through 12 (for December) + * + * + * Year + * --- + * --- + * + * + * %C + * Two digit representation of the century (year divided by 100, truncated to an integer) + * 19 for the 20th Century + * + * + * %g + * Two digit representation of the year going by ISO-8601:1988 standards (see %V) + * Example: 09 for the week of January 6, 2009 + * + * + * %G + * The full four-digit version of %g + * Example: 2008 for the week of January 3, 2009 + * + * + * %y + * Two digit representation of the year + * Example: 09 for 2009, 79 for 1979 + * + * + * %Y + * Four digit representation for the year + * Example: 2038 + * + * + * Time + * --- + * --- + * + * + * %H + * Two digit representation of the hour in 24-hour format + * 00 through 23 + * + * + * %k + * Hour in 24-hour format, with a space preceding single digits + * 0 through 23 + * + * + * %I + * Two digit representation of the hour in 12-hour format + * 01 through 12 + * + * + * %l (lower-case 'L') + * Hour in 12-hour format, with a space preceding single digits + * 1 through 12 + * + * + * %M + * Two digit representation of the minute + * 00 through 59 + * + * + * %p + * UPPER-CASE 'AM' or 'PM' based on the given time + * Example: AM for 00:31, + * PM for 22:23. The exact result depends on the + * Operating System, and they can also return lower-case variants, or + * variants with dots (such as a.m.). + * + * + * %P + * lower-case 'am' or 'pm' based on the given time + * Example: am for 00:31, + * pm for 22:23. Not supported by all Operating + * Systems. + * + * + * %r + * Same as "%I:%M:%S %p" + * Example: 09:34:17 PM for 21:34:17 + * + * + * %R + * Same as "%H:%M" + * Example: 00:35 for 12:35 AM, 16:44 for 4:44 PM + * + * + * %S + * Two digit representation of the second + * 00 through 59 + * + * + * %T + * Same as "%H:%M:%S" + * Example: 21:34:17 for 09:34:17 PM + * + * + * %X + * Preferred time representation based on locale, without the date + * Example: 03:59:16 or 15:59:16 + * + * + * %z + * The time zone offset. Not implemented as described on + * Windows. See below for more information. + * Example: -0500 for US Eastern Time + * + * + * %Z + * The time zone abbreviation. Not implemented as described on + * Windows. See below for more information. + * Example: EST for Eastern Time + * + * + * Time and Date Stamps + * --- + * --- + * + * + * %c + * Preferred date and time stamp based on locale + * Example: Tue Feb 5 00:45:10 2009 for + * February 5, 2009 at 12:45:10 AM + * + * + * %D + * Same as "%m/%d/%y" + * Example: 02/05/09 for February 5, 2009 + * + * + * %F + * Same as "%Y-%m-%d" (commonly used in database datestamps) + * Example: 2009-02-05 for February 5, 2009 + * + * + * %s + * Unix Epoch Time timestamp (same as the time + * function) + * Example: 305815200 for September 10, 1979 08:40:00 AM + * + * + * %x + * Preferred date representation based on locale, without the time + * Example: 02/05/09 for February 5, 2009 + * + * + * Miscellaneous + * --- + * --- + * + * + * %n + * A newline character ("\n") + * --- + * + * + * %t + * A Tab character ("\t") + * --- + * + * + * %% + * A literal percentage character ("%") + * --- + * + * + * + * + * + * Windows only: + * + * The %e modifier is not supported in the Windows + * implementation of this function. To achieve this value, the + * %#d modifier can be used instead. The example below + * illustrates how to write a cross platform compatible function. + * + * The %z and %Z modifiers both + * return the time zone name instead of the offset or abbreviation. + * @param int $timestamp The optional timestamp parameter is an + * int Unix timestamp that defaults to the current + * local time if timestamp is omitted or NULL. In other + * words, it defaults to the value of time. + * @return string Returns a string formatted according format + * using the given timestamp or the current + * local time if no timestamp is given. Month and weekday names and + * other language-dependent strings respect the current locale set + * with setlocale. + * The function returns FALSE if format is empty, contains unsupported + * conversion specifiers, or if the length of the returned string would be greater than + * 4095. + * @throws DatetimeException + * + */ +function strftime(string $format, int $timestamp = null): string +{ + error_clear_last(); + if ($timestamp !== null) { + $result = \strftime($format, $timestamp); } else { - $result = \mktime(); + $result = \strftime($format); } if ($result === false) { throw DatetimeException::createFromPhpError(); @@ -488,13 +1022,13 @@ function mktime(int $hour = null, int $minute = null, int $second = null, int $m /** * strptime returns an array with the - * date parsed. + * timestamp parsed. * * Month and weekday names and other language dependent strings respect the * current locale set with setlocale (LC_TIME). * - * @param string $date The string to parse (e.g. returned from strftime). - * @param string $format The format used in date (e.g. the same as + * @param string $timestamp The string to parse (e.g. returned from strftime). + * @param string $format The format used in timestamp (e.g. the same as * used in strftime). Note that some of the format * options available to strftime may not have any * effect within strptime; the exact subset that are @@ -549,7 +1083,7 @@ function mktime(int $hour = null, int $minute = null, int $second = null, int $m * * * "unparsed" - * the date part which was not + * the timestamp part which was not * recognized using the specified format * * @@ -558,10 +1092,10 @@ function mktime(int $hour = null, int $minute = null, int $second = null, int $m * @throws DatetimeException * */ -function strptime(string $date, string $format): array +function strptime(string $timestamp, string $format): array { error_clear_last(); - $result = \strptime($date, $format); + $result = \strptime($timestamp, $format); if ($result === false) { throw DatetimeException::createFromPhpError(); } @@ -577,18 +1111,17 @@ function strptime(string $date, string $format): array * ways to define the default time zone. * * @param string $datetime A date/time string. Valid formats are explained in Date and Time Formats. - * @param int $now The timestamp which is used as a base for the calculation of relative + * @param int $baseTimestamp The timestamp which is used as a base for the calculation of relative * dates. - * @return int Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, - * this function would return -1 on failure. + * @return int Returns a timestamp on success, FALSE otherwise. * @throws DatetimeException * */ -function strtotime(string $datetime, int $now = null): int +function strtotime(string $datetime, int $baseTimestamp = null): int { error_clear_last(); - if ($now !== null) { - $result = \strtotime($datetime, $now); + if ($baseTimestamp !== null) { + $result = \strtotime($datetime, $baseTimestamp); } else { $result = \strtotime($datetime); } diff --git a/vendor/thecodingmachine/safe/generated/dir.php b/vendor/thecodingmachine/safe/generated/dir.php index 628dec537..fe4ea5af5 100644 --- a/vendor/thecodingmachine/safe/generated/dir.php +++ b/vendor/thecodingmachine/safe/generated/dir.php @@ -31,6 +31,9 @@ function chdir(string $directory): void * 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 * @@ -74,7 +77,7 @@ function getcwd(): string * closedir, readdir, and * rewinddir calls. * - * @param string $path The directory path that is to be opened + * @param string $directory The directory path that is to be opened * @param resource $context For a description of the context parameter, * refer to the streams section of * the manual. @@ -82,13 +85,13 @@ function getcwd(): string * @throws DirException * */ -function opendir(string $path, $context = null) +function opendir(string $directory, $context = null) { error_clear_last(); if ($context !== null) { - $result = \opendir($path, $context); + $result = \opendir($directory, $context); } else { - $result = \opendir($path); + $result = \opendir($directory); } if ($result === false) { throw DirException::createFromPhpError(); @@ -98,32 +101,6 @@ function opendir(string $path, $context = null) /** - * Resets the directory stream indicated by - * dir_handle to the beginning of the - * directory. - * - * @param resource $dir_handle The directory handle resource previously opened - * with opendir. If the directory handle is - * not specified, the last link opened by opendir - * is assumed. - * @throws DirException - * - */ -function rewinddir($dir_handle = null): void -{ - error_clear_last(); - if ($dir_handle !== null) { - $result = \rewinddir($dir_handle); - } else { - $result = \rewinddir(); - } - if ($result === false) { - throw DirException::createFromPhpError(); - } -} - - -/** * Returns an array of files and directories from the * directory. * diff --git a/vendor/thecodingmachine/safe/generated/eio.php b/vendor/thecodingmachine/safe/generated/eio.php index 8d2f538e8..1fffa9004 100644 --- a/vendor/thecodingmachine/safe/generated/eio.php +++ b/vendor/thecodingmachine/safe/generated/eio.php @@ -414,6 +414,57 @@ function eio_fchmod($fd, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callba /** + * eio_fchown changes ownership of the file specified by + * fd file descriptor. + * + * @param mixed $fd Stream, Socket resource, or numeric file descriptor. + * @param int $uid User ID. Is ignored when equal to -1. + * @param int $gid Group ID. Is ignored when equal to -1. + * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL. + * If NULL passed, pri internally is set to + * EIO_PRI_DEFAULT. + * @param callable $callback + * callback function is called when the request is done. + * It should match the following prototype: + * + * + * data + * is custom data passed to the request. + * + * + * result + * request-specific result value; basically, the value returned by corresponding + * system call. + * + * + * req + * is optional request resource which can be used with functions like eio_get_last_error + * + * + * + * is custom data passed to the request. + * + * request-specific result value; basically, the value returned by corresponding + * system call. + * + * is optional request resource which can be used with functions like eio_get_last_error + * @param mixed $data is custom data passed to the request. + * @return resource eio_chmod returns request resource on success. + * @throws EioException + * + */ +function eio_fchown($fd, int $uid, int $gid = -1, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) +{ + error_clear_last(); + $result = \eio_fchown($fd, $uid, $gid, $pri, $callback, $data); + if ($result === false) { + throw EioException::createFromPhpError(); + } + return $result; +} + + +/** * eio_fdatasync synchronizes a file's in-core state with storage device. * * @param mixed $fd Stream, Socket resource, or numeric file descriptor, e.g. returned by eio_open. @@ -1061,7 +1112,8 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * is optional request resource which can be used with functions like eio_get_last_error * @param string $data is custom data passed to the request. - * @return resource eio_readdir returns request resource on success. Sets result argument of + * @return resource eio_readdir returns request resource on success. + * Sets result argument of * callback function according to * flags: * @@ -1071,7 +1123,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_READDIR_DENTS - * (integer) + * (int) * * * @@ -1091,7 +1143,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_READDIR_DIRS_FIRST - * (integer) + * (int) * * * @@ -1103,7 +1155,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_READDIR_STAT_ORDER - * (integer) + * (int) * * * @@ -1118,7 +1170,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_READDIR_FOUND_UNKNOWN - * (integer) + * (int) * * * @@ -1137,7 +1189,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_UNKNOWN - * (integer) + * (int) * * * @@ -1148,7 +1200,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_FIFO - * (integer) + * (int) * * * @@ -1159,7 +1211,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_CHR - * (integer) + * (int) * * * @@ -1170,7 +1222,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_MPC - * (integer) + * (int) * * * @@ -1181,7 +1233,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_DIR - * (integer) + * (int) * * * @@ -1192,7 +1244,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_NAM - * (integer) + * (int) * * * @@ -1203,7 +1255,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_BLK - * (integer) + * (int) * * * @@ -1214,7 +1266,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_MPB - * (integer) + * (int) * * * @@ -1225,7 +1277,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_REG - * (integer) + * (int) * * * @@ -1236,7 +1288,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_NWK - * (integer) + * (int) * * * @@ -1246,7 +1298,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_CMP - * (integer) + * (int) * * * @@ -1257,7 +1309,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_LNK - * (integer) + * (int) * * * @@ -1268,7 +1320,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_SOCK - * (integer) + * (int) * * * @@ -1279,7 +1331,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_DOOR - * (integer) + * (int) * * * @@ -1290,7 +1342,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_WHT - * (integer) + * (int) * * * @@ -1301,7 +1353,7 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT * * * EIO_DT_MAX - * (integer) + * (int) * * * @@ -1672,7 +1724,8 @@ function eio_stat(string $path, int $pri, callable $callback, $data = null) * * is optional request resource which can be used with functions like eio_get_last_error * @param mixed $data is custom data passed to the request. - * @return resource eio_statvfs returns request resource on success. On success assigns result argument of + * @return resource eio_statvfs returns request resource on success. + * On success assigns result argument of * callback to an array. * @throws EioException * diff --git a/vendor/thecodingmachine/safe/generated/errorfunc.php b/vendor/thecodingmachine/safe/generated/errorfunc.php index ac64a7d8b..9d3e98b2c 100644 --- a/vendor/thecodingmachine/safe/generated/errorfunc.php +++ b/vendor/thecodingmachine/safe/generated/errorfunc.php @@ -30,7 +30,7 @@ use Safe\Exceptions\ErrorfuncException; * message is sent by email to the address in * the destination parameter. This is the only * message type where the fourth parameter, - * extra_headers is used. + * additional_headers is used. * * * @@ -59,18 +59,18 @@ use Safe\Exceptions\ErrorfuncException; * * @param string $destination The destination. Its meaning depends on the * message_type parameter as described above. - * @param string $extra_headers The extra headers. It's used when the message_type + * @param string $additional_headers The extra headers. It's used when the message_type * parameter is set to 1. * This message type uses the same internal function as * mail does. * @throws ErrorfuncException * */ -function error_log(string $message, int $message_type = 0, string $destination = null, string $extra_headers = null): void +function error_log(string $message, int $message_type = 0, string $destination = null, string $additional_headers = null): void { error_clear_last(); - if ($extra_headers !== null) { - $result = \error_log($message, $message_type, $destination, $extra_headers); + if ($additional_headers !== null) { + $result = \error_log($message, $message_type, $destination, $additional_headers); } elseif ($destination !== null) { $result = \error_log($message, $message_type, $destination); } else { diff --git a/vendor/thecodingmachine/safe/generated/exec.php b/vendor/thecodingmachine/safe/generated/exec.php index e9a40e08b..126438d43 100644 --- a/vendor/thecodingmachine/safe/generated/exec.php +++ b/vendor/thecodingmachine/safe/generated/exec.php @@ -5,122 +5,97 @@ namespace Safe; use Safe\Exceptions\ExecException; /** - * proc_get_status fetches data about a - * process opened using proc_open. - * - * @param resource $process The proc_open resource that will - * be evaluated. - * @return array An array of collected information on success. The returned array contains the following elements: - * - * - * - * - * elementtypedescription - * - * - * - * command - * string - * - * The command string that was passed to proc_open. - * - * - * - * pid - * int - * process id - * - * - * running - * bool - * - * TRUE if the process is still running, FALSE if it has - * terminated. - * - * - * - * signaled - * bool - * - * TRUE if the child process has been terminated by - * an uncaught signal. Always set to FALSE on Windows. - * - * - * - * stopped - * bool - * - * TRUE if the child process has been stopped by a - * signal. Always set to FALSE on Windows. - * - * - * - * exitcode - * int - * - * The exit code returned by the process (which is only - * meaningful if running is FALSE). - * Only first call of this function return real value, next calls return - * -1. - * - * - * - * termsig - * int - * - * The number of the signal that caused the child process to terminate - * its execution (only meaningful if signaled is TRUE). - * - * - * - * stopsig - * int - * - * The number of the signal that caused the child process to stop its - * execution (only meaningful if stopped is TRUE). + * exec executes the given + * command. * + * @param string $command The command that will be executed. + * @param array|null $output If the output argument is present, then the + * specified array will be filled with every line of output from the + * command. Trailing whitespace, such as \n, is not + * included in this array. Note that if the array already contains some + * elements, exec will append to the end of the array. + * If you do not want the function to append elements, call + * unset on the array before passing it to + * exec. + * @param int|null $result_code If the result_code argument is present + * along with the output argument, then the + * return status of the executed command will be written to this + * variable. + * @return string The last line from the result of the command. If you need to execute a + * command and have all the data from the command passed directly back without + * any interference, use the passthru function. * + * Returns FALSE on failure. * + * To get the output of the executed command, be sure to set and use the + * output parameter. + * @throws ExecException * + */ +function exec(string $command, ?array &$output = null, ?int &$result_code = null): string +{ + error_clear_last(); + $result = \exec($command, $output, $result_code); + if ($result === false) { + throw ExecException::createFromPhpError(); + } + return $result; +} + + +/** + * The passthru function is similar to the + * exec function in that it executes a + * command. This function + * should be used in place of exec or + * system when the output from the Unix command + * is binary data which needs to be passed directly back to the + * browser. A common use for this is to execute something like the + * pbmplus utilities that can output an image stream directly. By + * setting the Content-type to image/gif and + * then calling a pbmplus program to output a gif, you can create + * PHP scripts that output images directly. * + * @param string $command The command that will be executed. + * @param int|null $result_code If the result_code argument is present, the + * return status of the Unix command will be placed here. * @throws ExecException * */ -function proc_get_status($process): array +function passthru(string $command, ?int &$result_code = null): void { error_clear_last(); - $result = \proc_get_status($process); + $result = \passthru($command, $result_code); if ($result === false) { throw ExecException::createFromPhpError(); } - return $result; } /** * proc_nice changes the priority of the current - * process by the amount specified in increment. A - * positive increment will lower the priority of the - * current process, whereas a negative increment + * process by the amount specified in priority. A + * positive priority will lower the priority of the + * current process, whereas a negative priority * will raise the priority. * * proc_nice is not related to * proc_open and its associated functions in any way. * - * @param int $increment The new priority value, the value of this may differ on platforms. + * @param int $priority The new priority value, the value of this may differ on platforms. * * On Unix, a low value, such as -20 means high priority - * wheras a positive value have a lower priority. + * whereas positive values have a lower priority. * - * For Windows the increment parameter have the - * following meanings: + * For Windows the priority parameter has the + * following meaning: * @throws ExecException * */ -function proc_nice(int $increment): void +function proc_nice(int $priority): void { error_clear_last(); - $result = \proc_nice($increment); + $result = \proc_nice($priority); if ($result === false) { throw ExecException::createFromPhpError(); } @@ -128,6 +103,26 @@ function proc_nice(int $increment): void /** + * This function is identical to the backtick operator. + * + * @param string $command The command that will be executed. + * @return string A string containing the output from the executed command, FALSE if the pipe + * cannot be established or NULL if an error occurs or the command produces no output. + * @throws ExecException + * + */ +function shell_exec(string $command): string +{ + error_clear_last(); + $result = \shell_exec($command); + if ($result === null) { + throw ExecException::createFromPhpError(); + } + return $result; +} + + +/** * system is just like the C version of the * function in that it executes the given * command and outputs the result. @@ -141,17 +136,17 @@ function proc_nice(int $increment): void * passthru function. * * @param string $command The command that will be executed. - * @param int $return_var If the return_var argument is present, then the + * @param int|null $result_code If the result_code argument is present, then the * return status of the executed command will be written to this * variable. * @return string Returns the last line of the command output on success. * @throws ExecException * */ -function system(string $command, int &$return_var = null): string +function system(string $command, ?int &$result_code = null): string { error_clear_last(); - $result = \system($command, $return_var); + $result = \system($command, $result_code); if ($result === false) { throw ExecException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/fileinfo.php b/vendor/thecodingmachine/safe/generated/fileinfo.php index 50345b67c..8bbfd3c47 100644 --- a/vendor/thecodingmachine/safe/generated/fileinfo.php +++ b/vendor/thecodingmachine/safe/generated/fileinfo.php @@ -5,9 +5,9 @@ namespace Safe; use Safe\Exceptions\FileinfoException; /** - * This function closes the resource opened by finfo_open. + * This function closes the instance opened by finfo_open. * - * @param resource $finfo Fileinfo resource returned by finfo_open. + * @param resource $finfo An finfo instance, returned by finfo_open. * @throws FileinfoException * */ @@ -24,13 +24,13 @@ function finfo_close($finfo): void /** * Procedural style * - * Object oriented style (constructor): + * Object-oriented style (constructor): * - * This function opens a magic database and returns its resource. + * This function opens a magic database and returns its instance. * - * @param int $options One or disjunction of more Fileinfo + * @param int $flags One or disjunction of more Fileinfo * constants. - * @param string $magic_file Name of a magic database file, usually something like + * @param 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 @@ -39,14 +39,18 @@ function finfo_close($finfo): void * Passing NULL or an empty string will be equivalent to the default * value. * @return resource (Procedural style only) - * Returns a magic database resource on success. + * Returns an finfo instance on success. * @throws FileinfoException * */ -function finfo_open(int $options = FILEINFO_NONE, string $magic_file = "") +function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = null) { error_clear_last(); - $result = \finfo_open($options, $magic_file); + if ($magic_database !== null) { + $result = \finfo_open($flags, $magic_database); + } else { + $result = \finfo_open($flags); + } if ($result === false) { throw FileinfoException::createFromPhpError(); } @@ -58,13 +62,13 @@ function finfo_open(int $options = FILEINFO_NONE, string $magic_file = "") * Returns the MIME content type for a file as determined by using * information from the magic.mime file. * - * @param string $filename Path to the tested file. + * @param string|resource $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(string $filename): string +function mime_content_type($filename): string { error_clear_last(); $result = \mime_content_type($filename); diff --git a/vendor/thecodingmachine/safe/generated/filesystem.php b/vendor/thecodingmachine/safe/generated/filesystem.php index ee0a4bdf1..f3e5a2081 100644 --- a/vendor/thecodingmachine/safe/generated/filesystem.php +++ b/vendor/thecodingmachine/safe/generated/filesystem.php @@ -28,12 +28,12 @@ function chgrp(string $filename, $group): void /** * Attempts to change the mode of the specified file to that given in - * mode. + * permissions. * * @param string $filename Path to the file. - * @param int $mode Note that mode is not automatically + * @param int $permissions Note that permissions is not automatically * assumed to be an octal value, so to ensure the expected operation, - * you need to prefix mode with a zero (0). + * you need to prefix permissions with a zero (0). * Strings such as "g+w" will not work properly. * * @@ -43,7 +43,7 @@ function chgrp(string $filename, $group): void * * * - * The mode parameter consists of three octal + * The permissions parameter consists of three octal * number components specifying access restrictions for the owner, * the user group in which the owner is in, and to everybody else in * this order. One component can be computed by adding up the needed @@ -58,10 +58,10 @@ function chgrp(string $filename, $group): void * * */ -function chmod(string $filename, int $mode): void +function chmod(string $filename, int $permissions): void { error_clear_last(); - $result = \chmod($filename, $mode); + $result = \chmod($filename, $permissions); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -89,13 +89,13 @@ function chown(string $filename, $user): void /** - * Makes a copy of the file source to - * dest. + * Makes a copy of the file from to + * to. * * If you wish to move a file, use the rename function. * - * @param string $source Path to the source file. - * @param string $dest The destination path. If dest is a URL, the + * @param string $from Path to the source file. + * @param string $to The destination path. If to is a URL, the * copy operation may fail if the wrapper does not support overwriting of * existing files. * @@ -105,13 +105,13 @@ function chown(string $filename, $user): void * @throws FilesystemException * */ -function copy(string $source, string $dest, $context = null): void +function copy(string $from, string $to, $context = null): void { error_clear_last(); if ($context !== null) { - $result = \copy($source, $dest, $context); + $result = \copy($from, $to, $context); } else { - $result = \copy($source, $dest); + $result = \copy($from, $to); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -165,17 +165,40 @@ function disk_total_space(string $directory): float /** - * The file pointed to by handle is closed. + * The file pointed to by stream is closed. * - * @param resource $handle The file pointer must be valid, and must point to a file successfully + * @param resource $stream The file pointer must be valid, and must point to a file successfully * opened by fopen or fsockopen. * @throws FilesystemException * */ -function fclose($handle): void +function fclose($stream): void { error_clear_last(); - $result = \fclose($handle); + $result = \fclose($stream); + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } +} + + +/** + * This function synchronizes stream contents to storage media, just like fsync does, + * but it does not synchronize file meta-data. + * Note that this function is only effectively different in POSIX systems. + * In Windows, this function is aliased to fsync. + * + * @param resource $stream The file pointer must be valid, and must point to + * a file successfully opened by fopen or + * fsockopen (and not yet closed by + * fclose). + * @throws FilesystemException + * + */ +function fdatasync($stream): void +{ + error_clear_last(); + $result = \fdatasync($stream); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -184,19 +207,19 @@ function fclose($handle): void /** * This function forces a write of all buffered output to the resource - * pointed to by the file handle. + * pointed to by the file stream. * - * @param resource $handle The file pointer must be valid, and must point to + * @param resource $stream The file pointer must be valid, and must point to * a file successfully opened by fopen or * fsockopen (and not yet closed by * fclose). * @throws FilesystemException * */ -function fflush($handle): void +function fflush($stream): void { error_clear_last(); - $result = \fflush($handle); + $result = \fflush($stream); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -204,10 +227,56 @@ function fflush($handle): void /** + * Similar to fgets except that + * fgetcsv parses the line it reads for fields in + * CSV format and returns an array containing the fields + * read. + * + * @param resource $stream A valid file pointer to a file successfully opened by + * fopen, popen, or + * fsockopen. + * @param int $length Must be greater than the longest line (in characters) to be found in + * the CSV file (allowing for trailing line-end characters). Otherwise the + * line is split in chunks of length characters, + * unless the split would occur inside an enclosure. + * + * Omitting this parameter (or setting it to 0, + * or NULL in PHP 8.0.0 or later) the maximum line length is not limited, + * which is slightly slower. + * @param string $separator The optional separator parameter sets the field separator (one single-byte character only). + * @param string $enclosure The optional enclosure parameter sets the field enclosure character (one single-byte character only). + * @param string $escape The optional escape parameter sets the escape character (at most one single-byte character). + * An empty string ("") disables the proprietary escape mechanism. + * @return array|null Returns an indexed array containing the fields read on success. + * @throws FilesystemException + * + */ +function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): ?array +{ + error_clear_last(); + if ($escape !== "\\") { + $result = \fgetcsv($stream, $length, $separator, $enclosure, $escape); + } elseif ($enclosure !== "\"") { + $result = \fgetcsv($stream, $length, $separator, $enclosure); + } elseif ($separator !== ",") { + $result = \fgetcsv($stream, $length, $separator); + } elseif ($length !== null) { + $result = \fgetcsv($stream, $length); + } else { + $result = \fgetcsv($stream); + } + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + +/** * This function is similar to file, except that * file_get_contents returns the file in a * string, starting at the specified offset - * up to maxlen bytes. On failure, + * up to length bytes. On failure, * file_get_contents will return FALSE. * * file_get_contents is the preferred way to read the @@ -230,18 +299,18 @@ function fflush($handle): void * Seeking (offset) is not supported with remote files. * Attempting to seek on non-local files may work with small offsets, but this * is unpredictable because it works on the buffered stream. - * @param int $maxlen Maximum length of data read. The default is to read until end + * @param int $length Maximum length of data read. The default is to read until end * of file is reached. Note that this parameter is applied to the * stream processed by the filters. * @return string The function returns the read data. * @throws FilesystemException * */ -function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $maxlen = null): string +function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $length = null): string { error_clear_last(); - if ($maxlen !== null) { - $result = \file_get_contents($filename, $use_include_path, $context, $offset, $maxlen); + if ($length !== null) { + $result = \file_get_contents($filename, $use_include_path, $context, $offset, $length); } elseif ($offset !== 0) { $result = \file_get_contents($filename, $use_include_path, $context, $offset); } elseif ($context !== null) { @@ -324,7 +393,7 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co * * * - * @param resource $context A valid context resource created with + * @param resource|null $context A valid context resource created with * stream_context_create. * @return int This function returns the number of bytes that were written to the file. * @throws FilesystemException @@ -508,6 +577,39 @@ function fileowner(string $filename): int /** + * Gets permissions for the given file. + * + * @param string $filename Path to the file. + * @return int Returns the file's permissions as a numeric mode. Lower bits of this mode + * are the same as the permissions expected by chmod, + * however on most platforms the return value will also include information on + * the type of file given as filename. The examples + * below demonstrate how to test the return value for specific permissions and + * file types on POSIX systems, including Linux and macOS. + * + * For local files, the specific return value is that of the + * st_mode member of the structure returned by the C + * library's stat function. Exactly which bits are set + * can vary from platform to platform, and looking up your specific platform's + * documentation is recommended if parsing the non-permission bits of the + * return value is required. + * + * Returns FALSE on failure. + * @throws FilesystemException + * + */ +function fileperms(string $filename): int +{ + error_clear_last(); + $result = \fileperms($filename); + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + +/** * Gets the size for the given file. * * @param string $filename Path to the file. @@ -532,16 +634,15 @@ function filesize(string $filename): int * model which can be used on virtually every platform (including most Unix * derivatives and even Windows). * - * On versions of PHP before 5.3.2, the lock is released also by - * fclose (which is also called automatically when script - * finished). + * The lock is released also by fclose, + * or when stream is garbage collected. * * PHP supports a portable way of locking complete files in an advisory way * (which means all accessing programs have to use the same way of locking * or it will not work). By default, this function will block until the * requested lock is acquired; this may be controlled with the LOCK_NB option documented below. * - * @param resource $handle A file system pointer resource + * @param resource $stream A file system pointer resource * that is typically created using fopen. * @param int $operation operation is one of the following: * @@ -565,15 +666,15 @@ function filesize(string $filename): int * It is also possible to add LOCK_NB as a bitmask to one * of the above operations, if flock should not * block during the locking attempt. - * @param int|null $wouldblock The optional third argument is set to 1 if the lock would block + * @param int|null $would_block The optional third argument is set to 1 if the lock would block * (EWOULDBLOCK errno condition). * @throws FilesystemException * */ -function flock($handle, int $operation, ?int &$wouldblock = null): void +function flock($stream, int $operation, ?int &$would_block = null): void { error_clear_last(); - $result = \flock($handle, $operation, $wouldblock); + $result = \flock($stream, $operation, $would_block); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -661,9 +762,8 @@ function flock($handle, int $operation, ?int &$wouldblock = null): void * * 'w+' * - * Open for reading and writing; place the file pointer at - * the beginning of the file and truncate the file to zero - * length. If the file does not exist, attempt to create it. + * Open for reading and writing; otherwise it has the + * same behavior as 'w'. * * * @@ -774,7 +874,8 @@ function flock($handle, int $operation, ?int &$wouldblock = null): void * @param bool $use_include_path The optional third use_include_path parameter * can be set to '1' or TRUE if you want to search for the file in the * include_path, too. - * @param resource $context + * @param resource|null $context A context stream + * resource. * @return resource Returns a file pointer resource on success * @throws FilesystemException * @@ -795,41 +896,9 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $ /** - * fputcsv formats a line (passed as a - * fields array) as CSV and writes it (terminated by a - * newline) to the specified file handle. - * - * @param resource $handle The file pointer must be valid, and must point to - * a file successfully opened by fopen or - * fsockopen (and not yet closed by - * fclose). - * @param array $fields An array of strings. - * @param string $delimiter The optional delimiter parameter sets the field - * delimiter (one character only). - * @param string $enclosure The optional enclosure parameter sets the field - * enclosure (one character only). - * @param string $escape_char The optional escape_char parameter sets the - * escape character (at most one character). - * An empty string ("") disables the proprietary escape mechanism. - * @return int Returns the length of the written string. - * @throws FilesystemException - * - */ -function fputcsv($handle, array $fields, string $delimiter = ",", string $enclosure = '"', string $escape_char = "\\"): int -{ - error_clear_last(); - $result = \fputcsv($handle, $fields, $delimiter, $enclosure, $escape_char); - if ($result === false) { - throw FilesystemException::createFromPhpError(); - } - return $result; -} - - -/** * fread reads up to * length bytes from the file pointer - * referenced by handle. Reading stops as soon as one + * referenced by stream. Reading stops as soon as one * of the following conditions is met: * * @@ -858,17 +927,42 @@ function fputcsv($handle, array $fields, string $delimiter = ",", string $enclos * * * - * @param resource $handle A file system pointer resource + * @param resource $stream A file system pointer resource * that is typically created using fopen. * @param int $length Up to length number of bytes read. * @return string Returns the read string. * @throws FilesystemException * */ -function fread($handle, int $length): string +function fread($stream, int $length): string +{ + error_clear_last(); + $result = \fread($stream, $length); + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + +/** + * Gathers the statistics of the file opened by the file + * pointer stream. This function is similar to the + * stat function except that it operates + * on an open file pointer instead of a filename. + * + * @param resource $stream A file system pointer resource + * that is typically created using fopen. + * @return array Returns an array with the statistics of the file; the format of the array + * is described in detail on the stat manual page. + * Returns FALSE on failure. + * @throws FilesystemException + * + */ +function fstat($stream): array { error_clear_last(); - $result = \fread($handle, $length); + $result = \fstat($stream); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -877,12 +971,33 @@ function fread($handle, int $length): string /** - * Takes the filepointer, handle, and truncates the file to + * This function synchronizes changes to the file, including its meta-data. This is similar to fflush, + * but it also instructs the operating system to write to the storage media. + * + * @param resource $stream The file pointer must be valid, and must point to + * a file successfully opened by fopen or + * fsockopen (and not yet closed by + * fclose). + * @throws FilesystemException + * + */ +function fsync($stream): void +{ + error_clear_last(); + $result = \fsync($stream); + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } +} + + +/** + * Takes the filepointer, stream, and truncates the file to * length, size. * - * @param resource $handle The file pointer. + * @param resource $stream The file pointer. * - * The handle must be open for writing. + * The stream must be open for writing. * @param int $size The size to truncate to. * * If size is larger than the file then the file @@ -893,10 +1008,10 @@ function fread($handle, int $length): string * @throws FilesystemException * */ -function ftruncate($handle, int $size): void +function ftruncate($stream, int $size): void { error_clear_last(); - $result = \ftruncate($handle, $size); + $result = \ftruncate($stream, $size); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -906,29 +1021,23 @@ function ftruncate($handle, int $size): void /** * * - * @param resource $handle A file system pointer resource + * @param resource $stream A file system pointer resource * that is typically created using fopen. - * @param string $string The string that is to be written. - * @param int $length If the length argument is given, writing will - * stop after length bytes have been written or - * the end of string is reached, whichever comes - * first. - * - * Note that if the length argument is given, - * then the magic_quotes_runtime - * configuration option will be ignored and no slashes will be - * stripped from string. + * @param string $data The string that is to be written. + * @param int $length If length is an integer, writing will stop + * after length bytes have been written or the + * end of data is reached, whichever comes first. * @return int * @throws FilesystemException * */ -function fwrite($handle, string $string, int $length = null): int +function fwrite($stream, string $data, int $length = null): int { error_clear_last(); if ($length !== null) { - $result = \fwrite($handle, $string, $length); + $result = \fwrite($stream, $data, $length); } else { - $result = \fwrite($handle, $string); + $result = \fwrite($stream, $data); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -1016,6 +1125,12 @@ function fwrite($handle, string $string, int $length = null): int * * * + * + * + * The GLOB_BRACE flag is not available on some non GNU + * systems, like Solaris or Alpine Linux. + * + * * @return array Returns an array containing the matched files/directories, an empty array * if no file matched. * @throws FilesystemException @@ -1095,32 +1210,67 @@ function link(string $target, string $link): void /** - * Attempts to create the directory specified by pathname. + * Gathers the statistics of the file or symbolic link named by + * filename. + * + * @param string $filename Path to a file or a symbolic link. + * @return array See the manual page for stat for information on + * the structure of the array that lstat returns. + * This function is identical to the stat function + * except that if the filename parameter is a symbolic + * link, the status of the symbolic link is returned, not the status of the + * file pointed to by the symbolic link. + * + * On failure, FALSE is returned. + * @throws FilesystemException * - * @param string $pathname The directory path. - * @param int $mode The mode is 0777 by default, which means the widest possible - * access. For more information on modes, read the details + */ +function lstat(string $filename): array +{ + error_clear_last(); + $result = \lstat($filename); + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + +/** + * Attempts to create the directory specified by directory. + * + * @param string $directory The directory path. + * A URL can be used as a + * filename with this function if the fopen wrappers have been enabled. + * See fopen for more details on how to specify the + * filename. See the for links to information + * about what abilities the various wrappers have, notes on their usage, + * and information on any predefined variables they may + * provide. + * @param int $permissions The permissions are 0777 by default, which means the widest possible + * access. For more information on permissions, read the details * on the chmod page. * - * mode is ignored on Windows. + * permissions is ignored on Windows. * - * Note that you probably want to specify the mode as an octal number, - * which means it should have a leading zero. The mode is also modified + * Note that you probably want to specify the permissions as an octal number, + * which means it should have a leading zero. The permissions is also modified * by the current umask, which you can change using * umask. - * @param bool $recursive Allows the creation of nested directories specified in the - * pathname. - * @param resource $context + * @param bool $recursive If TRUE, then any parent directories to the directory specified will + * also be created, with the same permissions. + * @param resource $context A context stream + * resource. * @throws FilesystemException * */ -function mkdir(string $pathname, int $mode = 0777, bool $recursive = false, $context = null): void +function mkdir(string $directory, int $permissions = 0777, bool $recursive = false, $context = null): void { error_clear_last(); if ($context !== null) { - $result = \mkdir($pathname, $mode, $recursive, $context); + $result = \mkdir($directory, $permissions, $recursive, $context); } else { - $result = \mkdir($pathname, $mode, $recursive); + $result = \mkdir($directory, $permissions, $recursive); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -1170,11 +1320,11 @@ function parse_ini_file(string $filename, bool $process_sections = false, int $s /** * parse_ini_string returns the settings in string - * ini in an associative array. + * ini_string in an associative array. * * The structure of the ini string is the same as the php.ini's. * - * @param string $ini The contents of the ini file being parsed. + * @param string $ini_string The contents of the ini file being parsed. * @param bool $process_sections By setting the process_sections * parameter to TRUE, you get a multidimensional array, with * the section names and settings included. The default @@ -1194,10 +1344,10 @@ function parse_ini_file(string $filename, bool $process_sections = false, int $s * @throws FilesystemException * */ -function parse_ini_string(string $ini, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array +function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array { error_clear_last(); - $result = \parse_ini_string($ini, $process_sections, $scanner_mode); + $result = \parse_ini_string($ini_string, $process_sections, $scanner_mode); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -1211,7 +1361,8 @@ function parse_ini_string(string $ini, bool $process_sections = false, int $scan * @param string $filename The filename being read. * @param bool $use_include_path You can use the optional second parameter and set it to TRUE, if * you want to search for the file in the include_path, too. - * @param resource $context A context stream resource. + * @param resource $context A context stream + * resource. * @return int Returns the number of bytes read from the file on success * @throws FilesystemException * @@ -1287,30 +1438,37 @@ function realpath(string $path): string /** - * Attempts to rename oldname to - * newname, moving it between directories if necessary. - * If renaming a file and newname exists, + * Attempts to rename from to + * to, moving it between directories if necessary. + * If renaming a file and to exists, * it will be overwritten. If renaming a directory and - * newname exists, + * to exists, * this function will emit a warning. * - * @param string $oldname The old name. + * @param string $from The old name. * - * The wrapper used in oldname + * The wrapper used in from * must match the wrapper used in - * newname. - * @param string $newname The new name. - * @param resource $context + * to. + * @param string $to The new name. + * + * + * On Windows, if to already exists, it must be writable. + * Otherwise rename fails and issues E_WARNING. + * + * + * @param resource $context A context stream + * resource. * @throws FilesystemException * */ -function rename(string $oldname, string $newname, $context = null): void +function rename(string $from, string $to, $context = null): void { error_clear_last(); if ($context !== null) { - $result = \rename($oldname, $newname, $context); + $result = \rename($from, $to, $context); } else { - $result = \rename($oldname, $newname); + $result = \rename($from, $to); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -1319,18 +1477,18 @@ function rename(string $oldname, string $newname, $context = null): void /** - * Sets the file position indicator for handle + * Sets the file position indicator for stream * to the beginning of the file stream. * - * @param resource $handle The file pointer must be valid, and must point to a file + * @param resource $stream The file pointer must be valid, and must point to a file * successfully opened by fopen. * @throws FilesystemException * */ -function rewind($handle): void +function rewind($stream): void { error_clear_last(); - $result = \rewind($handle); + $result = \rewind($stream); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -1338,22 +1496,23 @@ function rewind($handle): void /** - * Attempts to remove the directory named by dirname. + * Attempts to remove the directory named by directory. * The directory must be empty, and the relevant permissions must permit this. * A E_WARNING level error will be generated on failure. * - * @param string $dirname Path to the directory. - * @param resource $context + * @param string $directory Path to the directory. + * @param resource $context A context stream + * resource. * @throws FilesystemException * */ -function rmdir(string $dirname, $context = null): void +function rmdir(string $directory, $context = null): void { error_clear_last(); if ($context !== null) { - $result = \rmdir($dirname, $context); + $result = \rmdir($directory, $context); } else { - $result = \rmdir($dirname); + $result = \rmdir($directory); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -1387,16 +1546,16 @@ function symlink(string $target, string $link): void * generate a file in the system's temporary directory, and return * the full path to that file, including its name. * - * @param string $dir The directory where the temporary filename will be created. + * @param string $directory The directory where the temporary filename will be created. * @param string $prefix The prefix of the generated temporary filename. * @return string Returns the new temporary filename (with path). * @throws FilesystemException * */ -function tempnam(string $dir, string $prefix): string +function tempnam(string $directory, string $prefix): string { error_clear_last(); - $result = \tempnam($dir, $prefix); + $result = \tempnam($directory, $prefix); if ($result === false) { throw FilesystemException::createFromPhpError(); } @@ -1432,29 +1591,29 @@ function tmpfile() /** * Attempts to set the access and modification times of the file named in the * filename parameter to the value given in - * time. + * mtime. * Note that the access time is always modified, regardless of the number * of parameters. * * If the file does not exist, it will be created. * * @param string $filename The name of the file being touched. - * @param int $time The touch time. If time is not supplied, + * @param int $mtime The touch time. If mtime is NULL, * the current system time is used. - * @param int $atime If present, the access time of the given filename is set to + * @param int $atime If not NULL, the access time of the given filename is set to * the value of atime. Otherwise, it is set to - * the value passed to the time parameter. - * If neither are present, the current system time is used. + * the value passed to the mtime parameter. + * If both are NULL, the current system time is used. * @throws FilesystemException * */ -function touch(string $filename, int $time = null, int $atime = null): void +function touch(string $filename, int $mtime = null, int $atime = null): void { error_clear_last(); if ($atime !== null) { - $result = \touch($filename, $time, $atime); - } elseif ($time !== null) { - $result = \touch($filename, $time); + $result = \touch($filename, $mtime, $atime); + } elseif ($mtime !== null) { + $result = \touch($filename, $mtime); } else { $result = \touch($filename); } @@ -1470,7 +1629,11 @@ function touch(string $filename, int $time = null, int $atime = null): void * failure. * * @param string $filename Path to the file. - * @param resource $context + * + * If the file is a symlink, the symlink will be deleted. On Windows, to delete + * a symlink to a directory, rmdir has to be used instead. + * @param resource $context A context stream + * resource. * @throws FilesystemException * */ diff --git a/vendor/thecodingmachine/safe/generated/filter.php b/vendor/thecodingmachine/safe/generated/filter.php index 2d836c6c9..aba02b4d8 100644 --- a/vendor/thecodingmachine/safe/generated/filter.php +++ b/vendor/thecodingmachine/safe/generated/filter.php @@ -11,7 +11,7 @@ use Safe\Exceptions\FilterException; * @param int $type One of INPUT_GET, INPUT_POST, * INPUT_COOKIE, INPUT_SERVER, or * INPUT_ENV. - * @param int|array $definition An array defining the arguments. A valid key is a string + * @param int|array $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 @@ -23,7 +23,7 @@ use Safe\Exceptions\FilterException; * 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 mixed An array containing the values of the requested variables on success. + * @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. @@ -36,16 +36,10 @@ use Safe\Exceptions\FilterException; * @throws FilterException * */ -function filter_input_array(int $type, $definition = null, bool $add_empty = true) +function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empty = true): ?array { error_clear_last(); - if ($add_empty !== true) { - $result = \filter_input_array($type, $definition, $add_empty); - } elseif ($definition !== null) { - $result = \filter_input_array($type, $definition); - } else { - $result = \filter_input_array($type); - } + $result = \filter_input_array($type, $options, $add_empty); if ($result === false) { throw FilterException::createFromPhpError(); } @@ -57,8 +51,8 @@ function filter_input_array(int $type, $definition = null, bool $add_empty = tru * This function is useful for retrieving many values without * repetitively calling filter_var. * - * @param array $data An array with string keys containing the data to filter. - * @param mixed $definition An array defining the arguments. A valid key is a string + * @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. @@ -71,21 +65,15 @@ function filter_input_array(int $type, $definition = null, bool $add_empty = tru * 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 mixed An array containing the values of the requested variables on success. An array value will be FALSE if the filter fails, or NULL if + * @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 $data, $definition = null, bool $add_empty = true) +function filter_var_array(array $array, $options = FILTER_DEFAULT, bool $add_empty = true): ?array { error_clear_last(); - if ($add_empty !== true) { - $result = \filter_var_array($data, $definition, $add_empty); - } elseif ($definition !== null) { - $result = \filter_var_array($data, $definition); - } else { - $result = \filter_var_array($data); - } + $result = \filter_var_array($array, $options, $add_empty); if ($result === false) { throw FilterException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/ftp.php b/vendor/thecodingmachine/safe/generated/ftp.php index 174882657..23846bf1f 100644 --- a/vendor/thecodingmachine/safe/generated/ftp.php +++ b/vendor/thecodingmachine/safe/generated/ftp.php @@ -8,17 +8,17 @@ use Safe\Exceptions\FtpException; * Sends an ALLO command to the remote FTP server to * allocate space for a file to be uploaded. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param int $filesize The number of bytes to allocate. - * @param string $result A textual representation of the servers response will be returned by - * reference in result if a variable is provided. + * @param resource $ftp An FTP\Connection instance. + * @param int $size The number of bytes to allocate. + * @param string|null $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_stream, int $filesize, string &$result = null): void +function ftp_alloc($ftp, int $size, ?string &$response = null): void { error_clear_last(); - $result = \ftp_alloc($ftp_stream, $filesize, $result); + $result = \ftp_alloc($ftp, $size, $response); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -28,17 +28,17 @@ function ftp_alloc($ftp_stream, int $filesize, string &$result = null): void /** * * - * @param resource $ftp - * @param string $remote_file - * @param string $local_file + * @param resource $ftp An FTP\Connection instance. + * @param string $remote_filename + * @param string $local_filename * @param int $mode * @throws FtpException * */ -function ftp_append($ftp, string $remote_file, string $local_file, int $mode = FTP_BINARY): void +function ftp_append($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): void { error_clear_last(); - $result = \ftp_append($ftp, $remote_file, $local_file, $mode); + $result = \ftp_append($ftp, $remote_filename, $local_filename, $mode); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -48,14 +48,14 @@ function ftp_append($ftp, string $remote_file, string $local_file, int $mode = F /** * Changes to the parent directory. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. * @throws FtpException * */ -function ftp_cdup($ftp_stream): void +function ftp_cdup($ftp): void { error_clear_last(); - $result = \ftp_cdup($ftp_stream); + $result = \ftp_cdup($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -65,15 +65,15 @@ function ftp_cdup($ftp_stream): void /** * Changes the current directory to the specified one. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. * @param string $directory The target directory. * @throws FtpException * */ -function ftp_chdir($ftp_stream, string $directory): void +function ftp_chdir($ftp, string $directory): void { error_clear_last(); - $result = \ftp_chdir($ftp_stream, $directory); + $result = \ftp_chdir($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -82,19 +82,19 @@ function ftp_chdir($ftp_stream, string $directory): void /** * Sets the permissions on the specified remote file to - * mode. + * permissions. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param int $mode The new permissions, given as an octal value. + * @param resource $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_stream, int $mode, string $filename): int +function ftp_chmod($ftp, int $permissions, string $filename): int { error_clear_last(); - $result = \ftp_chmod($ftp_stream, $mode, $filename); + $result = \ftp_chmod($ftp, $permissions, $filename); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -106,14 +106,14 @@ function ftp_chmod($ftp_stream, int $mode, string $filename): int * ftp_close closes the given link identifier * and releases the resource. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. * @throws FtpException * */ -function ftp_close($ftp_stream): void +function ftp_close($ftp): void { error_clear_last(); - $result = \ftp_close($ftp_stream); + $result = \ftp_close($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -122,9 +122,9 @@ function ftp_close($ftp_stream): void /** * ftp_connect opens an FTP connection to the - * specified host. + * specified hostname. * - * @param string $host The FTP server address. This parameter shouldn't have any trailing + * @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. @@ -132,14 +132,14 @@ function ftp_close($ftp_stream): void * 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 resource Returns a FTP stream on success. + * @return resource Returns an FTP\Connection instance on success. * @throws FtpException * */ -function ftp_connect(string $host, int $port = 21, int $timeout = 90) +function ftp_connect(string $hostname, int $port = 21, int $timeout = 90) { error_clear_last(); - $result = \ftp_connect($host, $port, $timeout); + $result = \ftp_connect($hostname, $port, $timeout); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -149,17 +149,17 @@ function ftp_connect(string $host, int $port = 21, int $timeout = 90) /** * ftp_delete deletes the file specified by - * path from the FTP server. + * filename from the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $path The file to delete. + * @param resource $ftp An FTP\Connection instance. + * @param string $filename The file to delete. * @throws FtpException * */ -function ftp_delete($ftp_stream, string $path): void +function ftp_delete($ftp, string $filename): void { error_clear_last(); - $result = \ftp_delete($ftp_stream, $path); + $result = \ftp_delete($ftp, $filename); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -167,22 +167,22 @@ function ftp_delete($ftp_stream, string $path): void /** - * ftp_fget retrieves remote_file + * ftp_fget retrieves remote_filename * from the FTP server, and writes it to the given file pointer. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param resource $handle An open file pointer in which we store the data. - * @param string $remote_file The remote file path. + * @param resource $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 int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $resumepos The position in the remote file to start downloading from. + * @param int $offset The position in the remote file to start downloading from. * @throws FtpException * */ -function ftp_fget($ftp_stream, $handle, string $remote_file, int $mode = FTP_BINARY, int $resumepos = 0): void +function ftp_fget($ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_fget($ftp_stream, $handle, $remote_file, $mode, $resumepos); + $result = \ftp_fget($ftp, $stream, $remote_filename, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -193,19 +193,19 @@ function ftp_fget($ftp_stream, $handle, string $remote_file, int $mode = FTP_BIN * ftp_fput uploads the data from a file pointer * to a remote file on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $remote_file The remote file path. - * @param resource $handle An open file pointer on the local file. Reading stops at end of file. + * @param resource $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 int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $startpos The position in the remote file to start uploading to. + * @param int $offset The position in the remote file to start uploading to. * @throws FtpException * */ -function ftp_fput($ftp_stream, string $remote_file, $handle, int $mode = FTP_BINARY, int $startpos = 0): void +function ftp_fput($ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_fput($ftp_stream, $remote_file, $handle, $mode, $startpos); + $result = \ftp_fput($ftp, $remote_filename, $stream, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -216,19 +216,19 @@ function ftp_fput($ftp_stream, string $remote_file, $handle, int $mode = FTP_BIN * ftp_get retrieves a remote file from the FTP server, * and saves it into a local file. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $local_file The local file path (will be overwritten if the file already exists). - * @param string $remote_file The remote file path. + * @param resource $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 int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $resumepos The position in the remote file to start downloading from. + * @param int $offset The position in the remote file to start downloading from. * @throws FtpException * */ -function ftp_get($ftp_stream, string $local_file, string $remote_file, int $mode = FTP_BINARY, int $resumepos = 0): void +function ftp_get($ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_get($ftp_stream, $local_file, $remote_file, $mode, $resumepos); + $result = \ftp_get($ftp, $local_filename, $remote_filename, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -236,18 +236,18 @@ function ftp_get($ftp_stream, string $local_file, string $remote_file, int $mode /** - * Logs in to the given FTP stream. + * Logs in to the given FTP connection. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. * @param string $username The username (USER). * @param string $password The password (PASS). * @throws FtpException * */ -function ftp_login($ftp_stream, string $username, string $password): void +function ftp_login($ftp, string $username, string $password): void { error_clear_last(); - $result = \ftp_login($ftp_stream, $username, $password); + $result = \ftp_login($ftp, $username, $password); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -257,16 +257,16 @@ function ftp_login($ftp_stream, string $username, string $password): void /** * Creates the specified directory on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $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_stream, string $directory): string +function ftp_mkdir($ftp, string $directory): string { error_clear_last(); - $result = \ftp_mkdir($ftp_stream, $directory); + $result = \ftp_mkdir($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -277,16 +277,16 @@ function ftp_mkdir($ftp_stream, string $directory): string /** * * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $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_stream, string $directory): array +function ftp_mlsd($ftp, string $directory): array { error_clear_last(); - $result = \ftp_mlsd($ftp_stream, $directory); + $result = \ftp_mlsd($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -295,21 +295,50 @@ function ftp_mlsd($ftp_stream, string $directory): array /** + * 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 resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. + * @param string $remote_filename The remote file path. + * @param string $local_filename The local file path. + * @param int $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, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int +{ + error_clear_last(); + $result = \ftp_nb_put($ftp, $remote_filename, $local_filename, $mode, $offset); + if ($result === false) { + throw FtpException::createFromPhpError(); + } + return $result; +} + + +/** + * + * + * @param resource $ftp An FTP\Connection instance. * @param string $directory The directory to be listed. This parameter can also include arguments, eg. - * ftp_nlist($conn_id, "-la /your/dir"); + * 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_stream, string $directory): array +function ftp_nlist($ftp, string $directory): array { error_clear_last(); - $result = \ftp_nlist($ftp_stream, $directory); + $result = \ftp_nlist($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -326,15 +355,15 @@ function ftp_nlist($ftp_stream, string $directory): array * Please note that ftp_pasv can only be called after a * successful login or otherwise it will fail. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param bool $pasv If TRUE, the passive mode is turned on, else it's turned off. + * @param resource $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_stream, bool $pasv): void +function ftp_pasv($ftp, bool $enable): void { error_clear_last(); - $result = \ftp_pasv($ftp_stream, $pasv); + $result = \ftp_pasv($ftp, $enable); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -344,19 +373,19 @@ function ftp_pasv($ftp_stream, bool $pasv): void /** * ftp_put stores a local file on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $remote_file The remote file path. - * @param string $local_file The local file path. + * @param resource $ftp An FTP\Connection instance. + * @param string $remote_filename The remote file path. + * @param string $local_filename The local file path. * @param int $mode The transfer mode. Must be either FTP_ASCII or * FTP_BINARY. - * @param int $startpos The position in the remote file to start uploading to. + * @param int $offset The position in the remote file to start uploading to. * @throws FtpException * */ -function ftp_put($ftp_stream, string $remote_file, string $local_file, int $mode = FTP_BINARY, int $startpos = 0): void +function ftp_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): void { error_clear_last(); - $result = \ftp_put($ftp_stream, $remote_file, $local_file, $mode, $startpos); + $result = \ftp_put($ftp, $remote_filename, $local_filename, $mode, $offset); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -366,15 +395,15 @@ function ftp_put($ftp_stream, string $remote_file, string $local_file, int $mode /** * * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. * @return string Returns the current directory name. * @throws FtpException * */ -function ftp_pwd($ftp_stream): string +function ftp_pwd($ftp): string { error_clear_last(); - $result = \ftp_pwd($ftp_stream); + $result = \ftp_pwd($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -383,19 +412,41 @@ function ftp_pwd($ftp_stream): string /** + * Sends an arbitrary command to the FTP server. + * + * @param resource $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, string $command): array +{ + error_clear_last(); + $result = \ftp_raw($ftp, $command); + if ($result === null) { + throw FtpException::createFromPhpError(); + } + return $result; +} + + +/** * ftp_rename renames a file or a directory on the FTP * server. * - * @param resource $ftp_stream The link identifier of the FTP connection. - * @param string $oldname The old file/directory name. - * @param string $newname The new name. + * @param resource $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_stream, string $oldname, string $newname): void +function ftp_rename($ftp, string $from, string $to): void { error_clear_last(); - $result = \ftp_rename($ftp_stream, $oldname, $newname); + $result = \ftp_rename($ftp, $from, $to); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -405,16 +456,16 @@ function ftp_rename($ftp_stream, string $oldname, string $newname): void /** * Removes the specified directory on the FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $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_stream, string $directory): void +function ftp_rmdir($ftp, string $directory): void { error_clear_last(); - $result = \ftp_rmdir($ftp_stream, $directory); + $result = \ftp_rmdir($ftp, $directory); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -429,16 +480,16 @@ function ftp_rmdir($ftp_stream, string $directory): void * to server. They are useful for handling such things as file permissions and * group membership. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $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_stream, string $command): void +function ftp_site($ftp, string $command): void { error_clear_last(); - $result = \ftp_site($ftp_stream, $command); + $result = \ftp_site($ftp, $command); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -447,14 +498,14 @@ function ftp_site($ftp_stream, string $command): void /** * ftp_ssl_connect opens an explicit SSL-FTP connection to the - * specified host. That implies that + * 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 $host The FTP server address. This parameter shouldn't have any trailing + * @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. @@ -462,14 +513,14 @@ function ftp_site($ftp_stream, string $command): void * 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 resource Returns a SSL-FTP stream on success. + * @return resource Returns an FTP\Connection instance on success. * @throws FtpException * */ -function ftp_ssl_connect(string $host, int $port = 21, int $timeout = 90) +function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90) { error_clear_last(); - $result = \ftp_ssl_connect($host, $port, $timeout); + $result = \ftp_ssl_connect($hostname, $port, $timeout); if ($result === false) { throw FtpException::createFromPhpError(); } @@ -480,15 +531,15 @@ function ftp_ssl_connect(string $host, int $port = 21, int $timeout = 90) /** * Returns the system type identifier of the remote FTP server. * - * @param resource $ftp_stream The link identifier of the FTP connection. + * @param resource $ftp An FTP\Connection instance. * @return string Returns the remote system type. * @throws FtpException * */ -function ftp_systype($ftp_stream): string +function ftp_systype($ftp): string { error_clear_last(); - $result = \ftp_systype($ftp_stream); + $result = \ftp_systype($ftp); if ($result === false) { throw FtpException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/funchand.php b/vendor/thecodingmachine/safe/generated/funchand.php index 64654526e..4b2a7b8ff 100644 --- a/vendor/thecodingmachine/safe/generated/funchand.php +++ b/vendor/thecodingmachine/safe/generated/funchand.php @@ -5,12 +5,14 @@ namespace Safe; use Safe\Exceptions\FunchandException; /** - * Creates an anonymous function from the parameters passed, and - * returns a unique name for it. + * Creates a function dynamically from the parameters passed, and returns a unique name for it. * - * @param string $args The function arguments. + * @param string $args The function arguments, as a single comma-separated string. * @param string $code The function code. * @return string Returns a unique function name as a string. + * Note that the name contains a non-printable character ("\0"), + * so care should be taken when printing the name or incorporating it in any other + * string. * @throws FunchandException * */ @@ -28,18 +30,18 @@ function create_function(string $args, string $code): string /** * * - * @param callable(): void $function The function to register. - * @param mixed $params + * @param callable(): void $callback The function to register. + * @param mixed $args * @throws FunchandException * */ -function register_tick_function(callable $function, ...$params): void +function register_tick_function(callable $callback, ...$args): void { error_clear_last(); - if ($params !== []) { - $result = \register_tick_function($function, ...$params); + if ($args !== []) { + $result = \register_tick_function($callback, ...$args); } else { - $result = \register_tick_function($function); + $result = \register_tick_function($callback); } if ($result === false) { throw FunchandException::createFromPhpError(); diff --git a/vendor/thecodingmachine/safe/generated/functionsList.php b/vendor/thecodingmachine/safe/generated/functionsList.php index a43e7efa6..5a590058e 100644 --- a/vendor/thecodingmachine/safe/generated/functionsList.php +++ b/vendor/thecodingmachine/safe/generated/functionsList.php @@ -3,8 +3,8 @@ return [ 'apache_getenv', 'apache_get_version', + 'apache_lookup_uri', 'apache_request_headers', - 'apache_reset_timeout', 'apache_response_headers', 'apache_setenv', 'apcu_cache_info', @@ -14,14 +14,10 @@ return [ 'apcu_inc', 'apcu_sma_info', 'apc_fetch', - 'array_combine', - 'array_flip', - 'array_replace', - 'array_replace_recursive', 'array_walk_recursive', - 'arsort', - 'asort', + 'assert_options', 'base64_decode', + 'bindtextdomain', 'bzclose', 'bzflush', 'bzread', @@ -37,32 +33,75 @@ return [ 'class_uses', 'cli_set_process_title', 'closelog', + 'com_create_guid', 'com_event_sink', 'com_load_typelib', 'com_print_typeinfo', 'convert_uudecode', - 'convert_uuencode', 'copy', 'create_function', + 'cubrid_bind', + 'cubrid_column_names', + 'cubrid_column_types', + 'cubrid_col_size', + 'cubrid_commit', + 'cubrid_connect', + 'cubrid_connect_with_url', + 'cubrid_current_oid', + 'cubrid_disconnect', + 'cubrid_drop', 'cubrid_free_result', 'cubrid_get_charset', + 'cubrid_get_class_name', 'cubrid_get_client_info', 'cubrid_get_db_parameter', + 'cubrid_get_query_timeout', 'cubrid_get_server_info', 'cubrid_insert_id', + 'cubrid_lob2_bind', + 'cubrid_lob2_close', + 'cubrid_lob2_export', + 'cubrid_lob2_import', 'cubrid_lob2_new', + 'cubrid_lob2_read', + 'cubrid_lob2_seek', + 'cubrid_lob2_seek64', 'cubrid_lob2_size', 'cubrid_lob2_size64', 'cubrid_lob2_tell', 'cubrid_lob2_tell64', + 'cubrid_lob2_write', + 'cubrid_lob_close', + 'cubrid_lob_export', + 'cubrid_lob_get', + 'cubrid_lob_send', + 'cubrid_lob_size', + 'cubrid_lock_read', + 'cubrid_lock_write', + 'cubrid_move_cursor', + 'cubrid_next_result', + 'cubrid_pconnect', + 'cubrid_pconnect_with_url', + 'cubrid_prepare', + 'cubrid_put', + 'cubrid_rollback', + 'cubrid_schema', + 'cubrid_seq_drop', + 'cubrid_seq_insert', + 'cubrid_seq_put', + 'cubrid_set_add', + 'cubrid_set_autocommit', 'cubrid_set_db_parameter', + 'cubrid_set_drop', + 'cubrid_set_query_timeout', + 'curl_copy_handle', 'curl_escape', 'curl_exec', 'curl_getinfo', 'curl_init', - 'curl_multi_errno', 'curl_multi_info_read', 'curl_multi_init', + 'curl_multi_setopt', 'curl_setopt', 'curl_share_errno', 'curl_share_setopt', @@ -102,6 +141,7 @@ return [ 'eio_event_loop', 'eio_fallocate', 'eio_fchmod', + 'eio_fchown', 'eio_fdatasync', 'eio_fstat', 'eio_fstatvfs', @@ -131,16 +171,20 @@ return [ 'eio_utime', 'eio_write', 'error_log', + 'exec', 'fastcgi_finish_request', 'fbird_blob_cancel', 'fclose', + 'fdatasync', 'fflush', + 'fgetcsv', 'file', 'fileatime', 'filectime', 'fileinode', 'filemtime', 'fileowner', + 'fileperms', 'filesize', 'file_get_contents', 'file_put_contents', @@ -153,6 +197,8 @@ return [ 'fputcsv', 'fread', 'fsockopen', + 'fstat', + 'fsync', 'ftp_alloc', 'ftp_append', 'ftp_cdup', @@ -167,10 +213,12 @@ return [ 'ftp_login', 'ftp_mkdir', 'ftp_mlsd', + 'ftp_nb_put', 'ftp_nlist', 'ftp_pasv', 'ftp_put', 'ftp_pwd', + 'ftp_raw', 'ftp_rename', 'ftp_rmdir', 'ftp_site', @@ -190,19 +238,22 @@ return [ 'getopt', 'getprotobyname', 'getprotobynumber', + 'getrusage', + 'getservbyport', 'get_headers', + 'get_include_path', + 'get_meta_tags', 'glob', - 'gmdate', - 'gmp_binomial', - 'gmp_export', - 'gmp_import', + 'gmmktime', 'gmp_random_seed', + 'gmstrftime', 'gnupg_adddecryptkey', 'gnupg_addencryptkey', 'gnupg_addsignkey', 'gnupg_cleardecryptkeys', 'gnupg_clearencryptkeys', 'gnupg_clearsignkeys', + 'gnupg_deletekey', 'gnupg_setarmor', 'gnupg_setsignmode', 'gzclose', @@ -210,18 +261,23 @@ return [ 'gzdecode', 'gzdeflate', 'gzencode', + 'gzfile', 'gzgets', 'gzgetss', 'gzinflate', + 'gzopen', 'gzpassthru', + 'gzread', 'gzrewind', 'gzuncompress', + 'gzwrite', 'hash_hkdf', 'hash_update_file', 'header_register_callback', 'hex2bin', 'highlight_file', 'highlight_string', + 'hrtime', 'ibase_add_user', 'ibase_backup', 'ibase_blob_cancel', @@ -248,6 +304,7 @@ return [ 'iconv', 'iconv_get_encoding', 'iconv_set_encoding', + 'idate', 'image2wbmp', 'imageaffine', 'imageaffinematrixconcat', @@ -255,12 +312,14 @@ return [ 'imagealphablending', 'imageantialias', 'imagearc', + 'imageavif', 'imagebmp', 'imagechar', 'imagecharup', 'imagecolorat', 'imagecolordeallocate', 'imagecolormatch', + 'imagecolorset', 'imageconvolution', 'imagecopy', 'imagecopymerge', @@ -268,6 +327,7 @@ return [ 'imagecopyresampled', 'imagecopyresized', 'imagecreate', + 'imagecreatefromavif', 'imagecreatefrombmp', 'imagecreatefromgd', 'imagecreatefromgd2', @@ -275,6 +335,8 @@ return [ 'imagecreatefromgif', 'imagecreatefromjpeg', 'imagecreatefrompng', + 'imagecreatefromstring', + 'imagecreatefromtga', 'imagecreatefromwbmp', 'imagecreatefromwebp', 'imagecreatefromxbm', @@ -288,11 +350,12 @@ return [ 'imagefill', 'imagefilledarc', 'imagefilledellipse', - 'imagefilledpolygon', 'imagefilledrectangle', 'imagefilltoborder', 'imagefilter', 'imageflip', + 'imageftbbox', + 'imagefttext', 'imagegammacorrect', 'imagegd', 'imagegd2', @@ -303,10 +366,9 @@ return [ 'imagelayereffect', 'imageline', 'imageloadfont', - 'imageopenpolygon', 'imagepng', - 'imagepolygon', 'imagerectangle', + 'imageresolution', 'imagerotate', 'imagesavealpha', 'imagescale', @@ -327,29 +389,49 @@ return [ 'imagewbmp', 'imagewebp', 'imagexbm', + 'image_type_to_extension', + 'imap_8bit', 'imap_append', + 'imap_base64', + 'imap_binary', + 'imap_body', + 'imap_bodystruct', 'imap_check', 'imap_clearflag_full', 'imap_close', 'imap_createmailbox', 'imap_deletemailbox', + 'imap_fetchbody', + 'imap_fetchheader', + 'imap_fetchmime', 'imap_fetchstructure', + 'imap_fetch_overview', 'imap_gc', + 'imap_getacl', + 'imap_getmailboxes', + 'imap_getsubscribed', 'imap_headerinfo', + 'imap_headers', + 'imap_listscan', + 'imap_lsub', 'imap_mail', 'imap_mailboxmsginfo', 'imap_mail_compose', 'imap_mail_copy', 'imap_mail_move', + 'imap_mime_header_decode', 'imap_mutf7_to_utf8', 'imap_num_msg', 'imap_open', + 'imap_qprint', 'imap_renamemailbox', + 'imap_rfc822_write_address', 'imap_savebody', 'imap_setacl', 'imap_setflag_full', 'imap_set_quota', 'imap_sort', + 'imap_status', 'imap_subscribe', 'imap_thread', 'imap_timeout', @@ -361,42 +443,25 @@ return [ 'inflate_get_read_len', 'inflate_get_status', 'inflate_init', - 'ingres_autocommit', - 'ingres_close', - 'ingres_commit', - 'ingres_connect', - 'ingres_execute', - 'ingres_field_name', - 'ingres_field_type', - 'ingres_free_result', - 'ingres_pconnect', - 'ingres_result_seek', - 'ingres_rollback', - 'ingres_set_environment', 'ini_get', 'ini_set', 'inotify_init', 'inotify_rm_watch', 'iptcembed', 'iptcparse', - 'jdtounix', 'jpeg2wbmp', 'json_decode', 'json_encode', - 'json_last_error_msg', - 'krsort', - 'ksort', 'lchgrp', 'lchown', + 'ldap_8859_to_t61', 'ldap_add', - 'ldap_add_ext', 'ldap_bind', - 'ldap_bind_ext', 'ldap_control_paged_result', 'ldap_control_paged_result_response', 'ldap_count_entries', 'ldap_delete', - 'ldap_delete_ext', + 'ldap_dn2ufn', 'ldap_exop', 'ldap_exop_passwd', 'ldap_exop_whoami', @@ -410,27 +475,22 @@ return [ 'ldap_get_option', 'ldap_get_values', 'ldap_get_values_len', - 'ldap_list', 'ldap_modify_batch', 'ldap_mod_add', - 'ldap_mod_add_ext', 'ldap_mod_del', - 'ldap_mod_del_ext', 'ldap_mod_replace', - 'ldap_mod_replace_ext', 'ldap_next_attribute', 'ldap_parse_exop', 'ldap_parse_result', - 'ldap_read', 'ldap_rename', - 'ldap_rename_ext', 'ldap_sasl_bind', - 'ldap_search', 'ldap_set_option', 'ldap_unbind', 'libxml_get_last_error', 'libxml_set_external_entity_loader', 'link', + 'long2ip', + 'lstat', 'lzf_compress', 'lzf_decompress', 'mailparse_msg_extract_part_file', @@ -439,6 +499,7 @@ return [ 'mailparse_msg_parse_file', 'mailparse_stream_encode', 'mb_chr', + 'mb_convert_encoding', 'mb_detect_order', 'mb_encoding_aliases', 'mb_eregi_replace', @@ -448,6 +509,7 @@ return [ 'mb_ereg_search_init', 'mb_ereg_search_regs', 'mb_ereg_search_setpos', + 'mb_get_info', 'mb_http_output', 'mb_internal_encoding', 'mb_ord', @@ -455,42 +517,17 @@ return [ 'mb_regex_encoding', 'mb_send_mail', 'mb_split', - 'mb_str_split', 'md5_file', - 'metaphone', 'mime_content_type', 'mkdir', 'mktime', + 'msg_get_queue', 'msg_queue_exists', 'msg_receive', 'msg_remove_queue', 'msg_send', 'msg_set_queue', - 'msql_affected_rows', - 'msql_close', - 'msql_connect', - 'msql_create_db', - 'msql_data_seek', - 'msql_db_query', - 'msql_drop_db', - 'msql_field_len', - 'msql_field_name', - 'msql_field_seek', - 'msql_field_table', - 'msql_field_type', - 'msql_free_result', - 'msql_pconnect', - 'msql_query', - 'msql_select_db', - 'mysqli_get_cache_stats', - 'mysqli_get_client_stats', - 'mysqlnd_ms_dump_servers', - 'mysqlnd_ms_fabric_select_global', - 'mysqlnd_ms_fabric_select_shard', - 'mysqlnd_ms_get_last_used_connection', - 'mysqlnd_qc_clear_cache', - 'mysqlnd_qc_set_is_select', - 'mysqlnd_qc_set_storage_handler', + 'msg_stat_queue', 'mysql_close', 'mysql_connect', 'mysql_create_db', @@ -522,19 +559,19 @@ return [ 'mysql_tablename', 'mysql_thread_id', 'mysql_unbuffered_query', - 'natcasesort', - 'natsort', + 'net_get_interfaces', + 'ob_clean', 'ob_end_clean', 'ob_end_flush', + 'ob_flush', + 'ob_start', 'oci_bind_array_by_name', 'oci_bind_by_name', 'oci_cancel', - 'oci_close', 'oci_commit', 'oci_connect', 'oci_define_by_name', 'oci_execute', - 'oci_fetch_all', 'oci_field_name', 'oci_field_precision', 'oci_field_scale', @@ -547,10 +584,10 @@ return [ 'oci_new_connect', 'oci_new_cursor', 'oci_new_descriptor', - 'oci_num_fields', 'oci_num_rows', 'oci_parse', 'oci_pconnect', + 'oci_register_taf_callback', 'oci_result', 'oci_rollback', 'oci_server_version', @@ -562,6 +599,7 @@ return [ 'oci_set_edition', 'oci_set_module_name', 'oci_set_prefetch', + 'oci_set_prefetch_lob', 'oci_statement_type', 'oci_unregister_taf_callback', 'odbc_autocommit', @@ -569,6 +607,8 @@ return [ 'odbc_columnprivileges', 'odbc_columns', 'odbc_commit', + 'odbc_connect', + 'odbc_cursor', 'odbc_data_source', 'odbc_exec', 'odbc_execute', @@ -581,8 +621,11 @@ return [ 'odbc_foreignkeys', 'odbc_gettypeinfo', 'odbc_longreadlen', + 'odbc_pconnect', 'odbc_prepare', 'odbc_primarykeys', + 'odbc_procedurecolumns', + 'odbc_procedures', 'odbc_result', 'odbc_result_all', 'odbc_rollback', @@ -596,8 +639,14 @@ return [ 'opendir', 'openlog', 'openssl_cipher_iv_length', + 'openssl_cms_decrypt', + 'openssl_cms_encrypt', + 'openssl_cms_read', + 'openssl_cms_sign', + 'openssl_cms_verify', 'openssl_csr_export', 'openssl_csr_export_to_file', + 'openssl_csr_get_public_key', 'openssl_csr_get_subject', 'openssl_csr_new', 'openssl_csr_sign', @@ -605,6 +654,7 @@ return [ 'openssl_dh_compute_key', 'openssl_digest', 'openssl_encrypt', + 'openssl_get_curve_names', 'openssl_open', 'openssl_pbkdf2', 'openssl_pkcs7_decrypt', @@ -614,6 +664,7 @@ return [ 'openssl_pkcs12_export', 'openssl_pkcs12_export_to_file', 'openssl_pkcs12_read', + 'openssl_pkey_derive', 'openssl_pkey_export', 'openssl_pkey_export_to_file', 'openssl_pkey_get_private', @@ -626,6 +677,11 @@ return [ 'openssl_random_pseudo_bytes', 'openssl_seal', 'openssl_sign', + 'openssl_spki_export', + 'openssl_spki_export_challenge', + 'openssl_spki_new', + 'openssl_spki_verify', + 'openssl_verify', 'openssl_x509_export', 'openssl_x509_export_to_file', 'openssl_x509_fingerprint', @@ -636,123 +692,43 @@ return [ 'parse_ini_file', 'parse_ini_string', 'parse_url', - 'password_hash', - 'pcntl_exec', + 'passthru', 'pcntl_getpriority', 'pcntl_setpriority', + 'pcntl_signal', 'pcntl_signal_dispatch', 'pcntl_sigprocmask', - 'pcntl_strerror', - 'PDF_activate_item', - 'PDF_add_locallink', - 'PDF_add_nameddest', - 'PDF_add_note', - 'PDF_add_pdflink', - 'PDF_add_thumbnail', - 'PDF_add_weblink', - 'PDF_attach_file', - 'PDF_begin_layer', - 'PDF_begin_page', - 'PDF_begin_page_ext', - 'PDF_circle', - 'PDF_clip', - 'PDF_close', - 'PDF_closepath', - 'PDF_closepath_fill_stroke', - 'PDF_closepath_stroke', - 'PDF_close_pdi', - 'PDF_close_pdi_page', - 'PDF_concat', - 'PDF_continue_text', - 'PDF_curveto', - 'PDF_delete', - 'PDF_end_layer', - 'PDF_end_page', - 'PDF_end_page_ext', - 'PDF_end_pattern', - 'PDF_end_template', - 'PDF_fill', - 'PDF_fill_stroke', - 'PDF_fit_image', - 'PDF_fit_pdi_page', - 'PDF_fit_textline', - 'PDF_initgraphics', - 'PDF_lineto', - 'PDF_makespotcolor', - 'PDF_moveto', - 'PDF_open_file', - 'PDF_place_image', - 'PDF_place_pdi_page', - 'PDF_rect', - 'PDF_restore', - 'PDF_rotate', - 'PDF_save', - 'PDF_scale', - 'PDF_setcolor', - 'PDF_setdash', - 'PDF_setdashpattern', - 'PDF_setflat', - 'PDF_setfont', - 'PDF_setgray', - 'PDF_setgray_fill', - 'PDF_setgray_stroke', - 'PDF_setlinejoin', - 'PDF_setlinewidth', - 'PDF_setmatrix', - 'PDF_setmiterlimit', - 'PDF_setrgbcolor', - 'PDF_setrgbcolor_fill', - 'PDF_setrgbcolor_stroke', - 'PDF_set_border_color', - 'PDF_set_border_dash', - 'PDF_set_border_style', - 'PDF_set_info', - 'PDF_set_layer_dependency', - 'PDF_set_parameter', - 'PDF_set_text_pos', - 'PDF_set_value', - 'PDF_show', - 'PDF_show_xy', - 'PDF_skew', - 'PDF_stroke', + 'pcntl_sigtimedwait', + 'pcntl_sigwaitinfo', + 'pfsockopen', 'pg_cancel_query', - 'pg_client_encoding', - 'pg_close', 'pg_connect', 'pg_connection_reset', 'pg_convert', 'pg_copy_from', 'pg_copy_to', - 'pg_dbname', 'pg_delete', 'pg_end_copy', 'pg_execute', - 'pg_field_name', 'pg_field_table', - 'pg_field_type', 'pg_flush', 'pg_free_result', 'pg_host', 'pg_insert', - 'pg_last_error', - 'pg_last_notice', 'pg_last_oid', 'pg_lo_close', 'pg_lo_export', 'pg_lo_import', 'pg_lo_open', 'pg_lo_read', - 'pg_lo_read_all', 'pg_lo_seek', 'pg_lo_truncate', 'pg_lo_unlink', 'pg_lo_write', 'pg_meta_data', - 'pg_options', 'pg_parameter_status', 'pg_pconnect', 'pg_ping', - 'pg_port', 'pg_prepare', 'pg_put_line', 'pg_query', @@ -760,21 +736,21 @@ return [ 'pg_result_error_field', 'pg_result_seek', 'pg_select', - 'pg_send_execute', - 'pg_send_prepare', - 'pg_send_query', - 'pg_send_query_params', 'pg_socket', 'pg_trace', - 'pg_tty', 'pg_update', - 'pg_version', 'phpcredits', 'phpinfo', + 'php_sapi_name', 'png2wbmp', 'posix_access', + 'posix_getgrgid', 'posix_getgrnam', - 'posix_getpgid', + 'posix_getgroups', + 'posix_getlogin', + 'posix_getpwuid', + 'posix_getrlimit', + 'posix_getsid', 'posix_initgroups', 'posix_kill', 'posix_mkfifo', @@ -785,11 +761,13 @@ return [ 'posix_setpgid', 'posix_setrlimit', 'posix_setuid', + 'posix_times', + 'posix_uname', + 'preg_grep', 'preg_match', 'preg_match_all', 'preg_replace', 'preg_split', - 'proc_get_status', 'proc_nice', 'pspell_add_to_personal', 'pspell_add_to_session', @@ -805,6 +783,7 @@ return [ 'pspell_config_save_repl', 'pspell_new', 'pspell_new_config', + 'pspell_new_personal', 'pspell_save_wordlist', 'pspell_store_replacement', 'ps_add_launchlink', @@ -886,14 +865,21 @@ return [ 'register_tick_function', 'rename', 'rewind', - 'rewinddir', 'rmdir', 'rpmaddtag', 'rrd_create', - 'rsort', + 'rrd_first', + 'rrd_graph', + 'rrd_info', + 'rrd_lastupdate', + 'rrd_restore', + 'rrd_tune', + 'rrd_update', + 'rrd_xport', 'sapi_windows_cp_conv', 'sapi_windows_cp_set', 'sapi_windows_generate_ctrl_event', + 'sapi_windows_set_ctrl_handler', 'sapi_windows_vt100_support', 'scandir', 'sem_acquire', @@ -901,19 +887,27 @@ return [ 'sem_release', 'sem_remove', 'session_abort', + 'session_create_id', 'session_decode', 'session_destroy', + 'session_encode', + 'session_id', + 'session_module_name', + 'session_name', 'session_regenerate_id', 'session_reset', + 'session_save_path', 'session_unset', 'session_write_close', 'settype', 'set_include_path', 'set_time_limit', 'sha1_file', + 'shell_exec', 'shmop_delete', 'shmop_read', - 'shmop_write', + 'shm_attach', + 'shm_detach', 'shm_put_var', 'shm_remove', 'shm_remove_var', @@ -925,6 +919,7 @@ return [ 'socket_accept', 'socket_addrinfo_bind', 'socket_addrinfo_connect', + 'socket_addrinfo_lookup', 'socket_bind', 'socket_connect', 'socket_create', @@ -948,14 +943,23 @@ return [ 'socket_wsaprotocol_info_export', 'socket_wsaprotocol_info_import', 'socket_wsaprotocol_info_release', - 'sodium_crypto_pwhash', - 'sodium_crypto_pwhash_str', + 'sodium_crypto_aead_aes256gcm_decrypt', + 'sodium_crypto_aead_chacha20poly1305_decrypt', + 'sodium_crypto_aead_chacha20poly1305_encrypt', + 'sodium_crypto_aead_chacha20poly1305_ietf_decrypt', + 'sodium_crypto_aead_chacha20poly1305_ietf_encrypt', + 'sodium_crypto_aead_xchacha20poly1305_ietf_decrypt', + 'sodium_crypto_aead_xchacha20poly1305_ietf_encrypt', + 'sodium_crypto_auth_verify', + 'sodium_crypto_box_open', + 'sodium_crypto_box_seal_open', + 'sodium_crypto_generichash_update', + 'sodium_crypto_secretbox_open', + 'sodium_crypto_sign_open', + 'sodium_crypto_sign_verify_detached', 'solr_get_version', - 'sort', - 'soundex', 'spl_autoload_register', 'spl_autoload_unregister', - 'sprintf', 'sqlsrv_begin_transaction', 'sqlsrv_cancel', 'sqlsrv_client_info', @@ -981,11 +985,14 @@ return [ 'ssh2_connect', 'ssh2_disconnect', 'ssh2_exec', + 'ssh2_forward_accept', + 'ssh2_forward_listen', 'ssh2_publickey_add', 'ssh2_publickey_init', 'ssh2_publickey_remove', 'ssh2_scp_recv', 'ssh2_scp_send', + 'ssh2_send_eof', 'ssh2_sftp', 'ssh2_sftp_chmod', 'ssh2_sftp_mkdir', @@ -993,6 +1000,7 @@ return [ 'ssh2_sftp_rmdir', 'ssh2_sftp_symlink', 'ssh2_sftp_unlink', + 'ssh2_shell', 'stream_context_set_params', 'stream_copy_to_stream', 'stream_filter_append', @@ -1000,22 +1008,28 @@ return [ 'stream_filter_register', 'stream_filter_remove', 'stream_get_contents', + 'stream_get_line', 'stream_isatty', 'stream_resolve_include_path', 'stream_set_blocking', 'stream_set_timeout', 'stream_socket_accept', 'stream_socket_client', + 'stream_socket_get_name', 'stream_socket_pair', + 'stream_socket_recvfrom', + 'stream_socket_sendto', 'stream_socket_server', 'stream_socket_shutdown', 'stream_supports_lock', 'stream_wrapper_register', 'stream_wrapper_restore', 'stream_wrapper_unregister', + 'strftime', 'strptime', 'strtotime', - 'substr', + 'swoole_async_dns_lookup', + 'swoole_async_readfile', 'swoole_async_write', 'swoole_async_writefile', 'swoole_event_defer', @@ -1030,15 +1044,14 @@ return [ 'time_sleep_until', 'tmpfile', 'touch', - 'uasort', - 'uksort', + 'unixtojd', 'unlink', 'unpack', 'uopz_extend', 'uopz_implement', - 'usort', + 'variant_date_to_timestamp', + 'variant_round', 'virtual', - 'vsprintf', 'xdiff_file_bdiff', 'xdiff_file_bpatch', 'xdiff_file_diff', @@ -1049,9 +1062,17 @@ return [ 'xdiff_string_patch', 'xdiff_string_patch_binary', 'xmlrpc_set_type', - 'xml_parser_create', - 'xml_parser_create_ns', + 'xml_parser_free', + 'xml_set_character_data_handler', + 'xml_set_default_handler', + 'xml_set_element_handler', + 'xml_set_end_namespace_decl_handler', + 'xml_set_external_entity_ref_handler', + 'xml_set_notation_decl_handler', 'xml_set_object', + 'xml_set_processing_instruction_handler', + 'xml_set_start_namespace_decl_handler', + 'xml_set_unparsed_entity_decl_handler', 'yaml_parse', 'yaml_parse_file', 'yaml_parse_url', @@ -1064,6 +1085,10 @@ return [ 'yaz_search', 'yaz_wait', 'zip_entry_close', + 'zip_entry_compressedsize', + 'zip_entry_compressionmethod', + 'zip_entry_filesize', + 'zip_entry_name', 'zip_entry_open', 'zip_entry_read', 'zlib_decode', diff --git a/vendor/thecodingmachine/safe/generated/gettext.php b/vendor/thecodingmachine/safe/generated/gettext.php new file mode 100644 index 000000000..f7816e381 --- /dev/null +++ b/vendor/thecodingmachine/safe/generated/gettext.php @@ -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(); + $result = \bindtextdomain($domain, $directory); + if ($result === false) { + throw GettextException::createFromPhpError(); + } + return $result; +} diff --git a/vendor/thecodingmachine/safe/generated/gmp.php b/vendor/thecodingmachine/safe/generated/gmp.php index dae15975d..b2b88f6e4 100644 --- a/vendor/thecodingmachine/safe/generated/gmp.php +++ b/vendor/thecodingmachine/safe/generated/gmp.php @@ -5,75 +5,13 @@ namespace Safe; use Safe\Exceptions\GmpException; /** - * Calculates the binomial coefficient C(n, k). - * - * @param \GMP|string|int $n Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. - * @param int $k - * @return \GMP Returns the binomial coefficient C(n, k). - * @throws GmpException - * - */ -function gmp_binomial($n, int $k): \GMP -{ - error_clear_last(); - $result = \gmp_binomial($n, $k); - if ($result === false) { - throw GmpException::createFromPhpError(); - } - return $result; -} - - -/** - * Export a GMP number to a binary string - * - * @param \GMP|string|int $gmpnumber The GMP number being exported - * @param int $word_size Default value is 1. The number of bytes in each chunk of binary data. This is mainly used in conjunction with the options parameter. - * @param int $options Default value is GMP_MSW_FIRST | GMP_NATIVE_ENDIAN. - * @return string Returns a string. - * @throws GmpException - * - */ -function gmp_export($gmpnumber, int $word_size = 1, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN): string -{ - error_clear_last(); - $result = \gmp_export($gmpnumber, $word_size, $options); - if ($result === false) { - throw GmpException::createFromPhpError(); - } - return $result; -} - - -/** - * Import a GMP number from a binary string - * - * @param string $data The binary string being imported - * @param int $word_size Default value is 1. The number of bytes in each chunk of binary data. This is mainly used in conjunction with the options parameter. - * @param int $options Default value is GMP_MSW_FIRST | GMP_NATIVE_ENDIAN. - * @return \GMP Returns a GMP number. - * @throws GmpException - * - */ -function gmp_import(string $data, int $word_size = 1, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN): \GMP -{ - error_clear_last(); - $result = \gmp_import($data, $word_size, $options); - if ($result === false) { - throw GmpException::createFromPhpError(); - } - return $result; -} - - -/** * * * @param \GMP|string|int $seed The seed to be set for the gmp_random, * gmp_random_bits, and * gmp_random_range functions. * - * Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. + * A GMP object, an integer or a numeric string. * @throws GmpException * */ diff --git a/vendor/thecodingmachine/safe/generated/gnupg.php b/vendor/thecodingmachine/safe/generated/gnupg.php index b5d85ca3a..0ecb886b7 100644 --- a/vendor/thecodingmachine/safe/generated/gnupg.php +++ b/vendor/thecodingmachine/safe/generated/gnupg.php @@ -122,6 +122,26 @@ function gnupg_clearsignkeys($identifier): void /** + * + * + * @param resource $identifier The gnupg identifier, from a call to + * gnupg_init or gnupg. + * @param string $key The key to delete. + * @param bool $allow_secret It specifies whether to delete secret keys as well. + * @throws GnupgException + * + */ +function gnupg_deletekey($identifier, string $key, bool $allow_secret): void +{ + error_clear_last(); + $result = \gnupg_deletekey($identifier, $key, $allow_secret); + if ($result === false) { + throw GnupgException::createFromPhpError(); + } +} + + +/** * Toggle the armored output. * * @param resource $identifier The gnupg identifier, from a call to diff --git a/vendor/thecodingmachine/safe/generated/hash.php b/vendor/thecodingmachine/safe/generated/hash.php index 2c327c0e3..5acbc2670 100644 --- a/vendor/thecodingmachine/safe/generated/hash.php +++ b/vendor/thecodingmachine/safe/generated/hash.php @@ -16,7 +16,7 @@ use Safe\Exceptions\HashException; * * * Non-cryptographic hash functions are not allowed. - * @param string $ikm Input keying material (raw binary). Cannot be empty. + * @param string $key Input keying material (raw binary). Cannot be empty. * @param int $length Desired output length in bytes. * Cannot be greater than 255 times the chosen hash function size. * @@ -31,10 +31,10 @@ use Safe\Exceptions\HashException; * @throws HashException * */ -function hash_hkdf(string $algo, string $ikm, int $length = 0, string $info = '', string $salt = ''): string +function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "", string $salt = ""): string { error_clear_last(); - $result = \hash_hkdf($algo, $ikm, $length, $info, $salt); + $result = \hash_hkdf($algo, $key, $length, $info, $salt); if ($result === false) { throw HashException::createFromPhpError(); } @@ -45,16 +45,20 @@ function hash_hkdf(string $algo, string $ikm, int $length = 0, string $info = '' /** * * - * @param \HashContext $hcontext Hashing context returned by hash_init. + * @param \HashContext $context Hashing context returned by hash_init. * @param string $filename URL describing location of file to be hashed; Supports fopen wrappers. - * @param \HashContext|null $scontext Stream context as returned by stream_context_create. + * @param \HashContext|null $stream_context Stream context as returned by stream_context_create. * @throws HashException * */ -function hash_update_file(\HashContext $hcontext, string $filename, ?\HashContext $scontext = null): void +function hash_update_file(\HashContext $context, string $filename, ?\HashContext $stream_context = null): void { error_clear_last(); - $result = \hash_update_file($hcontext, $filename, $scontext); + if ($stream_context !== null) { + $result = \hash_update_file($context, $filename, $stream_context); + } else { + $result = \hash_update_file($context, $filename); + } if ($result === false) { throw HashException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/ibase.php b/vendor/thecodingmachine/safe/generated/ibase.php index 49697400d..7a6199129 100644 --- a/vendor/thecodingmachine/safe/generated/ibase.php +++ b/vendor/thecodingmachine/safe/generated/ibase.php @@ -122,7 +122,11 @@ function ibase_blob_cancel($blob_handle): void function ibase_blob_create($link_identifier = null) { error_clear_last(); - $result = \ibase_blob_create($link_identifier); + if ($link_identifier !== null) { + $result = \ibase_blob_create($link_identifier); + } else { + $result = \ibase_blob_create(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } @@ -166,7 +170,11 @@ function ibase_blob_get($blob_handle, int $len): string function ibase_close($connection_id = null): void { error_clear_last(); - $result = \ibase_close($connection_id); + if ($connection_id !== null) { + $result = \ibase_close($connection_id); + } else { + $result = \ibase_close(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } @@ -189,7 +197,11 @@ function ibase_close($connection_id = null): void function ibase_commit_ret($link_or_trans_identifier = null): void { error_clear_last(); - $result = \ibase_commit_ret($link_or_trans_identifier); + if ($link_or_trans_identifier !== null) { + $result = \ibase_commit_ret($link_or_trans_identifier); + } else { + $result = \ibase_commit_ret(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } @@ -210,7 +222,11 @@ function ibase_commit_ret($link_or_trans_identifier = null): void function ibase_commit($link_or_trans_identifier = null): void { error_clear_last(); - $result = \ibase_commit($link_or_trans_identifier); + if ($link_or_trans_identifier !== null) { + $result = \ibase_commit($link_or_trans_identifier); + } else { + $result = \ibase_commit(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } @@ -309,7 +325,11 @@ function ibase_delete_user($service_handle, string $user_name): void function ibase_drop_db($connection = null): void { error_clear_last(); - $result = \ibase_drop_db($connection); + if ($connection !== null) { + $result = \ibase_drop_db($connection); + } else { + $result = \ibase_drop_db(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } @@ -566,7 +586,11 @@ function ibase_restore($service_handle, string $source_file, string $dest_db, in function ibase_rollback_ret($link_or_trans_identifier = null): void { error_clear_last(); - $result = \ibase_rollback_ret($link_or_trans_identifier); + if ($link_or_trans_identifier !== null) { + $result = \ibase_rollback_ret($link_or_trans_identifier); + } else { + $result = \ibase_rollback_ret(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } @@ -587,7 +611,11 @@ function ibase_rollback_ret($link_or_trans_identifier = null): void function ibase_rollback($link_or_trans_identifier = null): void { error_clear_last(); - $result = \ibase_rollback($link_or_trans_identifier); + if ($link_or_trans_identifier !== null) { + $result = \ibase_rollback($link_or_trans_identifier); + } else { + $result = \ibase_rollback(); + } if ($result === false) { throw IbaseException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/iconv.php b/vendor/thecodingmachine/safe/generated/iconv.php index 44cf96ab8..7b28b4965 100644 --- a/vendor/thecodingmachine/safe/generated/iconv.php +++ b/vendor/thecodingmachine/safe/generated/iconv.php @@ -36,7 +36,7 @@ function iconv_get_encoding(string $type = "all") /** * Changes the value of the internal configuration variable specified by - * type to charset. + * type to encoding. * * @param string $type The value of type can be any one of these: * @@ -44,14 +44,14 @@ function iconv_get_encoding(string $type = "all") * output_encoding * internal_encoding * - * @param string $charset The character set. + * @param string $encoding The character set. * @throws IconvException * */ -function iconv_set_encoding(string $type, string $charset): void +function iconv_set_encoding(string $type, string $encoding): void { error_clear_last(); - $result = \iconv_set_encoding($type, $charset); + $result = \iconv_set_encoding($type, $encoding); if ($result === false) { throw IconvException::createFromPhpError(); } @@ -59,18 +59,17 @@ function iconv_set_encoding(string $type, string $charset): void /** - * Performs a character set conversion on the string - * str from in_charset - * to out_charset. + * Converts string from from_encoding + * to to_encoding. * - * @param string $in_charset The input charset. - * @param string $out_charset The output charset. + * @param string $from_encoding The current encoding used to interpret string. + * @param string $to_encoding The desired encoding of the result. * - * If you append the string //TRANSLIT to - * out_charset transliteration is activated. This + * 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 can be approximated through one or several similarly looking - * characters. If you append the string //IGNORE, + * 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. @@ -79,16 +78,16 @@ function iconv_set_encoding(string $type, string $charset): void * 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 out_charset. - * @param string $str The string to be converted. + * the to_encoding. + * @param string $string The string to be converted. * @return string Returns the converted string. * @throws IconvException * */ -function iconv(string $in_charset, string $out_charset, string $str): string +function iconv(string $from_encoding, string $to_encoding, string $string): string { error_clear_last(); - $result = \iconv($in_charset, $out_charset, $str); + $result = \iconv($from_encoding, $to_encoding, $string); if ($result === false) { throw IconvException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/image.php b/vendor/thecodingmachine/safe/generated/image.php index f1dc2183c..639cf16c9 100644 --- a/vendor/thecodingmachine/safe/generated/image.php +++ b/vendor/thecodingmachine/safe/generated/image.php @@ -12,12 +12,12 @@ use Safe\Exceptions\ImageException; * correspondent HTTP content type. * * getimagesize can also return some more information - * in imageinfo parameter. + * in image_info parameter. * * @param string $filename This parameter specifies the file you wish to retrieve information * about. It can reference a local file or (configuration permitting) a * remote file using one of the supported streams. - * @param array $imageinfo This optional parameter allows you to extract some extended + * @param array|null $image_info This optional parameter allows you to extract some extended * information from the image file. Currently, this will return the * different JPG APP markers as an associative array. * Some programs use these APP markers to embed text information in @@ -26,7 +26,7 @@ use Safe\Exceptions\ImageException; * You can use the iptcparse function to parse the * binary APP13 marker into something readable. * - * The imageinfo only supports + * The image_info only supports * JFIF files. * @return array Returns an array with up to 7 elements. Not all image types will include * the channels and bits elements. @@ -66,10 +66,31 @@ use Safe\Exceptions\ImageException; * @throws ImageException * */ -function getimagesize(string $filename, array &$imageinfo = null): array +function getimagesize(string $filename, ?array &$image_info = null): array { error_clear_last(); - $result = \getimagesize($filename, $imageinfo); + $result = \getimagesize($filename, $image_info); + if ($result === false) { + throw ImageException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns the extension for the given IMAGETYPE_XXX + * constant. + * + * @param int $image_type One of the IMAGETYPE_XXX constant. + * @param bool $include_dot Whether to prepend a dot to the extension or not. Default to TRUE. + * @return string A string with the extension corresponding to the given image type. + * @throws ImageException + * + */ +function image_type_to_extension(int $image_type, bool $include_dot = true): string +{ + error_clear_last(); + $result = \image_type_to_extension($image_type, $include_dot); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -110,11 +131,11 @@ function image2wbmp($image, ?string $filename = null, int $foreground = null): v /** * * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param array $affine Array with keys 0 to 5. - * @param array $clip Array with keys "x", "y", "width" and "height". - * @return resource Return affined image resource on success. + * @param array $clip Array with keys "x", "y", "width" and "height"; or NULL. + * @return resource Return affined image object on success. * @throws ImageException * */ @@ -138,19 +159,19 @@ function imageaffine($image, array $affine, array $clip = null) * what is useful if multiple transformations should be applied to the same * image in one go. * - * @param array $m1 An affine transformation matrix (an array with keys + * @param array $matrix1 An affine transformation matrix (an array with keys * 0 to 5 and float values). - * @param array $m2 An affine transformation matrix (an array with keys + * @param array $matrix2 An affine transformation matrix (an array with keys * 0 to 5 and float values). * @return array{0:float,1:float,2:float,3:float,4:float,5:float} An affine transformation matrix (an array with keys * 0 to 5 and float values). * @throws ImageException * */ -function imageaffinematrixconcat(array $m1, array $m2): array +function imageaffinematrixconcat(array $matrix1, array $matrix2): array { error_clear_last(); - $result = \imageaffinematrixconcat($m1, $m2); + $result = \imageaffinematrixconcat($matrix1, $matrix2); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -175,14 +196,10 @@ function imageaffinematrixconcat(array $m1, array $m2): array * @throws ImageException * */ -function imageaffinematrixget(int $type, $options = null): array +function imageaffinematrixget(int $type, $options): array { error_clear_last(); - if ($options !== null) { - $result = \imageaffinematrixget($type, $options); - } else { - $result = \imageaffinematrixget($type); - } + $result = \imageaffinematrixget($type, $options); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -202,17 +219,17 @@ function imageaffinematrixget(int $type, $options = null): array * information, replacing the destination pixel. Blending mode is not available * when drawing on palette images. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param bool $blendmode Whether to enable the blending mode or not. On true color images + * @param bool $enable Whether to enable the blending mode or not. On true color images * the default value is TRUE otherwise the default value is FALSE * @throws ImageException * */ -function imagealphablending($image, bool $blendmode): void +function imagealphablending($image, bool $enable): void { error_clear_last(); - $result = \imagealphablending($image, $blendmode); + $result = \imagealphablending($image, $enable); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -231,16 +248,16 @@ function imagealphablending($image, bool $blendmode): void * other colors. The lack of alpha component support does not allow an alpha * based antialiasing method. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param bool $enabled Whether to enable antialiasing or not. + * @param bool $enable Whether to enable antialiasing or not. * @throws ImageException * */ -function imageantialias($image, bool $enabled): void +function imageantialias($image, bool $enable): void { error_clear_last(); - $result = \imageantialias($image, $enabled); + $result = \imageantialias($image, $enable); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -251,24 +268,57 @@ function imageantialias($image, bool $enabled): void * imagearc draws an arc of circle centered at the given * coordinates. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $cx x-coordinate of the center. - * @param int $cy y-coordinate of the center. + * @param int $center_x x-coordinate of the center. + * @param int $center_y y-coordinate of the center. * @param int $width The arc width. * @param int $height The arc height. - * @param int $start The arc start angle, in degrees. - * @param int $end The arc end angle, in degrees. + * @param int $start_angle The arc start angle, in degrees. + * @param int $end_angle The arc end angle, in degrees. * 0° is located at the three-o'clock position, and the arc is drawn * clockwise. * @param int $color A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imagearc($image, int $cx, int $cy, int $width, int $height, int $start, int $end, int $color): void +function imagearc($image, int $center_x, int $center_y, int $width, int $height, int $start_angle, int $end_angle, int $color): void { error_clear_last(); - $result = \imagearc($image, $cx, $cy, $width, $height, $start, $end, $color); + $result = \imagearc($image, $center_x, $center_y, $width, $height, $start_angle, $end_angle, $color); + if ($result === false) { + throw ImageException::createFromPhpError(); + } +} + + +/** + * Outputs or saves a AVIF Raster image from the given image. + * + * @param \GdImage $image A GdImage object, returned by one of the image creation functions, + * such as imagecreatetruecolor. + * @param $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. + * @param int $quality quality is optional, and ranges from 0 (worst quality, smaller file) + * to 100 (best quality, larger file). + * If -1 is provided, the default value 30 is used. + * @param int $speed speed is optional, and ranges from 0 (slow, smaller file) + * to 10 (fast, larger file). + * If -1 is provided, the default value 6 is used. + * @throws ImageException + * + */ +function imageavif(\GdImage $image, $file = null, int $quality = -1, int $speed = -1): void +{ + error_clear_last(); + if ($speed !== -1) { + $result = \imageavif($image, $file, $quality, $speed); + } elseif ($quality !== -1) { + $result = \imageavif($image, $file, $quality); + } elseif ($file !== null) { + $result = \imageavif($image, $file); + } else { + $result = \imageavif($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -278,9 +328,9 @@ function imagearc($image, int $cx, int $cy, int $width, int $height, int $start, /** * Outputs or saves a BMP version of the given image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * * NULL is invalid if the compressed arguments is * not used. @@ -288,10 +338,16 @@ function imagearc($image, int $cx, int $cy, int $width, int $height, int $start, * @throws ImageException * */ -function imagebmp($image, $to = null, bool $compressed = true): void +function imagebmp($image, $file = null, bool $compressed = true): void { error_clear_last(); - $result = \imagebmp($image, $to, $compressed); + if ($compressed !== true) { + $result = \imagebmp($image, $file, $compressed); + } elseif ($file !== null) { + $result = \imagebmp($image, $file); + } else { + $result = \imagebmp($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -300,27 +356,27 @@ function imagebmp($image, $to = null, bool $compressed = true): void /** * imagechar draws the first character of - * c in the image identified by + * char in the image identified by * image with its upper-left at * x,y (top left is 0, * 0) with the color color. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $font Can be 1, 2, 3, 4, 5 for built-in - * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your - * own font identifiers registered with imageloadfont. + * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or GdFont instance, + * returned by imageloadfont. * @param int $x x-coordinate of the start. * @param int $y y-coordinate of the start. - * @param string $c The character to draw. + * @param string $char The character to draw. * @param int $color A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imagechar($image, int $font, int $x, int $y, string $c, int $color): void +function imagechar($image, int $font, int $x, int $y, string $char, int $color): void { error_clear_last(); - $result = \imagechar($image, $font, $x, $y, $c, $color); + $result = \imagechar($image, $font, $x, $y, $char, $color); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -328,25 +384,25 @@ function imagechar($image, int $font, int $x, int $y, string $c, int $color): vo /** - * Draws the character c vertically at the specified + * Draws the character char vertically at the specified * coordinate on the given image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $font Can be 1, 2, 3, 4, 5 for built-in - * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your - * own font identifiers registered with imageloadfont. + * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or GdFont instance, + * returned by imageloadfont. * @param int $x x-coordinate of the start. * @param int $y y-coordinate of the start. - * @param string $c The character to draw. + * @param string $char The character to draw. * @param int $color A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imagecharup($image, int $font, int $x, int $y, string $c, int $color): void +function imagecharup($image, int $font, int $x, int $y, string $char, int $color): void { error_clear_last(); - $result = \imagecharup($image, $font, $x, $y, $c, $color); + $result = \imagecharup($image, $font, $x, $y, $char, $color); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -362,7 +418,7 @@ function imagecharup($image, int $font, int $x, int $y, string $c, int $color): * integer. Use bitshifting and masking to access the distinct red, green and blue * component values: * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x x-coordinate of the point. * @param int $y y-coordinate of the point. @@ -386,7 +442,7 @@ function imagecolorat($image, int $x, int $y): int * imagecolorallocate or * imagecolorallocatealpha. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $color The color identifier. * @throws ImageException @@ -405,8 +461,8 @@ function imagecolordeallocate($image, int $color): void /** * Makes the colors of the palette version of an image more closely match the true color version. * - * @param resource $image1 A truecolor image resource. - * @param resource $image2 A palette image resource pointing to an image that has the same + * @param resource $image1 A truecolor image object. + * @param resource $image2 A palette image object pointing to an image that has the same * size as image1. * @throws ImageException * @@ -422,21 +478,47 @@ function imagecolormatch($image1, $image2): void /** + * This sets the specified index in the palette to the specified + * color. This is useful for creating flood-fill-like effects in + * palleted images without the overhead of performing the actual + * flood-fill. + * + * @param resource $image A GdImage object, returned by one of the image creation functions, + * such as imagecreatetruecolor. + * @param int $color An index in the palette. + * @param int $red Value of red component. + * @param int $green Value of green component. + * @param int $blue Value of blue component. + * @param int $alpha Value of alpha component. + * @throws ImageException + * + */ +function imagecolorset($image, int $color, int $red, int $green, int $blue, int $alpha = 0): void +{ + error_clear_last(); + $result = \imagecolorset($image, $color, $red, $green, $blue, $alpha); + if ($result === false) { + throw ImageException::createFromPhpError(); + } +} + + +/** * Applies a convolution matrix on the image, using the given coefficient and * offset. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param array $matrix A 3x3 matrix: an array of three arrays of three floats. - * @param float $div The divisor of the result of the convolution, used for normalization. + * @param float $divisor The divisor of the result of the convolution, used for normalization. * @param float $offset Color offset. * @throws ImageException * */ -function imageconvolution($image, array $matrix, float $div, float $offset): void +function imageconvolution($image, array $matrix, float $divisor, float $offset): void { error_clear_last(); - $result = \imageconvolution($image, $matrix, $div, $offset); + $result = \imageconvolution($image, $matrix, $divisor, $offset); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -444,29 +526,29 @@ function imageconvolution($image, array $matrix, float $div, float $offset): voi /** - * Copy a part of src_im onto - * dst_im starting at the x,y coordinates + * Copy a part of src_image onto + * dst_image starting at the x,y coordinates * src_x, src_y with - * a width of src_w and a height of - * src_h. The portion defined will be copied + * a width of src_width and a height of + * src_height. The portion defined will be copied * onto the x,y coordinates, dst_x and * dst_y. * - * @param resource $dst_im Destination image resource. - * @param resource $src_im Source image resource. + * @param resource $dst_image Destination image resource. + * @param resource $src_image Source image resource. * @param int $dst_x x-coordinate of destination point. * @param int $dst_y y-coordinate of destination point. * @param int $src_x x-coordinate of source point. * @param int $src_y y-coordinate of source point. - * @param int $src_w Source width. - * @param int $src_h Source height. + * @param int $src_width Source width. + * @param int $src_height Source height. * @throws ImageException * */ -function imagecopy($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h): void +function imagecopy($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height): void { error_clear_last(); - $result = \imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); + $result = \imagecopy($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -474,22 +556,22 @@ function imagecopy($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $sr /** - * Copy a part of src_im onto - * dst_im starting at the x,y coordinates + * Copy a part of src_image onto + * dst_image starting at the x,y coordinates * src_x, src_y with - * a width of src_w and a height of - * src_h. The portion defined will be copied + * a width of src_width and a height of + * src_height. The portion defined will be copied * onto the x,y coordinates, dst_x and * dst_y. * - * @param resource $dst_im Destination image resource. - * @param resource $src_im Source image resource. + * @param resource $dst_image Destination image resource. + * @param resource $src_image Source image resource. * @param int $dst_x x-coordinate of destination point. * @param int $dst_y y-coordinate of destination point. * @param int $src_x x-coordinate of source point. * @param int $src_y y-coordinate of source point. - * @param int $src_w Source width. - * @param int $src_h Source height. + * @param int $src_width Source width. + * @param int $src_height Source height. * @param int $pct The two images will be merged according to pct * which can range from 0 to 100. When pct = 0, * no action is taken, when 100 this function behaves identically @@ -499,10 +581,10 @@ function imagecopy($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $sr * @throws ImageException * */ -function imagecopymerge($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): void +function imagecopymerge($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height, int $pct): void { error_clear_last(); - $result = \imagecopymerge($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct); + $result = \imagecopymerge($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height, $pct); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -510,11 +592,11 @@ function imagecopymerge($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, in /** - * imagecopymergegray copy a part of src_im onto - * dst_im starting at the x,y coordinates + * imagecopymergegray copy a part of src_image onto + * dst_image starting at the x,y coordinates * src_x, src_y with - * a width of src_w and a height of - * src_h. The portion defined will be copied + * a width of src_width and a height of + * src_height. The portion defined will be copied * onto the x,y coordinates, dst_x and * dst_y. * @@ -522,15 +604,15 @@ function imagecopymerge($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, in * that when merging it preserves the hue of the source by converting * the destination pixels to gray scale before the copy operation. * - * @param resource $dst_im Destination image resource. - * @param resource $src_im Source image resource. + * @param resource $dst_image Destination image resource. + * @param resource $src_image Source image resource. * @param int $dst_x x-coordinate of destination point. * @param int $dst_y y-coordinate of destination point. * @param int $src_x x-coordinate of source point. * @param int $src_y y-coordinate of source point. - * @param int $src_w Source width. - * @param int $src_h Source height. - * @param int $pct The src_im will be changed to grayscale according + * @param int $src_width Source width. + * @param int $src_height Source height. + * @param int $pct The src_image will be changed to grayscale according * to pct where 0 is fully grayscale and 100 is * unchanged. When pct = 100 this function behaves * identically to imagecopy for pallete images, except for @@ -539,10 +621,10 @@ function imagecopymerge($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, in * @throws ImageException * */ -function imagecopymergegray($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): void +function imagecopymergegray($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height, int $pct): void { error_clear_last(); - $result = \imagecopymergegray($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct); + $result = \imagecopymergegray($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height, $pct); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -557,10 +639,10 @@ function imagecopymergegray($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x * * In other words, imagecopyresampled will take a * rectangular area from src_image of width - * src_w and height src_h at + * src_width and height src_height at * position (src_x,src_y) * and place it in a rectangular area of dst_image - * of width dst_w and height dst_h + * of width dst_width and height dst_height * at position (dst_x,dst_y). * * If the source and destination coordinates and width and heights @@ -577,17 +659,17 @@ function imagecopymergegray($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x * @param int $dst_y y-coordinate of destination point. * @param int $src_x x-coordinate of source point. * @param int $src_y y-coordinate of source point. - * @param int $dst_w Destination width. - * @param int $dst_h Destination height. - * @param int $src_w Source width. - * @param int $src_h Source height. + * @param int $dst_width Destination width. + * @param int $dst_height Destination height. + * @param int $src_width Source width. + * @param int $src_height Source height. * @throws ImageException * */ -function imagecopyresampled($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h): void +function imagecopyresampled($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_width, int $dst_height, int $src_width, int $src_height): void { error_clear_last(); - $result = \imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); + $result = \imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_width, $dst_height, $src_width, $src_height); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -602,10 +684,10 @@ function imagecopyresampled($dst_image, $src_image, int $dst_x, int $dst_y, int * * In other words, imagecopyresized will take a * rectangular area from src_image of width - * src_w and height src_h at + * src_width and height src_height at * position (src_x,src_y) * and place it in a rectangular area of dst_image - * of width dst_w and height dst_h + * of width dst_width and height dst_height * at position (dst_x,dst_y). * * If the source and destination coordinates and width and heights @@ -622,17 +704,17 @@ function imagecopyresampled($dst_image, $src_image, int $dst_x, int $dst_y, int * @param int $dst_y y-coordinate of destination point. * @param int $src_x x-coordinate of source point. * @param int $src_y y-coordinate of source point. - * @param int $dst_w Destination width. - * @param int $dst_h Destination height. - * @param int $src_w Source width. - * @param int $src_h Source height. + * @param int $dst_width Destination width. + * @param int $dst_height Destination height. + * @param int $src_width Source width. + * @param int $src_height Source height. * @throws ImageException * */ -function imagecopyresized($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h): void +function imagecopyresized($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_width, int $dst_height, int $src_width, int $src_height): void { error_clear_last(); - $result = \imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); + $result = \imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_width, $dst_height, $src_width, $src_height); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -653,7 +735,7 @@ function imagecopyresized($dst_image, $src_image, int $dst_x, int $dst_y, int $s * * @param int $width The image width. * @param int $height The image height. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -669,11 +751,31 @@ function imagecreate(int $width, int $height) /** + * imagecreatefromavif returns an image object + * representing the image obtained from the given filename. + * + * @param string $filename Path to the AVIF raster image. + * @return Returns an image object on success, FALSE on errors. + * @throws ImageException + * + */ +function imagecreatefromavif(string $filename) +{ + error_clear_last(); + $result = \imagecreatefromavif($filename); + if ($result === false) { + throw ImageException::createFromPhpError(); + } + return $result; +} + + +/** * imagecreatefrombmp returns an image identifier * representing the image obtained from the given filename. * * @param string $filename Path to the BMP image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -692,7 +794,7 @@ function imagecreatefrombmp(string $filename) * Create a new image from GD file or URL. * * @param string $filename Path to the GD file. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -711,7 +813,7 @@ function imagecreatefromgd(string $filename) * Create a new image from GD2 file or URL. * * @param string $filename Path to the GD2 image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -730,18 +832,18 @@ function imagecreatefromgd2(string $filename) * Create a new image from a given part of GD2 file or URL. * * @param string $filename Path to the GD2 image. - * @param int $srcX x-coordinate of source point. - * @param int $srcY y-coordinate of source point. + * @param int $x x-coordinate of source point. + * @param int $y y-coordinate of source point. * @param int $width Source width. * @param int $height Source height. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ -function imagecreatefromgd2part(string $filename, int $srcX, int $srcY, int $width, int $height) +function imagecreatefromgd2part(string $filename, int $x, int $y, int $width, int $height) { error_clear_last(); - $result = \imagecreatefromgd2part($filename, $srcX, $srcY, $width, $height); + $result = \imagecreatefromgd2part($filename, $x, $y, $width, $height); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -754,7 +856,7 @@ function imagecreatefromgd2part(string $filename, int $srcX, int $srcY, int $wid * representing the image obtained from the given filename. * * @param string $filename Path to the GIF image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -774,7 +876,7 @@ function imagecreatefromgif(string $filename) * representing the image obtained from the given filename. * * @param string $filename Path to the JPEG image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -794,7 +896,7 @@ function imagecreatefromjpeg(string $filename) * representing the image obtained from the given filename. * * @param string $filename Path to the PNG image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -810,11 +912,55 @@ function imagecreatefrompng(string $filename) /** + * imagecreatefromstring returns an image identifier + * representing the image obtained from the given data. + * These types will be automatically detected if your build of PHP supports + * them: JPEG, PNG, GIF, BMP, WBMP, GD2, and WEBP. + * + * @param string $data A string containing the image data. + * @return resource An image object will be returned on success. FALSE is returned if + * the image type is unsupported, the data is not in a recognised format, + * or the image is corrupt and cannot be loaded. + * @throws ImageException + * + */ +function imagecreatefromstring(string $data) +{ + error_clear_last(); + $result = \imagecreatefromstring($data); + if ($result === false) { + throw ImageException::createFromPhpError(); + } + return $result; +} + + +/** + * imagecreatefromtga returns an image object + * representing the image obtained from the given filename. + * + * @param string $filename Path to the Truevision TGA image. + * @return Returns an image object on success, FALSE on errors. + * @throws ImageException + * + */ +function imagecreatefromtga(string $filename) +{ + error_clear_last(); + $result = \imagecreatefromtga($filename); + if ($result === false) { + throw ImageException::createFromPhpError(); + } + return $result; +} + + +/** * imagecreatefromwbmp returns an image identifier * representing the image obtained from the given filename. * * @param string $filename Path to the WBMP image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -832,9 +978,10 @@ function imagecreatefromwbmp(string $filename) /** * imagecreatefromwebp returns an image identifier * representing the image obtained from the given filename. + * Note that animated WebP files cannot be read. * * @param string $filename Path to the WebP image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -854,7 +1001,7 @@ function imagecreatefromwebp(string $filename) * representing the image obtained from the given filename. * * @param string $filename Path to the XBM image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -874,7 +1021,7 @@ function imagecreatefromxbm(string $filename) * representing the image obtained from the given filename. * * @param string $filename Path to the XPM image. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -890,12 +1037,12 @@ function imagecreatefromxpm(string $filename) /** - * imagecreatetruecolor returns an image identifier + * imagecreatetruecolor returns an image object * representing a black image of the specified size. * * @param int $width Image width. * @param int $height Image height. - * @return resource Returns an image resource identifier on success, FALSE on errors. + * @return resource Returns an image object on success, FALSE on errors. * @throws ImageException * */ @@ -914,19 +1061,19 @@ function imagecreatetruecolor(int $width, int $height) * Crops an image to the given rectangular area and returns the resulting image. * The given image is not modified. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param array $rect The cropping rectangle as array with keys + * @param array $rectangle The cropping rectangle as array with keys * x, y, width and * height. - * @return resource Return cropped image resource on success. + * @return resource Return cropped image object on success. * @throws ImageException * */ -function imagecrop($image, array $rect) +function imagecrop($image, array $rectangle) { error_clear_last(); - $result = \imagecrop($image, $rect); + $result = \imagecrop($image, $rectangle); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -938,17 +1085,17 @@ function imagecrop($image, array $rect) * Automatically crops an image according to the given * mode. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $mode One of the following constants: * @param float $threshold * @param int $color - * @return resource Returns a cropped image resource on success. + * @return resource Returns a cropped image object on success. * If the complete image was cropped, imagecrop returns FALSE. * @throws ImageException * */ -function imagecropauto($image, int $mode = IMG_CROP_DEFAULT, float $threshold = .5, int $color = -1) +function imagecropauto($image, int $mode = IMG_CROP_DEFAULT, float $threshold = 0.5, int $color = -1) { error_clear_last(); $result = \imagecropauto($image, $mode, $threshold, $color); @@ -964,7 +1111,7 @@ function imagecropauto($image, int $mode = IMG_CROP_DEFAULT, float $threshold = * imagesetstyle and imageline * instead. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x1 Upper left x coordinate. * @param int $y1 Upper left y coordinate 0, 0 is the top left corner of the image. @@ -985,10 +1132,10 @@ function imagedashedline($image, int $x1, int $y1, int $x2, int $y2, int $color) /** - * imagedestroy frees any memory associated + * Prior to PHP 8.0.0, imagedestroy freed any memory associated * with image image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @throws ImageException * @@ -1006,20 +1153,20 @@ function imagedestroy($image): void /** * Draws an ellipse centered at the specified coordinates. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $cx x-coordinate of the center. - * @param int $cy y-coordinate of the center. + * @param int $center_x x-coordinate of the center. + * @param int $center_y y-coordinate of the center. * @param int $width The ellipse width. * @param int $height The ellipse height. * @param int $color The color of the ellipse. A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imageellipse($image, int $cx, int $cy, int $width, int $height, int $color): void +function imageellipse($image, int $center_x, int $center_y, int $width, int $height, int $color): void { error_clear_last(); - $result = \imageellipse($image, $cx, $cy, $width, $height, $color); + $result = \imageellipse($image, $center_x, $center_y, $width, $height, $color); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1031,7 +1178,7 @@ function imageellipse($image, int $cx, int $cy, int $width, int $height, int $co * with the given color in the * image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x x-coordinate of start point. * @param int $y y-coordinate of start point. @@ -1053,14 +1200,14 @@ function imagefill($image, int $x, int $y, int $color): void * Draws a partial arc centered at the specified coordinate in the * given image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $cx x-coordinate of the center. - * @param int $cy y-coordinate of the center. + * @param int $center_x x-coordinate of the center. + * @param int $center_y y-coordinate of the center. * @param int $width The arc width. * @param int $height The arc height. - * @param int $start The arc start angle, in degrees. - * @param int $end The arc end angle, in degrees. + * @param int $start_angle The arc start angle, in degrees. + * @param int $end_angle The arc end angle, in degrees. * 0° is located at the three-o'clock position, and the arc is drawn * clockwise. * @param int $color A color identifier created with imagecolorallocate. @@ -1083,10 +1230,10 @@ function imagefill($image, int $x, int $y, int $color): void * @throws ImageException * */ -function imagefilledarc($image, int $cx, int $cy, int $width, int $height, int $start, int $end, int $color, int $style): void +function imagefilledarc($image, int $center_x, int $center_y, int $width, int $height, int $start_angle, int $end_angle, int $color, int $style): void { error_clear_last(); - $result = \imagefilledarc($image, $cx, $cy, $width, $height, $start, $end, $color, $style); + $result = \imagefilledarc($image, $center_x, $center_y, $width, $height, $start_angle, $end_angle, $color, $style); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1097,43 +1244,20 @@ function imagefilledarc($image, int $cx, int $cy, int $width, int $height, int $ * Draws an ellipse centered at the specified coordinate on the given * image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $cx x-coordinate of the center. - * @param int $cy y-coordinate of the center. + * @param int $center_x x-coordinate of the center. + * @param int $center_y y-coordinate of the center. * @param int $width The ellipse width. * @param int $height The ellipse height. * @param int $color The fill color. A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imagefilledellipse($image, int $cx, int $cy, int $width, int $height, int $color): void +function imagefilledellipse($image, int $center_x, int $center_y, int $width, int $height, int $color): void { error_clear_last(); - $result = \imagefilledellipse($image, $cx, $cy, $width, $height, $color); - if ($result === false) { - throw ImageException::createFromPhpError(); - } -} - - -/** - * imagefilledpolygon creates a filled polygon - * in the given image. - * - * @param resource $image An image resource, returned by one of the image creation functions, - * such as imagecreatetruecolor. - * @param array $points An array containing the x and y - * coordinates of the polygons vertices consecutively. - * @param int $num_points Total number of points (vertices), which must be at least 3. - * @param int $color A color identifier created with imagecolorallocate. - * @throws ImageException - * - */ -function imagefilledpolygon($image, array $points, int $num_points, int $color): void -{ - error_clear_last(); - $result = \imagefilledpolygon($image, $points, $num_points, $color); + $result = \imagefilledellipse($image, $center_x, $center_y, $width, $height, $color); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1145,7 +1269,7 @@ function imagefilledpolygon($image, array $points, int $num_points, int $color): * image starting at point 1 and ending at point 2. * 0, 0 is the top left corner of the image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x1 x-coordinate for point 1. * @param int $y1 y-coordinate for point 1. @@ -1167,24 +1291,24 @@ function imagefilledrectangle($image, int $x1, int $y1, int $x2, int $y2, int $c /** * imagefilltoborder performs a flood fill - * whose border color is defined by border. + * whose border color is defined by border_color. * The starting point for the fill is x, * y (top left is 0, 0) and the region is * filled with color color. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x x-coordinate of start. * @param int $y y-coordinate of start. - * @param int $border The border color. A color identifier created with imagecolorallocate. + * @param int $border_color The border color. A color identifier created with imagecolorallocate. * @param int $color The fill color. A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imagefilltoborder($image, int $x, int $y, int $border, int $color): void +function imagefilltoborder($image, int $x, int $y, int $border_color, int $color): void { error_clear_last(); - $result = \imagefilltoborder($image, $x, $y, $border, $color); + $result = \imagefilltoborder($image, $x, $y, $border_color, $color); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1193,11 +1317,11 @@ function imagefilltoborder($image, int $x, int $y, int $border, int $color): voi /** * imagefilter applies the given filter - * filtertype on the image. + * filter on the image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $filtertype filtertype can be one of the following: + * @param int $filter filter can be one of the following: * * * @@ -1217,14 +1341,14 @@ function imagefilltoborder($image, int $x, int $y, int $border, int $color): voi * * * IMG_FILTER_BRIGHTNESS: Changes the brightness - * of the image. Use arg1 to set the level of + * of the image. Use args to set the level of * brightness. The range for the brightness is -255 to 255. * * * * * IMG_FILTER_CONTRAST: Changes the contrast of - * the image. Use arg1 to set the level of + * the image. Use args to set the level of * contrast. * * @@ -1232,7 +1356,7 @@ function imagefilltoborder($image, int $x, int $y, int $border, int $color): voi * * IMG_FILTER_COLORIZE: Like * IMG_FILTER_GRAYSCALE, except you can specify the - * color. Use arg1, arg2 and + * color. Use args, arg2 and * arg3 in the form of * red, green, * blue and arg4 for the @@ -1270,27 +1394,27 @@ function imagefilltoborder($image, int $x, int $y, int $border, int $color): voi * * * IMG_FILTER_SMOOTH: Makes the image smoother. - * Use arg1 to set the level of smoothness. + * Use args to set the level of smoothness. * * * * * IMG_FILTER_PIXELATE: Applies pixelation effect - * to the image, use arg1 to set the block size + * to the image, use args to set the block size * and arg2 to set the pixelation effect mode. * * * * * IMG_FILTER_SCATTER: Applies scatter effect - * to the image, use arg1 and + * to the image, use args and * arg2 to define the effect strength and * additionally arg3 to only apply the * on select pixel colors. * * * - * @param int $arg1 + * @param int $args * * * IMG_FILTER_BRIGHTNESS: Brightness level. @@ -1324,117 +1448,272 @@ function imagefilltoborder($image, int $x, int $y, int $border, int $color): voi * * * - * @param int $arg2 + * @throws ImageException + * + */ +function imagefilter($image, int $filter, int ...$args): void +{ + error_clear_last(); + if ($args !== []) { + $result = \imagefilter($image, $filter, ...$args); + } else { + $result = \imagefilter($image, $filter); + } + if ($result === false) { + throw ImageException::createFromPhpError(); + } +} + + +/** + * Flips the image image using the given + * mode. + * + * @param resource $image A GdImage object, returned by one of the image creation functions, + * such as imagecreatetruecolor. + * @param int $mode Flip mode, this can be one of the IMG_FLIP_* constants: + * + * * * - * IMG_FILTER_COLORIZE: Value of green component. * + * Constant + * Meaning * * * - * IMG_FILTER_PIXELATE: Whether to use advanced pixelation - * effect or not (defaults to FALSE). * + * IMG_FLIP_HORIZONTAL * + * Flips the image horizontally. * * - * IMG_FILTER_SCATTER: Effect addition level. * + * IMG_FLIP_VERTICAL * + * Flips the image vertically. * - * @param int $arg3 * * - * IMG_FILTER_COLORIZE: Value of blue component. + * IMG_FLIP_BOTH * + * Flips the image both horizontally and vertically. * * * - * IMG_FILTER_SCATTER: Optional array indexed color values - * to apply effect at. * * + * @throws ImageException * - * @param int $arg4 + */ +function imageflip($image, int $mode): void +{ + error_clear_last(); + $result = \imageflip($image, $mode); + if ($result === false) { + throw ImageException::createFromPhpError(); + } +} + + +/** + * This function calculates and returns the bounding box in pixels + * for a FreeType text. * + * @param float $size The font size in points. + * @param float $angle Angle in degrees in which string will be + * measured. + * @param string $font_filename The name of the TrueType font file (can be a URL). Depending on + * which version of the GD library that PHP is using, it may attempt to + * search for files that do not begin with a leading '/' by appending + * '.ttf' to the filename and searching along a library-defined font path. + * @param string $string The string to be measured. + * @param array $options + * Possible array indexes for options * - * IMG_FILTER_COLORIZE: Alpha channel, A value - * between 0 and 127. 0 indicates completely opaque while 127 indicates - * completely transparent. * * + * Key + * Type + * Meaning + * + * + * + * + * linespacing + * float + * Defines drawing linespacing + * + * + * + * + * @return array imageftbbox returns an array with 8 + * elements representing four points making the bounding box of the + * text: + * + * + * + * + * 0 + * lower left corner, X position + * + * + * 1 + * lower left corner, Y position + * + * + * 2 + * lower right corner, X position + * * + * 3 + * lower right corner, Y position + * + * + * 4 + * upper right corner, X position + * + * + * 5 + * upper right corner, Y position + * + * + * 6 + * upper left corner, X position + * + * + * 7 + * upper left corner, Y position + * + * + * + * + * + * The points are relative to the text regardless of the + * angle, so "upper left" means in the top left-hand + * corner seeing the text horizontally. + * + * On failure, FALSE is returned. * @throws ImageException * */ -function imagefilter($image, int $filtertype, int $arg1 = null, int $arg2 = null, int $arg3 = null, int $arg4 = null): void +function imageftbbox(float $size, float $angle, string $font_filename, string $string, array $options = []): array { error_clear_last(); - if ($arg4 !== null) { - $result = \imagefilter($image, $filtertype, $arg1, $arg2, $arg3, $arg4); - } elseif ($arg3 !== null) { - $result = \imagefilter($image, $filtertype, $arg1, $arg2, $arg3); - } elseif ($arg2 !== null) { - $result = \imagefilter($image, $filtertype, $arg1, $arg2); - } elseif ($arg1 !== null) { - $result = \imagefilter($image, $filtertype, $arg1); - } else { - $result = \imagefilter($image, $filtertype); - } + $result = \imageftbbox($size, $angle, $font_filename, $string, $options); if ($result === false) { throw ImageException::createFromPhpError(); } + return $result; } /** - * Flips the image image using the given - * mode. * - * @param resource $image An image resource, returned by one of the image creation functions, + * + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $mode Flip mode, this can be one of the IMG_FLIP_* constants: + * @param float $size The font size to use in points. + * @param float $angle The angle in degrees, with 0 degrees being left-to-right reading text. + * Higher values represent a counter-clockwise rotation. For example, a + * value of 90 would result in bottom-to-top reading text. + * @param int $x The coordinates given by x and + * y will define the basepoint of the first + * character (roughly the lower-left corner of the character). This + * is different from the imagestring, where + * x and y define the + * upper-left corner of the first character. For example, "top left" + * is 0, 0. + * @param int $y The y-ordinate. This sets the position of the fonts baseline, not the + * very bottom of the character. + * @param int $color The index of the desired color for the text, see + * imagecolorexact. + * @param string $font_filename The path to the TrueType font you wish to use. + * + * Depending on which version of the GD library PHP is using, when + * font_filename does not begin with a leading + * / then .ttf will be appended + * to the filename and the library will attempt to search for that + * filename along a library-defined font path. * + * In many cases where a font resides in the same directory as the script using it + * the following trick will alleviate any include problems. * * + * ]]> * + * @param string $text Text to be inserted into image. + * @param array $options + * Possible array indexes for options * - * Constant + * + * + * Key + * Type * Meaning * * * * - * IMG_FLIP_HORIZONTAL + * linespacing + * float + * Defines drawing linespacing * - * Flips the image horizontally. * * * - * IMG_FLIP_VERTICAL + * @return array This function returns an array defining the four points of the box, starting in the lower left and moving counter-clockwise: * - * Flips the image vertically. * * * - * IMG_FLIP_BOTH + * 0 + * lower left x-coordinate * - * Flips the image both horizontally and vertically. * + * 1 + * lower left y-coordinate * * + * 2 + * lower right x-coordinate + * + * + * 3 + * lower right y-coordinate + * + * + * 4 + * upper right x-coordinate + * + * + * 5 + * upper right y-coordinate * * + * 6 + * upper left x-coordinate + * + * + * 7 + * upper left y-coordinate + * + * + * + * + * + * On failure, FALSE is returned. * @throws ImageException * */ -function imageflip($image, int $mode): void +function imagefttext($image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, array $options = []): array { error_clear_last(); - $result = \imageflip($image, $mode); + $result = \imagefttext($image, $size, $angle, $x, $y, $color, $font_filename, $text, $options); if ($result === false) { throw ImageException::createFromPhpError(); } + return $result; } @@ -1442,17 +1721,17 @@ function imageflip($image, int $mode): void * Applies gamma correction to the given gd image * given an input and an output gamma. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param float $inputgamma The input gamma. - * @param float $outputgamma The output gamma. + * @param float $input_gamma The input gamma. + * @param float $output_gamma The output gamma. * @throws ImageException * */ -function imagegammacorrect($image, float $inputgamma, float $outputgamma): void +function imagegammacorrect($image, float $input_gamma, float $output_gamma): void { error_clear_last(); - $result = \imagegammacorrect($image, $inputgamma, $outputgamma); + $result = \imagegammacorrect($image, $input_gamma, $output_gamma); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1460,18 +1739,22 @@ function imagegammacorrect($image, float $inputgamma, float $outputgamma): void /** - * Outputs a GD image to the given to. + * Outputs a GD image to the given file. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * @throws ImageException * */ -function imagegd($image, $to = null): void +function imagegd($image, $file = null): void { error_clear_last(); - $result = \imagegd($image, $to); + if ($file !== null) { + $result = \imagegd($image, $file); + } else { + $result = \imagegd($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1479,22 +1762,30 @@ function imagegd($image, $to = null): void /** - * Outputs a GD2 image to the given to. + * Outputs a GD2 image to the given file. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * @param int $chunk_size Chunk size. - * @param int $type Either IMG_GD2_RAW or + * @param int $mode Either IMG_GD2_RAW or * IMG_GD2_COMPRESSED. Default is * IMG_GD2_RAW. * @throws ImageException * */ -function imagegd2($image, $to = null, int $chunk_size = 128, int $type = IMG_GD2_RAW): void +function imagegd2($image, $file = null, int $chunk_size = 128, int $mode = IMG_GD2_RAW): void { error_clear_last(); - $result = \imagegd2($image, $to, $chunk_size, $type); + if ($mode !== IMG_GD2_RAW) { + $result = \imagegd2($image, $file, $chunk_size, $mode); + } elseif ($chunk_size !== 128) { + $result = \imagegd2($image, $file, $chunk_size); + } elseif ($file !== null) { + $result = \imagegd2($image, $file); + } else { + $result = \imagegd2($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1503,7 +1794,7 @@ function imagegd2($image, $to = null, int $chunk_size = 128, int $type = IMG_GD2 /** * imagegif creates the GIF - * file in to from the image image. The + * file in file from the image image. The * image argument is the return from the * imagecreate or imagecreatefrom* * function. @@ -1513,16 +1804,20 @@ function imagegd2($image, $to = null, int $chunk_size = 128, int $type = IMG_GD2 * imagecolortransparent, in which case the * image format will be GIF89a. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * @throws ImageException * */ -function imagegif($image, $to = null): void +function imagegif($image, $file = null): void { error_clear_last(); - $result = \imagegif($image, $to); + if ($file !== null) { + $result = \imagegif($image, $file); + } else { + $result = \imagegif($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1532,7 +1827,7 @@ function imagegif($image, $to = null): void /** * Grabs a screenshot of the whole screen. * - * @return resource Returns an image resource identifier on success, FALSE on failure. + * @return resource Returns an image object on success, FALSE on failure. * @throws ImageException * */ @@ -1550,16 +1845,16 @@ function imagegrabscreen() /** * Grabs a window or its client area using a windows handle (HWND property in COM instance) * - * @param int $window_handle The HWND window ID. - * @param int $client_area Include the client area of the application window. - * @return resource Returns an image resource identifier on success, FALSE on failure. + * @param int $handle The HWND window ID. + * @param bool $client_area Include the client area of the application window. + * @return \GdImage Returns an image object on success, FALSE on failure. * @throws ImageException * */ -function imagegrabwindow(int $window_handle, int $client_area = 0) +function imagegrabwindow(int $handle, bool $client_area = false): \GdImage { error_clear_last(); - $result = \imagegrabwindow($window_handle, $client_area); + $result = \imagegrabwindow($handle, $client_area); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1571,19 +1866,25 @@ function imagegrabwindow(int $window_handle, int $client_area = 0) * imagejpeg creates a JPEG file from * the given image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * @param int $quality quality is optional, and ranges from 0 (worst * quality, smaller file) to 100 (best quality, biggest file). The * default (-1) uses the default IJG quality value (about 75). * @throws ImageException * */ -function imagejpeg($image, $to = null, int $quality = -1): void +function imagejpeg($image, $file = null, int $quality = -1): void { error_clear_last(); - $result = \imagejpeg($image, $to, $quality); + if ($quality !== -1) { + $result = \imagejpeg($image, $file, $quality); + } elseif ($file !== null) { + $result = \imagejpeg($image, $file); + } else { + $result = \imagejpeg($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1593,7 +1894,7 @@ function imagejpeg($image, $to = null, int $quality = -1): void /** * Set the alpha blending flag to use layering effects. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $effect One of the following constants: * @@ -1658,7 +1959,7 @@ function imagelayereffect($image, int $effect): void /** * Draws a line between the two given points. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x1 x-coordinate for first point. * @param int $y1 y-coordinate for first point. @@ -1682,7 +1983,7 @@ function imageline($image, int $x1, int $y1, int $x2, int $y2, int $color): void * imageloadfont loads a user-defined bitmap and returns * its identifier. * - * @param string $file The font file format is currently binary and architecture + * @param string $filename The font file format is currently binary and architecture * dependent. This means you should generate the font files on the * same type of CPU as the machine you are running PHP on. * @@ -1730,15 +2031,14 @@ function imageline($image, int $x1, int $y1, int $x2, int $y2, int $color): void * * * - * @return int The font identifier which is always bigger than 5 to avoid conflicts with - * built-in fontss. + * @return int Returns an GdFont instance. * @throws ImageException * */ -function imageloadfont(string $file): int +function imageloadfont(string $filename): int { error_clear_last(); - $result = \imageloadfont($file); + $result = \imageloadfont($filename); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1747,57 +2047,12 @@ function imageloadfont(string $file): int /** - * imageopenpolygon draws an open polygon on the given - * image. Contrary to imagepolygon, - * no line is drawn between the last and the first point. - * - * @param resource $image An image resource, returned by one of the image creation functions, - * such as imagecreatetruecolor. - * @param array $points An array containing the polygon's vertices, e.g.: - * - * - * - * - * points[0] - * = x0 - * - * - * points[1] - * = y0 - * - * - * points[2] - * = x1 - * - * - * points[3] - * = y1 - * - * - * - * - * @param int $num_points Total number of points (vertices), which must be at least 3. - * @param int $color A color identifier created with imagecolorallocate. - * @throws ImageException - * - */ -function imageopenpolygon($image, array $points, int $num_points, int $color): void -{ - error_clear_last(); - $result = \imageopenpolygon($image, $points, $num_points, $color); - if ($result === false) { - throw ImageException::createFromPhpError(); - } -} - - -/** * Outputs or saves a PNG image from the given * image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * * NULL is invalid if the quality and * filters arguments are not used. @@ -1813,10 +2068,18 @@ function imageopenpolygon($image, array $points, int $num_points, int $color): v * @throws ImageException * */ -function imagepng($image, $to = null, int $quality = -1, int $filters = -1): void +function imagepng($image, $file = null, int $quality = -1, int $filters = -1): void { error_clear_last(); - $result = \imagepng($image, $to, $quality, $filters); + if ($filters !== -1) { + $result = \imagepng($image, $file, $quality, $filters); + } elseif ($quality !== -1) { + $result = \imagepng($image, $file, $quality); + } elseif ($file !== null) { + $result = \imagepng($image, $file); + } else { + $result = \imagepng($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1824,43 +2087,24 @@ function imagepng($image, $to = null, int $quality = -1, int $filters = -1): voi /** - * imagepolygon creates a polygon in the given - * image. + * imagerectangle creates a rectangle starting at + * the specified coordinates. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param array $points An array containing the polygon's vertices, e.g.: - * - * - * - * - * points[0] - * = x0 - * - * - * points[1] - * = y0 - * - * - * points[2] - * = x1 - * - * - * points[3] - * = y1 - * - * - * - * - * @param int $num_points Total number of points (vertices), which must be at least 3. + * @param int $x1 Upper left x coordinate. + * @param int $y1 Upper left y coordinate + * 0, 0 is the top left corner of the image. + * @param int $x2 Bottom right x coordinate. + * @param int $y2 Bottom right y coordinate. * @param int $color A color identifier created with imagecolorallocate. * @throws ImageException * */ -function imagepolygon($image, array $points, int $num_points, int $color): void +function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color): void { error_clear_last(); - $result = \imagepolygon($image, $points, $num_points, $color); + $result = \imagerectangle($image, $x1, $y1, $x2, $y2, $color); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1868,27 +2112,44 @@ function imagepolygon($image, array $points, int $num_points, int $color): void /** - * imagerectangle creates a rectangle starting at - * the specified coordinates. + * imageresolution allows to set and get the resolution of + * an image in DPI (dots per inch). If the optional parameters are NULL, + * the current resolution is returned as an indexed array. If only + * resolution_x is not NULL, the horizontal and vertical resolution + * are set to this value. If none of the optional parameters are NULL, the horizontal + * and vertical resolution are set to these values, respectively. * - * @param resource $image An image resource, returned by one of the image creation functions, + * The resolution is only used as meta information when images are read from and + * written to formats supporting this kind of information (curently PNG and + * JPEG). It does not affect any drawing operations. The default resolution + * for new images is 96 DPI. + * + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $x1 Upper left x coordinate. - * @param int $y1 Upper left y coordinate - * 0, 0 is the top left corner of the image. - * @param int $x2 Bottom right x coordinate. - * @param int $y2 Bottom right y coordinate. - * @param int $color A color identifier created with imagecolorallocate. + * @param int $resolution_x The horizontal resolution in DPI. + * @param int $resolution_y The vertical resolution in DPI. + * @return mixed When used as getter, + * it returns an indexed array of the horizontal and vertical resolution on + * success. + * When used as setter, it returns + * TRUE on success. * @throws ImageException * */ -function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color): void +function imageresolution($image, int $resolution_x = null, int $resolution_y = null) { error_clear_last(); - $result = \imagerectangle($image, $x1, $y1, $x2, $y2, $color); + if ($resolution_y !== null) { + $result = \imageresolution($image, $resolution_x, $resolution_y); + } elseif ($resolution_x !== null) { + $result = \imageresolution($image, $resolution_x); + } else { + $result = \imageresolution($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } + return $result; } @@ -1899,20 +2160,20 @@ function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color): * The center of rotation is the center of the image, and the rotated * image may have different dimensions than the original image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param float $angle Rotation angle, in degrees. The rotation angle is interpreted as the * number of degrees to rotate the image anticlockwise. - * @param int $bgd_color Specifies the color of the uncovered zone after the rotation - * @param int $dummy This parameter is unused. - * @return resource Returns an image resource for the rotated image. + * @param int $background_color Specifies the color of the uncovered zone after the rotation + * @param bool $ignore_transparent This parameter is unused. + * @return resource Returns an image object for the rotated image. * @throws ImageException * */ -function imagerotate($image, float $angle, int $bgd_color, int $dummy = 0) +function imagerotate($image, float $angle, int $background_color, bool $ignore_transparent = false) { error_clear_last(); - $result = \imagerotate($image, $angle, $bgd_color, $dummy); + $result = \imagerotate($image, $angle, $background_color, $ignore_transparent); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1928,16 +2189,16 @@ function imagerotate($image, float $angle, int $bgd_color, int $dummy = 0) * Alphablending has to be disabled (imagealphablending($im, false)) * to retain the alpha-channel in the first place. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param bool $saveflag Whether to save the alpha channel or not. Defaults to FALSE. + * @param bool $enable Whether to save the alpha channel or not. Defaults to FALSE. * @throws ImageException * */ -function imagesavealpha($image, bool $saveflag): void +function imagesavealpha($image, bool $enable): void { error_clear_last(); - $result = \imagesavealpha($image, $saveflag); + $result = \imagesavealpha($image, $enable); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1948,10 +2209,10 @@ function imagesavealpha($image, bool $saveflag): void * imagescale scales an image using the given * interpolation algorithm. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param int $new_width The width to scale the image to. - * @param int $new_height The height to scale the image to. If omitted or negative, the aspect + * @param int $width The width to scale the image to. + * @param int $height The height to scale the image to. If omitted or negative, the aspect * ratio will be preserved. * @param int $mode One of IMG_NEAREST_NEIGHBOUR, * IMG_BILINEAR_FIXED, @@ -1963,14 +2224,14 @@ function imagesavealpha($image, bool $saveflag): void * IMG_WEIGHTED4 is not yet supported. * * - * @return resource Return the scaled image resource on success. + * @return resource Return the scaled image object on success. * @throws ImageException * */ -function imagescale($image, int $new_width, int $new_height = -1, int $mode = IMG_BILINEAR_FIXED) +function imagescale($image, int $width, int $height = -1, int $mode = IMG_BILINEAR_FIXED) { error_clear_last(); - $result = \imagescale($image, $new_width, $new_height, $mode); + $result = \imagescale($image, $width, $height, $mode); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -1985,9 +2246,9 @@ function imagescale($image, int $new_width, int $new_height = -1, int $mode = IM * colors IMG_COLOR_BRUSHED or * IMG_COLOR_STYLEDBRUSHED. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param resource $brush An image resource. + * @param resource $brush An image object. * @throws ImageException * */ @@ -2005,7 +2266,7 @@ function imagesetbrush($image, $brush): void * imagesetclip sets the current clipping rectangle, i.e. * the area beyond which no pixels will be drawn. * - * @param resource $im An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x1 The x-coordinate of the upper left corner. * @param int $y1 The y-coordinate of the upper left corner. @@ -2014,10 +2275,10 @@ function imagesetbrush($image, $brush): void * @throws ImageException * */ -function imagesetclip($im, int $x1, int $y1, int $x2, int $y2): void +function imagesetclip($image, int $x1, int $y1, int $x2, int $y2): void { error_clear_last(); - $result = \imagesetclip($im, $x1, $y1, $x2, $y2); + $result = \imagesetclip($image, $x1, $y1, $x2, $y2); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -2028,7 +2289,7 @@ function imagesetclip($im, int $x1, int $y1, int $x2, int $y2): void * Sets the interpolation method, setting an interpolation method affects the rendering * of various functions in GD, such as the imagerotate function. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $method The interpolation method, which can be one of the following: * @@ -2155,7 +2416,7 @@ function imagesetinterpolation($image, int $method = IMG_BILINEAR_FIXED): void * imagesetpixel draws a pixel at the specified * coordinate. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $x x-coordinate. * @param int $y y-coordinate. @@ -2180,7 +2441,7 @@ function imagesetpixel($image, int $x, int $y, int $color): void * color IMG_COLOR_STYLED or lines of images with color * IMG_COLOR_STYLEDBRUSHED. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param array $style An array of pixel colors. You can use the * IMG_COLOR_TRANSPARENT constant to add a @@ -2204,7 +2465,7 @@ function imagesetstyle($image, array $style): void * drawn when drawing rectangles, polygons, arcs etc. to * thickness pixels. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $thickness Thickness, in pixels. * @throws ImageException @@ -2231,9 +2492,9 @@ function imagesetthickness($image, int $thickness): void * image with imagecolortransparent, a tile allows certain parts * of the underlying area to shine through can be created. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param resource $tile The image resource to be used as a tile. + * @param resource $tile The image object to be used as a tile. * @throws ImageException * */ @@ -2250,11 +2511,11 @@ function imagesettile($image, $tile): void /** * Draws a string at the given coordinates. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $font Can be 1, 2, 3, 4, 5 for built-in - * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your - * own font identifiers registered with imageloadfont. + * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or GdFont instance, + * returned by imageloadfont. * @param int $x x-coordinate of the upper left corner. * @param int $y y-coordinate of the upper left corner. * @param string $string The string to be written. @@ -2276,11 +2537,11 @@ function imagestring($image, int $font, int $x, int $y, string $string, int $col * Draws a string vertically at the given * coordinates. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param int $font Can be 1, 2, 3, 4, 5 for built-in - * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your - * own font identifiers registered with imageloadfont. + * fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or GdFont instance, + * returned by imageloadfont. * @param int $x x-coordinate of the bottom left corner. * @param int $y y-coordinate of the bottom left corner. * @param string $string The string to be written. @@ -2299,9 +2560,9 @@ function imagestringup($image, int $font, int $x, int $y, string $string, int $c /** - * Returns the width of the given image resource. + * Returns the width of the given image object. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @return int Return the width of the images. * @throws ImageException @@ -2319,9 +2580,9 @@ function imagesx($image): int /** - * Returns the height of the given image resource. + * Returns the height of the given image object. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @return int Return the height of the images. * @throws ImageException @@ -2348,19 +2609,19 @@ function imagesy($image): int * usually best to simply produce a truecolor output image instead, which * guarantees the highest output quality. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param bool $dither Indicates if the image should be dithered - if it is TRUE then * dithering will be used which will result in a more speckled image but * with better color approximation. - * @param int $ncolors Sets the maximum number of colors that should be retained in the palette. + * @param int $num_colors Sets the maximum number of colors that should be retained in the palette. * @throws ImageException * */ -function imagetruecolortopalette($image, bool $dither, int $ncolors): void +function imagetruecolortopalette($image, bool $dither, int $num_colors): void { error_clear_last(); - $result = \imagetruecolortopalette($image, $dither, $ncolors); + $result = \imagetruecolortopalette($image, $dither, $num_colors); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -2372,8 +2633,8 @@ function imagetruecolortopalette($image, bool $dither, int $ncolors): void * for a TrueType text. * * @param float $size The font size in points. - * @param float $angle Angle in degrees in which text will be measured. - * @param string $fontfile The path to the TrueType font you wish to use. + * @param float $angle Angle in degrees in which string will be measured. + * @param string $font_filename The path to the TrueType font you wish to use. * * Depending on which version of the GD library PHP is using, when * fontfile does not begin with a leading @@ -2396,7 +2657,8 @@ function imagetruecolortopalette($image, bool $dither, int $ncolors): void * * Note that open_basedir does * not apply to fontfile. - * @param string $text The string to be measured. + * @param string $string The string to be measured. + * @param array $options * @return array imagettfbbox returns an array with 8 * elements representing four points making the bounding box of the * text on success and FALSE on error. @@ -2451,10 +2713,10 @@ function imagetruecolortopalette($image, bool $dither, int $ncolors): void * @throws ImageException * */ -function imagettfbbox(float $size, float $angle, string $fontfile, string $text): array +function imagettfbbox(float $size, float $angle, string $font_filename, string $string, array $options = []): array { error_clear_last(); - $result = \imagettfbbox($size, $angle, $fontfile, $text); + $result = \imagettfbbox($size, $angle, $font_filename, $string, $options); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -2466,7 +2728,7 @@ function imagettfbbox(float $size, float $angle, string $fontfile, string $text) * Writes the given text into the image using TrueType * fonts. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param float $size The font size in points. * @param float $angle The angle in degrees, with 0 degrees being left-to-right reading text. @@ -2483,7 +2745,7 @@ function imagettfbbox(float $size, float $angle, string $fontfile, string $text) * very bottom of the character. * @param int $color The color index. Using the negative of a color index has the effect of * turning off antialiasing. See imagecolorallocate. - * @param string $fontfile The path to the TrueType font you wish to use. + * @param string $font_filename The path to the TrueType font you wish to use. * * Depending on which version of the GD library PHP is using, when * fontfile does not begin with a leading @@ -2519,6 +2781,7 @@ function imagettfbbox(float $size, float $angle, string $fontfile, string $text) * * If a character is used in the string which is not supported by the * font, a hollow rectangle will replace the character. + * @param array $options * @return array Returns an array with 8 elements representing four points making the * bounding box of the text. The order of the points is lower left, lower * right, upper right, upper left. The points are relative to the text @@ -2527,10 +2790,10 @@ function imagettfbbox(float $size, float $angle, string $fontfile, string $text) * @throws ImageException * */ -function imagettftext($image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text): array +function imagettftext($image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, array $options = []): array { error_clear_last(); - $result = \imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text); + $result = \imagettftext($image, $size, $angle, $x, $y, $color, $font_filename, $text, $options); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -2542,22 +2805,24 @@ function imagettftext($image, float $size, float $angle, int $x, int $y, int $co * imagewbmp outputs or save a WBMP * version of the given image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. - * @param int $foreground You can set the foreground color with this parameter by setting an + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. + * @param int $foreground_color You can set the foreground color with this parameter by setting an * identifier obtained from imagecolorallocate. * The default foreground color is black. * @throws ImageException * */ -function imagewbmp($image, $to = null, int $foreground = null): void +function imagewbmp($image, $file = null, int $foreground_color = null): void { error_clear_last(); - if ($foreground !== null) { - $result = \imagewbmp($image, $to, $foreground); + if ($foreground_color !== null) { + $result = \imagewbmp($image, $file, $foreground_color); + } elseif ($file !== null) { + $result = \imagewbmp($image, $file); } else { - $result = \imagewbmp($image, $to); + $result = \imagewbmp($image); } if ($result === false) { throw ImageException::createFromPhpError(); @@ -2568,18 +2833,24 @@ function imagewbmp($image, $to = null, int $foreground = null): void /** * Outputs or saves a WebP version of the given image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. + * @param string|resource|null $file The path or an open stream resource (which is automatically closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be output directly. * @param int $quality quality ranges from 0 (worst * quality, smaller file) to 100 (best quality, biggest file). * @throws ImageException * */ -function imagewebp($image, $to = null, int $quality = 80): void +function imagewebp($image, $file = null, int $quality = -1): void { error_clear_last(); - $result = \imagewebp($image, $to, $quality); + if ($quality !== -1) { + $result = \imagewebp($image, $file, $quality); + } elseif ($file !== null) { + $result = \imagewebp($image, $file); + } else { + $result = \imagewebp($image); + } if ($result === false) { throw ImageException::createFromPhpError(); } @@ -2590,27 +2861,27 @@ function imagewebp($image, $to = null, int $quality = 80): void * Outputs or save an XBM version of the given * image. * - * @param resource $image An image resource, returned by one of the image creation functions, + * @param resource $image A GdImage object, returned by one of the image creation functions, * such as imagecreatetruecolor. - * @param string|null $filename The path to save the file to, given as string. If NULL, the raw image stream will be output directly. + * @param string|resource|null $filename The path to save the file to, given as string. If NULL, the raw image stream will be output directly. * * The filename (without the .xbm extension) is also * used for the C identifiers of the XBM, whereby non * alphanumeric characters of the current locale are substituted by * underscores. If filename is set to NULL, * image is used to build the C identifiers. - * @param int $foreground You can set the foreground color with this parameter by setting an + * @param int $foreground_color You can set the foreground color with this parameter by setting an * identifier obtained from imagecolorallocate. * The default foreground color is black. All other colors are treated as * background. * @throws ImageException * */ -function imagexbm($image, ?string $filename, int $foreground = null): void +function imagexbm($image, $filename, int $foreground_color = null): void { error_clear_last(); - if ($foreground !== null) { - $result = \imagexbm($image, $filename, $foreground); + if ($foreground_color !== null) { + $result = \imagexbm($image, $filename, $foreground_color); } else { $result = \imagexbm($image, $filename); } @@ -2623,18 +2894,18 @@ function imagexbm($image, ?string $filename, int $foreground = null): void /** * Embeds binary IPTC data into a JPEG image. * - * @param string $iptcdata The data to be written. - * @param string $jpeg_file_name Path to the JPEG image. + * @param string $iptc_data The data to be written. + * @param string $filename Path to the JPEG image. * @param int $spool Spool flag. If the spool flag is less than 2 then the JPEG will be * returned as a string. Otherwise the JPEG will be printed to STDOUT. * @return string|bool If spool is less than 2, the JPEG will be returned. Otherwise returns TRUE on success. * @throws ImageException * */ -function iptcembed(string $iptcdata, string $jpeg_file_name, int $spool = 0) +function iptcembed(string $iptc_data, string $filename, int $spool = 0) { error_clear_last(); - $result = \iptcembed($iptcdata, $jpeg_file_name, $spool); + $result = \iptcembed($iptc_data, $filename, $spool); if ($result === false) { throw ImageException::createFromPhpError(); } @@ -2645,16 +2916,16 @@ function iptcembed(string $iptcdata, string $jpeg_file_name, int $spool = 0) /** * Parses an IPTC block into its single tags. * - * @param string $iptcblock A binary IPTC block. + * @param string $iptc_block A binary IPTC block. * @return array Returns an array using the tagmarker as an index and the value as the * value. It returns FALSE on error or if no IPTC data was found. * @throws ImageException * */ -function iptcparse(string $iptcblock): array +function iptcparse(string $iptc_block): array { error_clear_last(); - $result = \iptcparse($iptcblock); + $result = \iptcparse($iptc_block); if ($result === false) { throw ImageException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/imap.php b/vendor/thecodingmachine/safe/generated/imap.php index acd8672c6..917a8e201 100644 --- a/vendor/thecodingmachine/safe/generated/imap.php +++ b/vendor/thecodingmachine/safe/generated/imap.php @@ -5,11 +5,30 @@ namespace Safe; use Safe\Exceptions\ImapException; /** - * Appends a string message to the specified mailbox. + * Convert an 8bit string to a quoted-printable string (according to + * RFC2045, section 6.7). * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param string $mailbox The mailbox name, see imap_open for more + * @param string $string The 8bit string to convert + * @return string Returns a quoted-printable string. + * @throws ImapException + * + */ +function imap_8bit(string $string): string +{ + error_clear_last(); + $result = \imap_8bit($string); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Appends a string message to the specified folder. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $folder The mailbox name, see imap_open for more * information * @param string $message The message to be append, as a string * @@ -17,26 +36,141 @@ use Safe\Exceptions\ImapException; * your end-of-line terminator instead of "\n" or the operation will * fail * @param string $options If provided, the options will also be written - * to the mailbox + * to the folder * @param string $internal_date If this parameter is set, it will set the INTERNALDATE on the appended message. The parameter should be a date string that conforms to the rfc2060 specifications for a date_time value. * @throws ImapException * */ -function imap_append($imap_stream, string $mailbox, string $message, string $options = null, string $internal_date = null): void +function imap_append($imap, string $folder, string $message, string $options = null, string $internal_date = null): void +{ + error_clear_last(); + if ($internal_date !== null) { + $result = \imap_append($imap, $folder, $message, $options, $internal_date); + } elseif ($options !== null) { + $result = \imap_append($imap, $folder, $message, $options); + } else { + $result = \imap_append($imap, $folder, $message); + } + if ($result === false) { + throw ImapException::createFromPhpError(); + } +} + + +/** + * Decodes the given BASE-64 encoded string. + * + * @param string $string The encoded text + * @return string Returns the decoded message as a string. + * @throws ImapException + * + */ +function imap_base64(string $string): string +{ + error_clear_last(); + $result = \imap_base64($string); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Convert an 8bit string to a base64 string according to RFC2045, Section 6.8. + * + * @param string $string The 8bit string + * @return string Returns a base64 encoded string. + * @throws ImapException + * + */ +function imap_binary(string $string): string { error_clear_last(); - $result = \imap_append($imap_stream, $mailbox, $message, $options, $internal_date); + $result = \imap_binary($string); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; +} + + +/** + * imap_body returns the body of the message, + * numbered message_num in the current + * mailbox. + * + * imap_body will only return a verbatim copy of the + * message body. To extract single parts of a multipart MIME-encoded + * message you have to use imap_fetchstructure to + * analyze its structure and imap_fetchbody to + * extract a copy of a single body component. + * + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param int $flags The optional flags are a bit mask + * with one or more of the following: + * + * + * + * FT_UID - The message_num is a UID + * + * + * + * + * FT_PEEK - Do not set the \Seen flag if not already set + * + * + * + * + * FT_INTERNAL - The return string is in internal format, will + * not canonicalize to CRLF. + * + * + * + * @return string Returns the body of the specified message, as a string. + * @throws ImapException + * + */ +function imap_body($imap, int $message_num, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_body($imap, $message_num, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Read the structure of a specified body section of a specific message. + * + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param string $section The body section to read + * @return \stdClass Returns the information in an object. + * For a detailed description + * of the object structure and properties see + * imap_fetchstructure. + * @throws ImapException + * + */ +function imap_bodystruct($imap, int $message_num, string $section): \stdClass +{ + error_clear_last(); + $result = \imap_bodystruct($imap, $message_num, $section); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; } /** * Checks information about the current mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @return \stdClass Returns the information in an object with following properties: * * @@ -71,10 +205,10 @@ function imap_append($imap_stream, string $mailbox, string $message, string $opt * @throws ImapException * */ -function imap_check($imap_stream): \stdClass +function imap_check($imap): \stdClass { error_clear_last(); - $result = \imap_check($imap_stream); + $result = \imap_check($imap); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -87,8 +221,7 @@ function imap_check($imap_stream): \stdClass * flag to the flags set for the * messages in the specified sequence. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $sequence A sequence of message numbers. You can enumerate desired messages * with the X,Y syntax, or retrieve all messages * within an interval with the X:Y syntax @@ -107,10 +240,10 @@ function imap_check($imap_stream): \stdClass * @throws ImapException * */ -function imap_clearflag_full($imap_stream, string $sequence, string $flag, int $options = 0): void +function imap_clearflag_full($imap, string $sequence, string $flag, int $options = 0): void { error_clear_last(); - $result = \imap_clearflag_full($imap_stream, $sequence, $flag, $options); + $result = \imap_clearflag_full($imap, $sequence, $flag, $options); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -120,19 +253,18 @@ function imap_clearflag_full($imap_stream, string $sequence, string $flag, int $ /** * Closes the imap stream. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param int $flag If set to CL_EXPUNGE, the function will silently + * @param resource $imap An IMAP\Connection instance. + * @param int $flags If set to CL_EXPUNGE, the function will silently * expunge the mailbox before closing, removing all messages marked for * deletion. You can achieve the same thing by using * imap_expunge * @throws ImapException * */ -function imap_close($imap_stream, int $flag = 0): void +function imap_close($imap, int $flags = 0): void { error_clear_last(); - $result = \imap_close($imap_stream, $flag); + $result = \imap_close($imap, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -142,18 +274,17 @@ function imap_close($imap_stream, int $flag = 0): void /** * Creates a new mailbox specified by mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $mailbox The mailbox name, see imap_open for more * information. Names containing international characters should be * encoded by imap_utf7_encode * @throws ImapException * */ -function imap_createmailbox($imap_stream, string $mailbox): void +function imap_createmailbox($imap, string $mailbox): void { error_clear_last(); - $result = \imap_createmailbox($imap_stream, $mailbox); + $result = \imap_createmailbox($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -163,17 +294,16 @@ function imap_createmailbox($imap_stream, string $mailbox): void /** * Deletes the specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $mailbox The mailbox name, see imap_open for more * information * @throws ImapException * */ -function imap_deletemailbox($imap_stream, string $mailbox): void +function imap_deletemailbox($imap, string $mailbox): void { error_clear_last(); - $result = \imap_deletemailbox($imap_stream, $mailbox); + $result = \imap_deletemailbox($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -181,14 +311,262 @@ function imap_deletemailbox($imap_stream, string $mailbox): void /** + * This function fetches mail headers for the given + * sequence and returns an overview of their + * contents. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $sequence A message sequence description. You can enumerate desired messages + * with the X,Y syntax, or retrieve all messages + * within an interval with the X:Y syntax + * @param int $flags sequence will contain a sequence of message + * indices or UIDs, if this parameter is set to + * FT_UID. + * @return array Returns an array of objects describing one message header each. + * The object will only define a property if it exists. The possible + * properties are: + * + * + * + * subject - the messages subject + * + * + * + * + * from - who sent it + * + * + * + * + * to - recipient + * + * + * + * + * date - when was it sent + * + * + * + * + * message_id - Message-ID + * + * + * + * + * references - is a reference to this message id + * + * + * + * + * in_reply_to - is a reply to this message id + * + * + * + * + * size - size in bytes + * + * + * + * + * uid - UID the message has in the mailbox + * + * + * + * + * msgno - message sequence number in the mailbox + * + * + * + * + * recent - this message is flagged as recent + * + * + * + * + * flagged - this message is flagged + * + * + * + * + * answered - this message is flagged as answered + * + * + * + * + * deleted - this message is flagged for deletion + * + * + * + * + * seen - this message is flagged as already read + * + * + * + * + * draft - this message is flagged as being a draft + * + * + * + * + * udate - the UNIX timestamp of the arrival date + * + * + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_fetch_overview($imap, string $sequence, int $flags = 0): array +{ + error_clear_last(); + $result = \imap_fetch_overview($imap, $sequence, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Fetch of a particular section of the body of the specified messages. + * Body parts are not decoded by this function. + * + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param string $section The part number. It is a string of integers delimited by period which + * index into a body part list as per the IMAP4 specification + * @param int $flags A bitmask with one or more of the following: + * + * + * + * FT_UID - The message_num is a UID + * + * + * + * + * FT_PEEK - Do not set the \Seen flag if + * not already set + * + * + * + * + * FT_INTERNAL - The return string is in + * internal format, will not canonicalize to CRLF. + * + * + * + * @return string Returns a particular section of the body of the specified messages as a + * text string. + * @throws ImapException + * + */ +function imap_fetchbody($imap, int $message_num, string $section, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_fetchbody($imap, $message_num, $section, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * This function causes a fetch of the complete, unfiltered RFC2822 format header of the specified + * message. + * + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param int $flags The possible flags are: + * + * + * + * FT_UID - The message_num + * argument is a UID + * + * + * + * + * FT_INTERNAL - The return string + * is in "internal" format, without any attempt to + * canonicalize to CRLF newlines + * + * + * + * + * FT_PREFETCHTEXT - The RFC822.TEXT + * should be pre-fetched at the same time. This avoids an + * extra RTT on an IMAP connection if a full message text is + * desired (e.g. in a "save to local file" operation) + * + * + * + * @return string Returns the header of the specified message as a text string. + * @throws ImapException + * + */ +function imap_fetchheader($imap, int $message_num, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_fetchheader($imap, $message_num, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Fetch the MIME headers of a particular section of the body of the specified messages. + * + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param string $section The part number. It is a string of integers delimited by period which + * index into a body part list as per the IMAP4 specification + * @param int $flags A bitmask with one or more of the following: + * + * + * + * FT_UID - The message_num is a UID + * + * + * + * + * FT_PEEK - Do not set the \Seen flag if + * not already set + * + * + * + * + * FT_INTERNAL - The return string is in + * internal format, will not canonicalize to CRLF. + * + * + * + * @return string Returns the MIME headers of a particular section of the body of the specified messages as a + * text string. + * @throws ImapException + * + */ +function imap_fetchmime($imap, int $message_num, string $section, int $flags = 0): string +{ + error_clear_last(); + $result = \imap_fetchmime($imap, $message_num, $section, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** * Fetches all the structured information for a given message. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param int $msg_number The message number - * @param int $options This optional parameter only has a single option, + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param int $flags This optional parameter only has a single option, * FT_UID, which tells the function to treat the - * msg_number argument as a + * message_num argument as a * UID. * @return \stdClass Returns an object with properties listed in the table below. * @@ -317,10 +695,10 @@ function imap_deletemailbox($imap_stream, string $mailbox): void * @throws ImapException * */ -function imap_fetchstructure($imap_stream, int $msg_number, int $options = 0): \stdClass +function imap_fetchstructure($imap, int $message_num, int $flags = 0): \stdClass { error_clear_last(); - $result = \imap_fetchstructure($imap_stream, $msg_number, $options); + $result = \imap_fetchstructure($imap, $message_num, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -331,9 +709,8 @@ function imap_fetchstructure($imap_stream, int $msg_number, int $options = 0): \ /** * Purges the cache of entries of a specific type. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param int $caches Specifies the cache to purge. It may one or a combination + * @param resource $imap An IMAP\Connection instance. + * @param int $flags Specifies the cache to purge. It may one or a combination * of the following constants: * IMAP_GC_ELT (message cache elements), * IMAP_GC_ENV (envelope and bodies), @@ -341,27 +718,218 @@ function imap_fetchstructure($imap_stream, int $msg_number, int $options = 0): \ * @throws ImapException * */ -function imap_gc($imap_stream, int $caches): void +function imap_gc($imap, int $flags): void +{ + error_clear_last(); + $result = \imap_gc($imap, $flags); + if ($result === false) { + throw ImapException::createFromPhpError(); + } +} + + +/** + * Gets the ACL for a given mailbox. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $mailbox The mailbox name, see imap_open for more + * information + * @return array Returns an associative array of "folder" => "acl" pairs. + * @throws ImapException + * + */ +function imap_getacl($imap, string $mailbox): array +{ + error_clear_last(); + $result = \imap_getacl($imap, $mailbox); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets information on the mailboxes. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @return array Returns an array of objects containing mailbox information. Each + * object has the attributes name, specifying + * the full name of the mailbox; delimiter, + * which is the hierarchy delimiter for the part of the hierarchy + * this mailbox is in; and + * attributes. Attributes + * is a bitmask that can be tested against: + * + * + * + * LATT_NOINFERIORS - This mailbox not contains, and may not contain any + * "children" (there are no mailboxes below this one). Calling + * imap_createmailbox will not work on this mailbox. + * + * + * + * + * LATT_NOSELECT - This is only a container, + * not a mailbox - you cannot open it. + * + * + * + * + * LATT_MARKED - This mailbox is marked. This means that it may + * contain new messages since the last time it was checked. Not provided by all IMAP + * servers. + * + * + * + * + * LATT_UNMARKED - This mailbox is not marked, does not contain new + * messages. If either MARKED or UNMARKED is + * provided, you can assume the IMAP server supports this feature for this mailbox. + * + * + * + * + * LATT_REFERRAL - This container has a referral to a remote mailbox. + * + * + * + * + * LATT_HASCHILDREN - This mailbox has selectable inferiors. + * + * + * + * + * LATT_HASNOCHILDREN - This mailbox has no selectable inferiors. + * + * + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_getmailboxes($imap, string $reference, string $pattern): array { error_clear_last(); - $result = \imap_gc($imap_stream, $caches); + $result = \imap_getmailboxes($imap, $reference, $pattern); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; +} + + +/** + * Gets information about the subscribed mailboxes. + * + * Identical to imap_getmailboxes, except that it only + * returns mailboxes that the user is subscribed to. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @return array Returns an array of objects containing mailbox information. Each + * object has the attributes name, specifying + * the full name of the mailbox; delimiter, + * which is the hierarchy delimiter for the part of the hierarchy + * this mailbox is in; and + * attributes. Attributes + * is a bitmask that can be tested against: + * + * + * + * LATT_NOINFERIORS - This mailbox has no + * "children" (there are no mailboxes below this one). + * + * + * + * + * LATT_NOSELECT - This is only a container, + * not a mailbox - you cannot open it. + * + * + * + * + * LATT_MARKED - This mailbox is marked. + * Only used by UW-IMAPD. + * + * + * + * + * LATT_UNMARKED - This mailbox is not marked. + * Only used by UW-IMAPD. + * + * + * + * + * LATT_REFERRAL - This container has a referral to a remote mailbox. + * + * + * + * + * LATT_HASCHILDREN - This mailbox has selectable inferiors. + * + * + * + * + * LATT_HASNOCHILDREN - This mailbox has no selectable inferiors. + * + * + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_getsubscribed($imap, string $reference, string $pattern): array +{ + error_clear_last(); + $result = \imap_getsubscribed($imap, $reference, $pattern); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; } /** * Gets information about the given message number by reading its headers. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param int $msg_number The message number - * @param int $fromlength Number of characters for the fetchfrom property. + * @param resource $imap An IMAP\Connection instance. + * @param int $message_num The message number + * @param int $from_length Number of characters for the fetchfrom property. * Must be greater than or equal to zero. - * @param int $subjectlength Number of characters for the fetchsubject property + * @param int $subject_length Number of characters for the fetchsubject property * Must be greater than or equal to zero. - * @param string $defaulthost * @return \stdClass Returns FALSE on error or, if successful, the information in an object with following properties: * * @@ -553,24 +1121,122 @@ function imap_gc($imap_stream, int $caches): void * * * - * fetchfrom - from line formatted to fit fromlength + * fetchfrom - from line formatted to fit from_length * characters * * * * * fetchsubject - subject line formatted to fit - * subjectlength characters + * subject_length characters + * + * + * + * @throws ImapException + * + */ +function imap_headerinfo($imap, int $message_num, int $from_length = 0, int $subject_length = 0): \stdClass +{ + error_clear_last(); + $result = \imap_headerinfo($imap, $message_num, $from_length, $subject_length); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns headers for all messages in a mailbox. * + * @param resource $imap An IMAP\Connection instance. + * @return array Returns an array of string formatted with header info. One + * element per mail message. + * Returns FALSE on failure. + * @throws ImapException * + */ +function imap_headers($imap): array +{ + error_clear_last(); + $result = \imap_headers($imap); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns an array containing the names of the mailboxes that have + * content in the text of the mailbox. + * + * This function is similar to imap_listmailbox, + * but it will additionally check for the presence of the string + * content inside the mailbox data. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @param string $content The searched string + * @return array Returns an array containing the names of the mailboxes that have + * content in the text of the mailbox. + * @throws ImapException * + */ +function imap_listscan($imap, string $reference, string $pattern, string $content): array +{ + error_clear_last(); + $result = \imap_listscan($imap, $reference, $pattern, $content); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets an array of all the mailboxes that you have subscribed. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $reference reference should normally be just the server + * specification as described in imap_open + * @param string $pattern Specifies where in the mailbox hierarchy + * to start searching. + * + * There are two special characters you can + * pass as part of the pattern: + * '*' and '%'. + * '*' means to return all mailboxes. If you pass + * pattern as '*', you will + * get a list of the entire mailbox hierarchy. + * '%' + * means to return the current level only. + * '%' as the pattern + * parameter will return only the top level + * mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. + * @return array Returns an array of all the subscribed mailboxes. * @throws ImapException * */ -function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int $subjectlength = 0, string $defaulthost = null): \stdClass +function imap_lsub($imap, string $reference, string $pattern): array { error_clear_last(); - $result = \imap_headerinfo($imap_stream, $msg_number, $fromlength, $subjectlength, $defaulthost); + $result = \imap_lsub($imap, $reference, $pattern); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -580,14 +1246,14 @@ function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int /** * Create a MIME message based on the given envelope - * and body sections. + * and bodies sections. * * @param array $envelope An associative array of header fields. Valid keys are: "remail", * "return_path", "date", "from", "reply_to", "in_reply_to", "subject", * "to", "cc", "bcc" and "message_id", which set the respective message headers to the given string. * To set additional headers, the key "custom_headers" is supported, which expects * an array of those headers, e.g. ["User-Agent: My Mail Client"]. - * @param array $body An indexed array of bodies. The first body is the main body of the message; + * @param array $bodies An indexed array of bodies. The first body is the main body of the message; * only if it has a type of TYPEMULTIPART, further bodies * are processed; these bodies constitute the bodies of the parts. * @@ -685,10 +1351,10 @@ function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int * @throws ImapException * */ -function imap_mail_compose(array $envelope, array $body): string +function imap_mail_compose(array $envelope, array $bodies): string { error_clear_last(); - $result = \imap_mail_compose($envelope, $body); + $result = \imap_mail_compose($envelope, $bodies); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -697,16 +1363,15 @@ function imap_mail_compose(array $envelope, array $body): string /** - * Copies mail messages specified by msglist + * Copies mail messages specified by message_nums * to specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param string $msglist msglist is a range not just message + * @param resource $imap An IMAP\Connection instance. + * @param string $message_nums message_nums is a range not just message * numbers (as described in RFC2060). * @param string $mailbox The mailbox name, see imap_open for more * information - * @param int $options options is a bitmask of one or more of + * @param int $flags flags is a bitmask of one or more of * * * @@ -716,17 +1381,18 @@ function imap_mail_compose(array $envelope, array $body): string * * * CP_MOVE - Delete the messages from - * the current mailbox after copying + * the current mailbox after copying. If this flag is set, the function + * behaves identically to imap_mail_move. * * * * @throws ImapException * */ -function imap_mail_copy($imap_stream, string $msglist, string $mailbox, int $options = 0): void +function imap_mail_copy($imap, string $message_nums, string $mailbox, int $flags = 0): void { error_clear_last(); - $result = \imap_mail_copy($imap_stream, $msglist, $mailbox, $options); + $result = \imap_mail_copy($imap, $message_nums, $mailbox, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -734,16 +1400,18 @@ function imap_mail_copy($imap_stream, string $msglist, string $mailbox, int $opt /** - * Moves mail messages specified by msglist to the + * Moves mail messages specified by message_nums to the * specified mailbox. + * Note that the mail messages are actually copied to the + * mailbox, and the original messages are flagged for deletion. + * That implies that the messages in mailbox are assigned new UIDs. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param string $msglist msglist is a range not just message numbers + * @param resource $imap An IMAP\Connection instance. + * @param string $message_nums message_nums is a range not just message numbers * (as described in RFC2060). * @param string $mailbox The mailbox name, see imap_open for more * information - * @param int $options options is a bitmask and may contain the single option: + * @param int $flags flags is a bitmask and may contain the single option: * * * @@ -754,10 +1422,10 @@ function imap_mail_copy($imap_stream, string $msglist, string $mailbox, int $opt * @throws ImapException * */ -function imap_mail_move($imap_stream, string $msglist, string $mailbox, int $options = 0): void +function imap_mail_move($imap, string $message_nums, string $mailbox, int $flags = 0): void { error_clear_last(); - $result = \imap_mail_move($imap_stream, $msglist, $mailbox, $options); + $result = \imap_mail_move($imap, $message_nums, $mailbox, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -779,15 +1447,25 @@ function imap_mail_move($imap_stream, string $msglist, string $mailbox, int $opt * @param string $cc * @param string $bcc The receivers specified in bcc will get the * mail, but are excluded from the headers. - * @param string $rpath Use this parameter to specify return path upon mail delivery failure. + * @param string $return_path Use this parameter to specify return path upon mail delivery failure. * This is useful when using PHP as a mail client for multiple users. * @throws ImapException * */ -function imap_mail(string $to, string $subject, string $message, string $additional_headers = null, string $cc = null, string $bcc = null, string $rpath = null): void +function imap_mail(string $to, string $subject, string $message, string $additional_headers = null, string $cc = null, string $bcc = null, string $return_path = null): void { error_clear_last(); - $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc, $rpath); + if ($return_path !== null) { + $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc, $return_path); + } elseif ($bcc !== null) { + $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc); + } elseif ($cc !== null) { + $result = \imap_mail($to, $subject, $message, $additional_headers, $cc); + } elseif ($additional_headers !== null) { + $result = \imap_mail($to, $subject, $message, $additional_headers); + } else { + $result = \imap_mail($to, $subject, $message); + } if ($result === false) { throw ImapException::createFromPhpError(); } @@ -800,8 +1478,7 @@ function imap_mail(string $to, string $subject, string $message, string $additio * all messages in the mailbox, which will take some additional time to * execute. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @return \stdClass Returns the information in an object with following properties: * * Mailbox properties @@ -847,10 +1524,37 @@ function imap_mail(string $to, string $subject, string $message, string $additio * @throws ImapException * */ -function imap_mailboxmsginfo($imap_stream): \stdClass +function imap_mailboxmsginfo($imap): \stdClass { error_clear_last(); - $result = \imap_mailboxmsginfo($imap_stream); + $result = \imap_mailboxmsginfo($imap); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Decodes MIME message header extensions that are non ASCII text (see RFC2047). + * + * @param string $string The MIME text + * @return array The decoded elements are returned in an array of objects, where each + * object has two properties, charset and + * text. + * + * If the element hasn't been encoded, and in other words is in + * plain US-ASCII, the charset property of that element is + * set to default. + * + * The function returns FALSE on failure. + * @throws ImapException + * + */ +function imap_mime_header_decode(string $string): array +{ + error_clear_last(); + $result = \imap_mime_header_decode($string); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -861,15 +1565,15 @@ function imap_mailboxmsginfo($imap_stream): \stdClass /** * Decode a modified UTF-7 (as specified in RFC 2060, section 5.1.3) string to UTF-8. * - * @param string $in A string encoded in modified UTF-7. - * @return string Returns in converted to UTF-8. + * @param string $string A string encoded in modified UTF-7. + * @return string Returns string converted to UTF-8. * @throws ImapException * */ -function imap_mutf7_to_utf8(string $in): string +function imap_mutf7_to_utf8(string $string): string { error_clear_last(); - $result = \imap_mutf7_to_utf8($in); + $result = \imap_mutf7_to_utf8($string); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -880,16 +1584,15 @@ function imap_mutf7_to_utf8(string $in): string /** * Gets the number of messages in the current mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @return int Return the number of messages in the current mailbox, as an integer. * @throws ImapException * */ -function imap_num_msg($imap_stream): int +function imap_num_msg($imap): int { error_clear_last(); - $result = \imap_num_msg($imap_stream); + $result = \imap_num_msg($imap); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1031,9 +1734,9 @@ function imap_num_msg($imap_stream): int * * * - * @param string $username The user name - * @param string $password The password associated with the username - * @param int $options The options are a bit mask with one or more of + * @param string $user The user name + * @param string $password The password associated with the user + * @param int $flags The flags are a bit mask with one or more of * the following: * * @@ -1087,8 +1790,8 @@ function imap_num_msg($imap_stream): int * * * - * @param int $n_retries Number of maximum connect attempts - * @param array|null $params Connection parameters, the following (string) keys maybe used + * @param int $retries Number of maximum connect attempts + * @param array $options Connection parameters, the following (string) keys maybe used * to set one or more connection parameters: * * @@ -1097,14 +1800,33 @@ function imap_num_msg($imap_stream): int * * * - * @return resource Returns an IMAP stream on success. + * @return resource Returns an IMAP\Connection instance on success. + * @throws ImapException + * + */ +function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = []) +{ + error_clear_last(); + $result = \imap_open($mailbox, $user, $password, $flags, $retries, $options); + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Convert a quoted-printable string to an 8 bit string according to RFC2045, section 6.7. + * + * @param string $string A quoted-printable string + * @return string Returns an 8 bits string. * @throws ImapException * */ -function imap_open(string $mailbox, string $username, string $password, int $options = 0, int $n_retries = 0, ?array $params = null) +function imap_qprint(string $string): string { error_clear_last(); - $result = \imap_open($mailbox, $username, $password, $options, $n_retries, $params); + $result = \imap_qprint($string); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1117,40 +1839,60 @@ function imap_open(string $mailbox, string $username, string $password, int $opt * imap_open for the format of * mbox names). * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param string $old_mbox The old mailbox name, see imap_open for more + * @param resource $imap An IMAP\Connection instance. + * @param string $from The old mailbox name, see imap_open for more + * information + * @param string $to The new mailbox name, see imap_open for more * information - * @param string $new_mbox The new mailbox name, see imap_open for more + * @throws ImapException + * + */ +function imap_renamemailbox($imap, string $from, string $to): void +{ + error_clear_last(); + $result = \imap_renamemailbox($imap, $from, $to); + if ($result === false) { + throw ImapException::createFromPhpError(); + } +} + + +/** + * Returns a properly formatted email address as defined in RFC2822 given the needed information. + * + * @param string|null $mailbox The mailbox name, see imap_open for more * information + * @param string|null $hostname The email host part + * @param string|null $personal The name of the account owner + * @return string Returns a string properly formatted email address as defined in RFC2822. * @throws ImapException * */ -function imap_renamemailbox($imap_stream, string $old_mbox, string $new_mbox): void +function imap_rfc822_write_address(?string $mailbox, ?string $hostname, ?string $personal): string { error_clear_last(); - $result = \imap_renamemailbox($imap_stream, $old_mbox, $new_mbox); + $result = \imap_rfc822_write_address($mailbox, $hostname, $personal); if ($result === false) { throw ImapException::createFromPhpError(); } + return $result; } /** * Saves a part or the whole body of the specified message. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string|resource $file The path to the saved file as a string, or a valid file descriptor * returned by fopen. - * @param int $msg_number The message number - * @param string $part_number The part number. It is a string of integers delimited by period which + * @param int $message_num The message number + * @param string $section The part number. It is a string of integers delimited by period which * index into a body part list as per the IMAP4 specification - * @param int $options A bitmask with one or more of the following: + * @param int $flags A bitmask with one or more of the following: * * * - * FT_UID - The msg_number is a UID + * FT_UID - The message_num is a UID * * * @@ -1169,10 +1911,10 @@ function imap_renamemailbox($imap_stream, string $old_mbox, string $new_mbox): v * @throws ImapException * */ -function imap_savebody($imap_stream, $file, int $msg_number, string $part_number = "", int $options = 0): void +function imap_savebody($imap, $file, int $message_num, string $section = "", int $flags = 0): void { error_clear_last(); - $result = \imap_savebody($imap_stream, $file, $msg_number, $part_number, $options); + $result = \imap_savebody($imap, $file, $message_num, $section, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1182,18 +1924,17 @@ function imap_savebody($imap_stream, $file, int $msg_number, string $part_number /** * Sets an upper limit quota on a per mailbox basis. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $quota_root The mailbox to have a quota set. This should follow the IMAP standard * format for a mailbox: user.name. - * @param int $quota_limit The maximum size (in KB) for the quota_root + * @param int $mailbox_size The maximum size (in KB) for the quota_root * @throws ImapException * */ -function imap_set_quota($imap_stream, string $quota_root, int $quota_limit): void +function imap_set_quota($imap, string $quota_root, int $mailbox_size): void { error_clear_last(); - $result = \imap_set_quota($imap_stream, $quota_root, $quota_limit); + $result = \imap_set_quota($imap, $quota_root, $mailbox_size); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1203,20 +1944,19 @@ function imap_set_quota($imap_stream, string $quota_root, int $quota_limit): voi /** * Sets the ACL for a giving mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $mailbox The mailbox name, see imap_open for more * information - * @param string $id The user to give the rights to. + * @param string $user_id The user to give the rights to. * @param string $rights The rights to give to the user. Passing an empty string will delete * acl. * @throws ImapException * */ -function imap_setacl($imap_stream, string $mailbox, string $id, string $rights): void +function imap_setacl($imap, string $mailbox, string $user_id, string $rights): void { error_clear_last(); - $result = \imap_setacl($imap_stream, $mailbox, $id, $rights); + $result = \imap_setacl($imap, $mailbox, $user_id, $rights); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1228,8 +1968,7 @@ function imap_setacl($imap_stream, string $mailbox, string $id, string $rights): * flags set for the messages in the specified * sequence. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $sequence A sequence of message numbers. You can enumerate desired messages * with the X,Y syntax, or retrieve all messages * within an interval with the X:Y syntax @@ -1249,10 +1988,10 @@ function imap_setacl($imap_stream, string $mailbox, string $id, string $rights): * @throws ImapException * */ -function imap_setflag_full($imap_stream, string $sequence, string $flag, int $options = NIL): void +function imap_setflag_full($imap, string $sequence, string $flag, int $options = 0): void { error_clear_last(); - $result = \imap_setflag_full($imap_stream, $sequence, $flag, $options); + $result = \imap_setflag_full($imap, $sequence, $flag, $options); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1262,8 +2001,7 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op /** * Gets and sorts message numbers by the given parameters. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param int $criteria Criteria can be one (and only one) of the following: * * @@ -1302,8 +2040,8 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op * * * - * @param int $reverse Set this to 1 for reverse sorting - * @param int $options The options are a bitmask of one or more of the + * @param int $reverse Whether to sort in reverse order. + * @param int $flags The flags are a bitmask of one or more of the * following: * * @@ -1325,10 +2063,82 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op * @throws ImapException * */ -function imap_sort($imap_stream, int $criteria, int $reverse, int $options = 0, string $search_criteria = null, string $charset = null): array +function imap_sort($imap, int $criteria, int $reverse, int $flags = 0, string $search_criteria = null, string $charset = null): array { error_clear_last(); - $result = \imap_sort($imap_stream, $criteria, $reverse, $options, $search_criteria, $charset); + if ($charset !== null) { + $result = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria, $charset); + } elseif ($search_criteria !== null) { + $result = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria); + } else { + $result = \imap_sort($imap, $criteria, $reverse, $flags); + } + if ($result === false) { + throw ImapException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets status information about the given mailbox. + * + * @param resource $imap An IMAP\Connection instance. + * @param string $mailbox The mailbox name, see imap_open for more + * information + * @param int $flags Valid flags are: + * + * + * + * SA_MESSAGES - set $status->messages to the + * number of messages in the mailbox + * + * + * + * + * SA_RECENT - set $status->recent to the number + * of recent messages in the mailbox + * + * + * + * + * SA_UNSEEN - set $status->unseen to the number + * of unseen (new) messages in the mailbox + * + * + * + * + * SA_UIDNEXT - set $status->uidnext to the next + * uid to be used in the mailbox + * + * + * + * + * SA_UIDVALIDITY - set $status->uidvalidity to a + * constant that changes when uids for the mailbox may no longer be + * valid + * + * + * + * + * SA_ALL - set all of the above + * + * + * + * @return \stdClass This function returns an object containing status information. + * The object has the following properties: messages, + * recent, unseen, + * uidnext, and uidvalidity. + * + * flags is also set, which contains a bitmask which can + * be checked against any of the above constants. + * @throws ImapException + * + */ +function imap_status($imap, string $mailbox, int $flags): \stdClass +{ + error_clear_last(); + $result = \imap_status($imap, $mailbox, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1339,17 +2149,16 @@ function imap_sort($imap_stream, int $criteria, int $reverse, int $options = 0, /** * Subscribe to a new mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $mailbox The mailbox name, see imap_open for more * information * @throws ImapException * */ -function imap_subscribe($imap_stream, string $mailbox): void +function imap_subscribe($imap, string $mailbox): void { error_clear_last(); - $result = \imap_subscribe($imap_stream, $mailbox); + $result = \imap_subscribe($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1359,9 +2168,8 @@ function imap_subscribe($imap_stream, string $mailbox): void /** * Gets a tree of a threaded message. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param int $options + * @param resource $imap An IMAP\Connection instance. + * @param int $flags * @return array imap_thread returns an associative array containing * a tree of messages threaded by REFERENCES. * @@ -1381,10 +2189,10 @@ function imap_subscribe($imap_stream, string $mailbox): void * @throws ImapException * */ -function imap_thread($imap_stream, int $options = SE_FREE): array +function imap_thread($imap, int $flags = SE_FREE): array { error_clear_last(); - $result = \imap_thread($imap_stream, $options); + $result = \imap_thread($imap, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1425,17 +2233,18 @@ function imap_timeout(int $timeout_type, int $timeout = -1) * Removes the deletion flag for a specified message, which is set by * imap_delete or imap_mail_move. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. - * @param int $msg_number The message number + * @param resource $imap An IMAP\Connection instance. + * @param string $message_nums A string representing one or more messages in IMAP4-style sequence format + * ("n", "n:m", or combination of these + * delimited by commas). * @param int $flags * @throws ImapException * */ -function imap_undelete($imap_stream, int $msg_number, int $flags = 0): void +function imap_undelete($imap, string $message_nums, int $flags = 0): void { error_clear_last(); - $result = \imap_undelete($imap_stream, $msg_number, $flags); + $result = \imap_undelete($imap, $message_nums, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1445,17 +2254,16 @@ function imap_undelete($imap_stream, int $msg_number, int $flags = 0): void /** * Unsubscribe from the specified mailbox. * - * @param resource $imap_stream An IMAP stream returned by - * imap_open. + * @param resource $imap An IMAP\Connection instance. * @param string $mailbox The mailbox name, see imap_open for more * information * @throws ImapException * */ -function imap_unsubscribe($imap_stream, string $mailbox): void +function imap_unsubscribe($imap, string $mailbox): void { error_clear_last(); - $result = \imap_unsubscribe($imap_stream, $mailbox); + $result = \imap_unsubscribe($imap, $mailbox); if ($result === false) { throw ImapException::createFromPhpError(); } @@ -1465,15 +2273,15 @@ function imap_unsubscribe($imap_stream, string $mailbox): void /** * Encode a UTF-8 string to modified UTF-7 (as specified in RFC 2060, section 5.1.3). * - * @param string $in A UTF-8 encoded string. - * @return string Returns in converted to modified UTF-7. + * @param string $string A UTF-8 encoded string. + * @return string Returns string converted to modified UTF-7. * @throws ImapException * */ -function imap_utf8_to_mutf7(string $in): string +function imap_utf8_to_mutf7(string $string): string { error_clear_last(); - $result = \imap_utf8_to_mutf7($in); + $result = \imap_utf8_to_mutf7($string); if ($result === false) { throw ImapException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/info.php b/vendor/thecodingmachine/safe/generated/info.php index 1a76b406e..aefa0819d 100644 --- a/vendor/thecodingmachine/safe/generated/info.php +++ b/vendor/thecodingmachine/safe/generated/info.php @@ -5,6 +5,123 @@ 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) { + $result = \assert_options($what, $value); + } else { + $result = \assert_options($what); + } + if ($result === false) { + throw InfoException::createFromPhpError(); + } + return $result; +} + + +/** * Sets the process title visible in tools such as top and * ps. This function is available only in * CLI mode. @@ -25,14 +142,14 @@ function cli_set_process_title(string $title): void /** * Loads the PHP extension given by the parameter - * library. + * 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 $library This parameter is only the filename of the + * @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 @@ -77,10 +194,10 @@ function cli_set_process_title(string $title): void * @throws InfoException * */ -function dl(string $library): void +function dl(string $extension_filename): void { error_clear_last(); - $result = \dl($library); + $result = \dl($extension_filename); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -88,6 +205,24 @@ function dl(string $library): void /** + * + * + * @return string Returns the path, as a string. + * @throws InfoException + * + */ +function get_include_path(): string +{ + error_clear_last(); + $result = \get_include_path(); + if ($result === false) { + throw InfoException::createFromPhpError(); + } + return $result; +} + + +/** * Gets the time of the last modification of the main script of execution. * * If you're interested in getting the last modification time @@ -185,23 +320,40 @@ function getmyuid(): int /** * Parses options passed to the script. * - * @param string $options - * @param array $longopts - * @param int|null $optind - * @return array|array|array This function will return an array of option / argument pairs. + * @param string $short_options + * @param array $long_options + * @param int|null $rest_index + * @return \__benevolent This function will return an array of option / argument pairs. * @throws InfoException * */ -function getopt(string $options, array $longopts = null, ?int &$optind = null): array +function getopt(string $short_options, array $long_options = [], ?int &$rest_index = null): array { error_clear_last(); - if ($optind !== null) { - $result = \getopt($options, $longopts, $optind); - } elseif ($longopts !== null) { - $result = \getopt($options, $longopts); - } else { - $result = \getopt($options); + $result = \getopt($short_options, $long_options, $rest_index); + if ($result === false) { + throw InfoException::createFromPhpError(); } + return $result; +} + + +/** + * 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(); + $result = \getrusage($mode); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -212,17 +364,17 @@ function getopt(string $options, array $longopts = null, ?int &$optind = null): /** * Returns the value of the configuration option on success. * - * @param string $varname The configuration option name. + * @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 $varname): string +function ini_get(string $option): string { error_clear_last(); - $result = \ini_get($varname); + $result = \ini_get($option); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -235,18 +387,45 @@ function ini_get(string $varname): string * will keep this new value during the script's execution, and will be restored * at the script's ending. * - * @param string $varname Not all the available options can be changed using + * @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 string|int|float|bool $newvalue The new value for the option. + * @param string $value The new value for the option. * @return string Returns the old value on success, FALSE on failure. * @throws InfoException * */ -function ini_set(string $varname, $newvalue): string +function ini_set(string $option, string $value): string +{ + error_clear_last(); + $result = \ini_set($option, $value); + if ($result === false) { + throw InfoException::createFromPhpError(); + } + return $result; +} + + +/** + * + * + * @return 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(); - $result = \ini_set($varname, $newvalue); + $result = \php_sapi_name(); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -259,8 +438,8 @@ function ini_set(string $varname, $newvalue): string * modules, etc. It generates the appropriate HTML codes to insert * the information in a page. * - * @param int $flag To generate a custom credits page, you may want to use the - * flag parameter. + * @param int $flags To generate a custom credits page, you may want to use the + * flags parameter. * * * Pre-defined phpcredits flags @@ -323,10 +502,10 @@ function ini_set(string $varname, $newvalue): string * @throws InfoException * */ -function phpcredits(int $flag = CREDITS_ALL): void +function phpcredits(int $flags = CREDITS_ALL): void { error_clear_last(); - $result = \phpcredits($flag); + $result = \phpcredits($flags); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -348,9 +527,9 @@ function phpcredits(int $flag = CREDITS_ALL): void * phpinfo is also a valuable debugging tool as it * contains all EGPCS (Environment, GET, POST, Cookie, Server) data. * - * @param int $what The output may be customized by passing one or more of the + * @param int $flags The output may be customized by passing one or more of the * following constants bitwise values summed - * together in the optional what parameter. + * together in the optional flags parameter. * One can also combine the respective constants or bitwise values * together with the bitwise or operator. * @@ -433,10 +612,10 @@ function phpcredits(int $flag = CREDITS_ALL): void * @throws InfoException * */ -function phpinfo(int $what = INFO_ALL): void +function phpinfo(int $flags = INFO_ALL): void { error_clear_last(); - $result = \phpinfo($what); + $result = \phpinfo($flags); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -444,19 +623,19 @@ function phpinfo(int $what = INFO_ALL): void /** - * Adds setting to the server environment. The + * 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 $setting The setting, like "FOO=BAR" + * @param string $assignment The setting, like "FOO=BAR" * @throws InfoException * */ -function putenv(string $setting): void +function putenv(string $assignment): void { error_clear_last(); - $result = \putenv($setting); + $result = \putenv($assignment); if ($result === false) { throw InfoException::createFromPhpError(); } @@ -467,16 +646,16 @@ function putenv(string $setting): void * Sets the include_path * configuration option for the duration of the script. * - * @param string $new_include_path The new value for the include_path + * @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 $new_include_path): string +function set_include_path(string $include_path): string { error_clear_last(); - $result = \set_include_path($new_include_path); + $result = \set_include_path($include_path); if ($result === false) { throw InfoException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/ingres-ii.php b/vendor/thecodingmachine/safe/generated/ingres-ii.php deleted file mode 100644 index 9ea8b5f35..000000000 --- a/vendor/thecodingmachine/safe/generated/ingres-ii.php +++ /dev/null @@ -1,720 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\IngresiiException; - -/** - * ingres_autocommit is called before opening a - * transaction (before the first call to - * ingres_query or just after a call to - * ingres_rollback or - * ingres_commit) to switch the - * autocommit mode of the server on or off (when the script begins - * the autocommit mode is off). - * - * When autocommit mode is on, every query is automatically - * committed by the server, as if ingres_commit - * was called after every call to ingres_query. - * To see if autocommit is enabled use, - * ingres_autocommit_state. - * - * By default Ingres will rollback any uncommitted transactions at the end of - * a request. Use this function or ingres_commit to - * ensure your data is committed to the database. - * - * @param resource $link The connection link identifier - * @throws IngresiiException - * - */ -function ingres_autocommit($link): void -{ - error_clear_last(); - $result = \ingres_autocommit($link); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * ingres_close closes the connection to - * the Ingres server that is associated with the specified link. - * - * ingres_close is usually unnecessary, as it - * will not close persistent connections and all non-persistent connections - * are automatically closed at the end of the script. - * - * @param resource $link The connection link identifier - * @throws IngresiiException - * - */ -function ingres_close($link): void -{ - error_clear_last(); - $result = \ingres_close($link); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * ingres_commit commits the currently open - * transaction, making all changes made to the database permanent. - * - * This closes the transaction. A new transaction can be opened by sending a - * query with ingres_query. - * - * You can also have the server commit automatically after every - * query by calling ingres_autocommit before - * opening the transaction. - * - * By default Ingres will roll back any uncommitted transactions at the end of - * a request. Use this function or ingres_autocommit to - * ensure your that data is committed to the database. - * - * @param resource $link The connection link identifier - * @throws IngresiiException - * - */ -function ingres_commit($link): void -{ - error_clear_last(); - $result = \ingres_commit($link); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * ingres_connect opens a connection with the - * given Ingres database. - * - * The connection is closed when the script ends or when - * ingres_close is called on this link. - * - * @param string $database The database name. Must follow the syntax: - * - * [vnode::]dbname[/svr_class] - * @param string $username The Ingres user name - * @param string $password The password associated with username - * @param array $options ingres_connect options - * - * - * - * - * Option name - * Option type - * Description - * Example - * - * - * - * - * date_century_boundary - * integer - * The threshold by which a 2-digit year is determined to be in - * the current century or in the next century. Equivalent to II_DATE_CENTURY_BOUNDARY. - * 50 - * - * - * group - * string - * Specifies the group ID of the user, equivalent to the "-G" - * flag - * payroll - * - * - * role - * string - * The role ID of the application. If a role password is - * required, the parameter value should be specified as "role/password" - * - * - * effective_user - * string - * The ingres user account being impersonated, equivalent to the "-u" flag - * another_user - * - * - * dbms_password - * string - * The internal database password for the user connecting to Ingres - * s3cr3t - * - * - * table_structure - * string - * - * The default structure for new tables. - * Valid values for table_structure are: - * - * INGRES_STRUCTURE_BTREE - * INGRES_STRUCTURE_HASH - * INGRES_STRUCTURE_HEAP - * INGRES_STRUCTURE_ISAM - * INGRES_STRUCTURE_CBTREE - * INGRES_STRUCTURE_CISAM - * INGRES_STRUCTURE_CHASH - * INGRES_STRUCTURE_CHEAP - * - * - * - * INGRES_STRUCTURE_BTREE - * - * - * index_structure - * string - * - * The default structure for new secondary indexes. Valid values - * for index_structure are: - * - * INGRES_STRUCTURE_CBTREE - * INGRES_STRUCTURE_CISAM - * INGRES_STRUCTURE_CHASH - * INGRES_STRUCTURE_BTREE - * INGRES_STRUCTURE_HASH - * INGRES_STRUCTURE_ISAM - * - * - * - * INGRES_STRUCTURE_HASH - * - * - * login_local - * boolean - * Determines how the connection user ID and password are - * used when a VNODE is included in the target database string. - * If set to TRUE, the user ID and password are used to locally access - * the VNODE, and the VNODE login information is used to establish the DBMS - * connection. If set to FALSE, the process user ID is used to access - * the VNODE, and the connection user ID and password are used in place - * of the VNODE login information to establish the DBMS connection. - * This parameter is ignored if no VNODE is included in the target - * database string. The default is FALSE. - * TRUE - * - * - * timezone - * string - * Controls the timezone of the session. If not set it will - * default to the value defined by II_TIMEZONE_NAME. If - * II_TIMEZONE_NAME is not defined, NA-PACIFIC (GMT-8 with Daylight - * Savings) is used. - * - * - * date_format - * integer - * Sets the allowable input and output format for Ingres dates. - * Defaults to the value defined by II_DATE_FORMAT. If II_DATE_FORMAT is - * not set the default date format is US, e.g. mm/dd/yy. Valid values - * for date_format are: - * - * INGRES_DATE_DMY - * INGRES_DATE_FINISH - * INGRES_DATE_GERMAN - * INGRES_DATE_ISO - * INGRES_DATE_ISO4 - * INGRES_DATE_MDY - * INGRES_DATE_MULTINATIONAL - * INGRES_DATE_MULTINATIONAL4 - * INGRES_DATE_YMD - * INGRES_DATE_US - * - * - * - * INGRES_DATE_MULTINATIONAL4 - * - * - * decimal_separator - * string - * The character identifier for decimal data - * "," - * - * - * money_lort - * integer - * Leading or trailing currency sign. Valid values for money_lort - * are: - * - * INGRES_MONEY_LEADING - * INGRES_MONEY_TRAILING - * - * - * - * INGRES_MONEY_TRAILING - * - * - * money_sign - * string - * The currency symbol to be used with the MONEY datatype - * € - * - * - * money_precision - * integer - * The precision of the MONEY datatype - * 3 - * - * - * float4_precision - * integer - * Precision of the FLOAT4 datatype - * 10 - * - * - * float8_precision - * integer - * Precision of the FLOAT8 data - * 10 - * - * - * blob_segment_length - * integer - * The amount of data in bytes to fetch at a time when retrieving - * BLOB or CLOB data, defaults to 4096 bytes when not explicitly set - * 8192 - * - * - * - * - * - * The default structure for new tables. - * Valid values for table_structure are: - * - * INGRES_STRUCTURE_BTREE - * INGRES_STRUCTURE_HASH - * INGRES_STRUCTURE_HEAP - * INGRES_STRUCTURE_ISAM - * INGRES_STRUCTURE_CBTREE - * INGRES_STRUCTURE_CISAM - * INGRES_STRUCTURE_CHASH - * INGRES_STRUCTURE_CHEAP - * - * - * The default structure for new secondary indexes. Valid values - * for index_structure are: - * - * INGRES_STRUCTURE_CBTREE - * INGRES_STRUCTURE_CISAM - * INGRES_STRUCTURE_CHASH - * INGRES_STRUCTURE_BTREE - * INGRES_STRUCTURE_HASH - * INGRES_STRUCTURE_ISAM - * - * - * Sets the allowable input and output format for Ingres dates. - * Defaults to the value defined by II_DATE_FORMAT. If II_DATE_FORMAT is - * not set the default date format is US, e.g. mm/dd/yy. Valid values - * for date_format are: - * - * INGRES_DATE_DMY - * INGRES_DATE_FINISH - * INGRES_DATE_GERMAN - * INGRES_DATE_ISO - * INGRES_DATE_ISO4 - * INGRES_DATE_MDY - * INGRES_DATE_MULTINATIONAL - * INGRES_DATE_MULTINATIONAL4 - * INGRES_DATE_YMD - * INGRES_DATE_US - * - * - * Leading or trailing currency sign. Valid values for money_lort - * are: - * - * INGRES_MONEY_LEADING - * INGRES_MONEY_TRAILING - * - * @return resource Returns a Ingres link resource on success - * @throws IngresiiException - * - */ -function ingres_connect(string $database = null, string $username = null, string $password = null, array $options = null) -{ - error_clear_last(); - if ($options !== null) { - $result = \ingres_connect($database, $username, $password, $options); - } elseif ($password !== null) { - $result = \ingres_connect($database, $username, $password); - } elseif ($username !== null) { - $result = \ingres_connect($database, $username); - } elseif ($database !== null) { - $result = \ingres_connect($database); - } else { - $result = \ingres_connect(); - } - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } - return $result; -} - - -/** - * Execute a query prepared using ingres_prepare. - * - * @param resource $result The result query identifier - * @param array $params An array of parameter values to be used with the query - * @param string $types A string containing a sequence of types for the parameter values - * passed. See the types parameter in - * ingres_query for the list of type codes. - * @throws IngresiiException - * - */ -function ingres_execute($result, array $params = null, string $types = null): void -{ - error_clear_last(); - if ($types !== null) { - $result = \ingres_execute($result, $params, $types); - } elseif ($params !== null) { - $result = \ingres_execute($result, $params); - } else { - $result = \ingres_execute($result); - } - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * ingres_field_name returns the name of a field - * in a query result. - * - * @param resource $result The query result identifier - * @param int $index index is the field whose name will be - * retrieved. - * - * The possible values of index depend upon - * the value - * of ingres.array_index_start. - * If ingres.array_index_start - * is 1 (the default) - * then index must be - * between 1 and the value returned - * by ingres_num_fields. If ingres.array_index_start - * is 0 then index must - * be between 0 - * and ingres_num_fields - - * 1. - * @return string Returns the name of a field - * in a query result - * @throws IngresiiException - * - */ -function ingres_field_name($result, int $index): string -{ - error_clear_last(); - $result = \ingres_field_name($result, $index); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } - return $result; -} - - -/** - * Get the type of a field in a query result. - * - * @param resource $result The query result identifier - * @param int $index index is the field whose type will be - * retrieved. - * - * The possible values of index depend upon - * the value - * of ingres.array_index_start. - * If ingres.array_index_start - * is 1 (the default) - * then index must be - * between 1 and the value returned - * by ingres_num_fields. If ingres.array_index_start - * is 0 then index must - * be between 0 - * and ingres_num_fields - - * 1. - * @return string ingres_field_type returns the type of a - * field in a query result. Examples of - * types returned are IIAPI_BYTE_TYPE, - * IIAPI_CHA_TYPE, IIAPI_DTE_TYPE, - * IIAPI_FLT_TYPE, IIAPI_INT_TYPE, - * IIAPI_VCH_TYPE. Some of these types can map to more - * than one SQL type depending on the length of the field (see - * ingres_field_length). For example - * IIAPI_FLT_TYPE can be a float4 or a float8. For detailed - * information, see the Ingres OpenAPI User Guide, Appendix - * "Data Types" in the Ingres documentation. - * @throws IngresiiException - * - */ -function ingres_field_type($result, int $index): string -{ - error_clear_last(); - $result = \ingres_field_type($result, $index); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } - return $result; -} - - -/** - * - * - * @param resource $result The query result identifier - * @throws IngresiiException - * - */ -function ingres_free_result($result): void -{ - error_clear_last(); - $result = \ingres_free_result($result); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * Open a persistent connection to an Ingres database. - * - * There are only two differences between this function and - * ingres_connect: First, when connecting, the - * function will initially try to find a (persistent) link that is - * 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 Ingres server will not - * be closed when the execution of the script ends. Instead, the - * link will remain open for future use - * (ingres_close will not close links - * established by ingres_pconnect). This type - * of link is therefore called "persistent". - * - * @param string $database The database name. Must follow the syntax: - * - * [vnode::]dbname[/svr_class] - * @param string $username The Ingres user name - * @param string $password The password associated with username - * @param array $options See ingres_connect for the list of options that - * can be passed - * @return resource Returns an Ingres link resource on success - * @throws IngresiiException - * - */ -function ingres_pconnect(string $database = null, string $username = null, string $password = null, array $options = null) -{ - error_clear_last(); - if ($options !== null) { - $result = \ingres_pconnect($database, $username, $password, $options); - } elseif ($password !== null) { - $result = \ingres_pconnect($database, $username, $password); - } elseif ($username !== null) { - $result = \ingres_pconnect($database, $username); - } elseif ($database !== null) { - $result = \ingres_pconnect($database); - } else { - $result = \ingres_pconnect(); - } - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } - return $result; -} - - -/** - * This function is used to position the cursor associated with the result - * resource before issuing a fetch. If ingres.array_index_start - * is set to 0 then the first row is 0 else it is 1. - * ingres_result_seek can be used only with queries that - * make use of scrollable - * cursors. It cannot be used with - * ingres_unbuffered_query. - * - * @param resource $result The result identifier for a query - * @param int $position The row to position the cursor on. If ingres.array_index_start - * is set to 0, then the first row is 0, else it is 1 - * @throws IngresiiException - * - */ -function ingres_result_seek($result, int $position): void -{ - error_clear_last(); - $result = \ingres_result_seek($result, $position); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * ingres_rollback rolls back the currently - * open transaction, actually cancelling all changes made to the - * database during the transaction. - * - * This closes the transaction. A new transaction can be opened by sending a - * query with ingres_query. - * - * @param resource $link The connection link identifier - * @throws IngresiiException - * - */ -function ingres_rollback($link): void -{ - error_clear_last(); - $result = \ingres_rollback($link); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} - - -/** - * ingres_set_environment is called to set environmental - * options that affect the output of certain values from Ingres, such as the - * timezone, date format, decimal character separator, and float precision. - * - * @param resource $link The connection link identifier - * @param array $options An enumerated array of option name/value pairs. The following table - * lists the option name and the expected type - * - * - * - * - * - * Option name - * Option type - * Description - * Example - * - * - * - * - * date_century_boundary - * integer - * The threshold by which a 2-digit year is determined to be in - * the current century or in the next century. Equivalent to II_DATE_CENTURY_BOUNDARY - * 50 - * - * - * timezone - * string - * Controls the timezone of the session. If not set, it will - * default the value defined by II_TIMEZONE_NAME. If - * II_TIMEZONE_NAME is not defined, NA-PACIFIC (GMT-8 with Daylight - * Savings) is used. - * UNITED-KINGDOM - * - * - * date_format - * integer - * Sets the allowable input and output format for Ingres dates. - * Defaults to the value defined by II_DATE_FORMAT. If II_DATE_FORMAT is - * not set, the default date format is US, for example mm/dd/yy. Valid values - * for date_format are: - * - * INGRES_DATE_DMY - * INGRES_DATE_FINISH - * INGRES_DATE_GERMAN - * INGRES_DATE_ISO - * INGRES_DATE_ISO4 - * INGRES_DATE_MDY - * INGRES_DATE_MULTINATIONAL - * INGRES_DATE_MULTINATIONAL4 - * INGRES_DATE_YMD - * INGRES_DATE_US - * - * - * - * INGRES_DATE_ISO4 - * - * - * decimal_separator - * string - * The character identifier for decimal data - * "," - * - * - * money_lort - * integer - * Leading or trailing currency sign. Valid values for money_lort - * are: - * - * INGRES_MONEY_LEADING - * INGRES_MONEY_TRAILING - * - * - * - * INGRES_MONEY_LEADING - * - * - * money_sign - * string - * The currency symbol to be used with the MONEY datatype - * € - * - * - * money_precision - * integer - * The precision of the MONEY datatype - * 2 - * - * - * float4_precision - * integer - * Precision of the FLOAT4 datatype - * 10 - * - * - * float8_precision - * integer - * Precision of the FLOAT8 data - * 10 - * - * - * blob_segment_length - * integer - * The amount of data in bytes to fetch at a time when retrieving - * BLOB or CLOB data. Defaults to 4096 bytes when not set explicitly - * 8192 - * - * - * - * - * - * Sets the allowable input and output format for Ingres dates. - * Defaults to the value defined by II_DATE_FORMAT. If II_DATE_FORMAT is - * not set, the default date format is US, for example mm/dd/yy. Valid values - * for date_format are: - * - * INGRES_DATE_DMY - * INGRES_DATE_FINISH - * INGRES_DATE_GERMAN - * INGRES_DATE_ISO - * INGRES_DATE_ISO4 - * INGRES_DATE_MDY - * INGRES_DATE_MULTINATIONAL - * INGRES_DATE_MULTINATIONAL4 - * INGRES_DATE_YMD - * INGRES_DATE_US - * - * - * Leading or trailing currency sign. Valid values for money_lort - * are: - * - * INGRES_MONEY_LEADING - * INGRES_MONEY_TRAILING - * - * @throws IngresiiException - * - */ -function ingres_set_environment($link, array $options): void -{ - error_clear_last(); - $result = \ingres_set_environment($link, $options); - if ($result === false) { - throw IngresiiException::createFromPhpError(); - } -} diff --git a/vendor/thecodingmachine/safe/generated/json.php b/vendor/thecodingmachine/safe/generated/json.php index dad455ccd..e524c6178 100644 --- a/vendor/thecodingmachine/safe/generated/json.php +++ b/vendor/thecodingmachine/safe/generated/json.php @@ -6,9 +6,14 @@ use Safe\Exceptions\JsonException; /** * Returns a string containing the JSON representation of the supplied - * value. + * value. If the parameter is an array or object, + * it will be serialized recursively. * - * The encoding is affected by the supplied options + * 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. * @@ -19,7 +24,7 @@ use Safe\Exceptions\JsonException; * * PHP implements a superset of JSON as specified in the original * RFC 7159. - * @param int $options Bitmask consisting of + * @param int $flags Bitmask consisting of * JSON_FORCE_OBJECT, * JSON_HEX_QUOT, * JSON_HEX_TAG, @@ -42,30 +47,10 @@ use Safe\Exceptions\JsonException; * @throws JsonException * */ -function json_encode($value, int $options = 0, int $depth = 512): string -{ - error_clear_last(); - $result = \json_encode($value, $options, $depth); - if ($result === false) { - throw JsonException::createFromPhpError(); - } - return $result; -} - - -/** - * Returns the error string of the last json_encode or json_decode - * call, which did not specify JSON_THROW_ON_ERROR. - * - * @return string Returns the error message on success, "No error" if no - * error has occurred. - * @throws JsonException - * - */ -function json_last_error_msg(): string +function json_encode($value, int $flags = 0, int $depth = 512): string { error_clear_last(); - $result = \json_last_error_msg(); + $result = \json_encode($value, $flags, $depth); if ($result === false) { throw JsonException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/ldap.php b/vendor/thecodingmachine/safe/generated/ldap.php index 871f29580..0bfaaaf2b 100644 --- a/vendor/thecodingmachine/safe/generated/ldap.php +++ b/vendor/thecodingmachine/safe/generated/ldap.php @@ -5,20 +5,22 @@ namespace Safe; use Safe\Exceptions\LdapException; /** - * Does the same thing as ldap_add but returns the LDAP result resource to be parsed with ldap_parse_result. + * Translate ISO-8859 characters to t61 + * characters. * - * @param resource $link_identifier - * @param string $dn - * @param array $entry - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. + * This function is useful if you have to talk to a legacy + * LDAPv2 server. + * + * @param string $value The text to be translated. + * @return string Return the t61 translation of + * value. * @throws LdapException * */ -function ldap_add_ext($link_identifier, string $dn, array $entry, array $serverctrls = null) +function ldap_8859_to_t61(string $value): string { error_clear_last(); - $result = \ldap_add_ext($link_identifier, $dn, $entry, $serverctrls); + $result = \ldap_8859_to_t61($value); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -29,7 +31,7 @@ function ldap_add_ext($link_identifier, string $dn, array $entry, array $serverc /** * Add entries in the LDAP directory. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry An array that specifies the information about the entry. The values in * the entries are indexed by individual attributes. @@ -41,55 +43,43 @@ function ldap_add_ext($link_identifier, string $dn, array $entry, array $serverc * ]]> * * - * @param array $serverctrls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_add($link_identifier, string $dn, array $entry, array $serverctrls = null): void +function ldap_add($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); - $result = \ldap_add($link_identifier, $dn, $entry, $serverctrls); - if ($result === false) { - throw LdapException::createFromPhpError(); + if ($controls !== null) { + $result = \ldap_add($ldap, $dn, $entry, $controls); + } else { + $result = \ldap_add($ldap, $dn, $entry); } -} - - -/** - * Does the same thing as ldap_bind but returns the LDAP result resource to be parsed with ldap_parse_result. - * - * @param resource $link_identifier - * @param string|null $bind_rdn - * @param string|null $bind_password - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. - * @throws LdapException - * - */ -function ldap_bind_ext($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null, array $serverctrls = null) -{ - error_clear_last(); - $result = \ldap_bind_ext($link_identifier, $bind_rdn, $bind_password, $serverctrls); if ($result === false) { throw LdapException::createFromPhpError(); } - return $result; } /** * Binds to the LDAP directory with specified RDN and password. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param string|null $bind_rdn - * @param string|null $bind_password + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param string|null $dn + * @param string|null $password * @throws LdapException * */ -function ldap_bind($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null): void +function ldap_bind($ldap, ?string $dn = null, ?string $password = null): void { error_clear_last(); - $result = \ldap_bind($link_identifier, $bind_rdn, $bind_password); + if ($password !== null) { + $result = \ldap_bind($ldap, $dn, $password); + } elseif ($dn !== null) { + $result = \ldap_bind($ldap, $dn); + } else { + $result = \ldap_bind($ldap); + } if ($result === false) { throw LdapException::createFromPhpError(); } @@ -99,7 +89,7 @@ function ldap_bind($link_identifier, ?string $bind_rdn = null, ?string $bind_pas /** * Retrieve the pagination information send by the server. * - * @param resource $link An LDAP link identifier, returned by ldap_connect. + * @param resource $link An LDAP resource, returned by ldap_connect. * @param resource $result * @param string|null $cookie An opaque structure sent by the server. * @param int|null $estimated The estimated number of entries to retrieve. @@ -119,7 +109,7 @@ function ldap_control_paged_result_response($link, $result, ?string &$cookie = n /** * Enable LDAP pagination by sending the pagination control (page size, cookie...). * - * @param resource $link An LDAP link identifier, returned by ldap_connect. + * @param resource $link An LDAP resource, returned by ldap_connect. * @param int $pagesize The number of entries by page. * @param bool $iscritical Indicates whether the pagination is critical or not. * If true and if the server doesn't support pagination, the search @@ -143,16 +133,16 @@ function ldap_control_paged_result($link, int $pagesize, bool $iscritical = fals * Returns the number of entries stored in the result of previous search * operations. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_identifier The internal LDAP result. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $result An LDAP\Result instance, returned by ldap_list or ldap_search. * @return int Returns number of entries in the result. * @throws LdapException * */ -function ldap_count_entries($link_identifier, $result_identifier): int +function ldap_count_entries($ldap, $result): int { error_clear_last(); - $result = \ldap_count_entries($link_identifier, $result_identifier); + $result = \ldap_count_entries($ldap, $result); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -161,64 +151,67 @@ function ldap_count_entries($link_identifier, $result_identifier): int /** - * Does the same thing as ldap_delete but returns the LDAP result resource to be parsed with ldap_parse_result. + * Deletes a particular entry in LDAP directory. * - * @param resource $link_identifier - * @param string $dn - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param string $dn The distinguished name of an LDAP entity. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_delete_ext($link_identifier, string $dn, array $serverctrls = null) +function ldap_delete($ldap, string $dn, array $controls = null): void { error_clear_last(); - $result = \ldap_delete_ext($link_identifier, $dn, $serverctrls); + if ($controls !== null) { + $result = \ldap_delete($ldap, $dn, $controls); + } else { + $result = \ldap_delete($ldap, $dn); + } if ($result === false) { throw LdapException::createFromPhpError(); } - return $result; } /** - * Deletes a particular entry in LDAP directory. + * Turns the specified dn, into a more user-friendly + * form, stripping off type names. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. - * @param array $serverctrls Array of LDAP Controls to send with the request. + * @return string Returns the user friendly name. * @throws LdapException * */ -function ldap_delete($link_identifier, string $dn, array $serverctrls = null): void +function ldap_dn2ufn(string $dn): string { error_clear_last(); - $result = \ldap_delete($link_identifier, $dn, $serverctrls); + $result = \ldap_dn2ufn($dn); if ($result === false) { throw LdapException::createFromPhpError(); } + return $result; } /** * Performs a PASSWD extended operation. * - * @param resource $link An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param string $user dn of the user to change the password of. - * @param string $oldpw The old password of this user. May be ommited depending of server configuration. - * @param string $newpw The new password for this user. May be omitted or empty to have a generated password. - * @param array $serverctrls If provided, a password policy request control is send with the request and this is + * @param string $old_password The old password of this user. May be ommited depending of server configuration. + * @param string $new_password The new password for this user. May be omitted or empty to have a generated password. + * @param array $controls If provided, a password policy request control is send with the request and this is * filled with an array of LDAP Controls * returned with the request. - * @return mixed Returns the generated password if newpw is empty or omitted. + * @return string|bool Returns the generated password if new_password is empty or omitted. * Otherwise returns TRUE on success. * @throws LdapException * */ -function ldap_exop_passwd($link, string $user = "", string $oldpw = "", string $newpw = "", array &$serverctrls = null) +function ldap_exop_passwd($ldap, string $user = "", string $old_password = "", string $new_password = "", array &$controls = null) { error_clear_last(); - $result = \ldap_exop_passwd($link, $user, $oldpw, $newpw, $serverctrls); + $result = \ldap_exop_passwd($ldap, $user, $old_password, $new_password, $controls); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -229,15 +222,15 @@ function ldap_exop_passwd($link, string $user = "", string $oldpw = "", string $ /** * Performs a WHOAMI extended operation and returns the data. * - * @param resource $link An LDAP link identifier, returned by ldap_connect. - * @return string The data returned by the server. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @return string|bool The data returned by the server. * @throws LdapException * */ -function ldap_exop_whoami($link): string +function ldap_exop_whoami($ldap) { error_clear_last(); - $result = \ldap_exop_whoami($link); + $result = \ldap_exop_whoami($ldap); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -246,27 +239,37 @@ function ldap_exop_whoami($link): string /** - * Performs an extended operation on the specified link with - * reqoid the OID of the operation and - * reqdata the data. - * - * @param resource $link An LDAP link identifier, returned by ldap_connect. - * @param string $reqoid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send. - * @param string $reqdata The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded. - * @param array|null $serverctrls Array of LDAP Controls to send with the request. - * @param string|null $retdata Will be filled with the extended operation response data if provided. + * Performs an extended operation on the specified ldap with + * request_oid the OID of the operation and + * request_data the data. + * + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param string $request_oid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send. + * @param string $request_data The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded. + * @param array|null $controls Array of LDAP Controls to send with the request. + * @param string|null $response_data Will be filled with the extended operation response data if provided. * If not provided you may use ldap_parse_exop on the result object * later to get this data. - * @param string|null $retoid Will be filled with the response OID if provided, usually equal to the request OID. - * @return mixed When used with retdata, returns TRUE on success. - * When used without retdata, returns a result identifier. + * @param string|null $response_oid Will be filled with the response OID if provided, usually equal to the request OID. + * @return resource|bool When used with response_data, returns TRUE on success. + * When used without response_data, returns a result identifier. * @throws LdapException * */ -function ldap_exop($link, string $reqoid, string $reqdata = null, ?array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null) +function ldap_exop($ldap, string $request_oid, string $request_data = null, ?array $controls = null, ?string &$response_data = null, ?string &$response_oid = null) { error_clear_last(); - $result = \ldap_exop($link, $reqoid, $reqdata, $serverctrls, $retdata, $retoid); + if ($response_oid !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data, $response_oid); + } elseif ($response_data !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data); + } elseif ($controls !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data, $controls); + } elseif ($request_data !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data); + } else { + $result = \ldap_exop($ldap, $request_oid); + } if ($result === false) { throw LdapException::createFromPhpError(); } @@ -309,17 +312,17 @@ function ldap_explode_dn(string $dn, int $with_attrib): array * Similar to reading entries, attributes are also read one by one from a * particular entry. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_entry_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $entry An LDAP\ResultEntry instance. * @return string Returns the first attribute in the entry on success and FALSE on * error. * @throws LdapException * */ -function ldap_first_attribute($link_identifier, $result_entry_identifier): string +function ldap_first_attribute($ldap, $entry): string { error_clear_last(); - $result = \ldap_first_attribute($link_identifier, $result_entry_identifier); + $result = \ldap_first_attribute($ldap, $entry); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -336,17 +339,16 @@ function ldap_first_attribute($link_identifier, $result_entry_identifier): strin * ldap_first_entry and * ldap_next_entry functions. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_identifier - * @return resource Returns the result entry identifier for the first entry on success and - * FALSE on error. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $result An LDAP\Result instance, returned by ldap_list or ldap_search. + * @return resource Returns an LDAP\ResultEntry instance. * @throws LdapException * */ -function ldap_first_entry($link_identifier, $result_identifier) +function ldap_first_entry($ldap, $result) { error_clear_last(); - $result = \ldap_first_entry($link_identifier, $result_identifier); + $result = \ldap_first_entry($ldap, $result); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -363,14 +365,14 @@ function ldap_first_entry($link_identifier, $result_identifier) * return large result sets, ldap_free_result could be * called to keep the runtime memory usage by the script low. * - * @param resource $result_identifier + * @param resource $result An LDAP\Result instance, returned by ldap_list or ldap_search. * @throws LdapException * */ -function ldap_free_result($result_identifier): void +function ldap_free_result($result): void { error_clear_last(); - $result = \ldap_free_result($result_identifier); + $result = \ldap_free_result($result); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -392,17 +394,17 @@ function ldap_free_result($result_identifier): void * * * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_entry_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $entry An LDAP\ResultEntry instance. * @return array Returns a complete entry information in a multi-dimensional array * on success and FALSE on error. * @throws LdapException * */ -function ldap_get_attributes($link_identifier, $result_entry_identifier): array +function ldap_get_attributes($ldap, $entry): array { error_clear_last(); - $result = \ldap_get_attributes($link_identifier, $result_entry_identifier); + $result = \ldap_get_attributes($ldap, $entry); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -413,16 +415,16 @@ function ldap_get_attributes($link_identifier, $result_entry_identifier): array /** * Finds out the DN of an entry in the result. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_entry_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $entry An LDAP\ResultEntry instance. * @return string Returns the DN of the result entry and FALSE on error. * @throws LdapException * */ -function ldap_get_dn($link_identifier, $result_entry_identifier): string +function ldap_get_dn($ldap, $entry): string { error_clear_last(); - $result = \ldap_get_dn($link_identifier, $result_entry_identifier); + $result = \ldap_get_dn($ldap, $entry); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -434,10 +436,10 @@ function ldap_get_dn($link_identifier, $result_entry_identifier): string * Reads multiple entries from the given result, and then reading the * attributes and multiple values. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $result An LDAP\Result instance, returned by ldap_list or ldap_search. * @return array Returns a complete result information in a multi-dimensional array on - * success and FALSE on error. + * success. * * The structure of the array is as follows. * The attribute index is converted to lowercase. (Attributes are @@ -451,10 +453,10 @@ function ldap_get_dn($link_identifier, $result_entry_identifier): string * @throws LdapException * */ -function ldap_get_entries($link_identifier, $result_identifier): array +function ldap_get_entries($ldap, $result): array { error_clear_last(); - $result = \ldap_get_entries($link_identifier, $result_identifier); + $result = \ldap_get_entries($ldap, $result); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -463,9 +465,9 @@ function ldap_get_entries($link_identifier, $result_identifier): array /** - * Sets retval to the value of the specified option. + * Sets value to the value of the specified option. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param int $option The parameter option can be one of: * * @@ -479,47 +481,47 @@ function ldap_get_entries($link_identifier, $result_identifier): array * * * LDAP_OPT_DEREF - * integer + * int * * * * LDAP_OPT_SIZELIMIT - * integer + * int * * * * LDAP_OPT_TIMELIMIT - * integer + * int * * * * LDAP_OPT_NETWORK_TIMEOUT - * integer + * int * * * * LDAP_OPT_PROTOCOL_VERSION - * integer + * int * * * * LDAP_OPT_ERROR_NUMBER - * integer + * int * * * * LDAP_OPT_DIAGNOSTIC_MESSAGE - * integer + * int * * * * LDAP_OPT_REFERRALS - * bool + * int * * * * LDAP_OPT_RESTART - * bool + * int * * * @@ -584,22 +586,22 @@ function ldap_get_entries($link_identifier, $result_identifier): array * * * LDAP_OPT_X_TLS_CRLCHECK - * integer + * int * 7.1 * * * LDAP_OPT_X_TLS_CRL_NONE - * integer + * int * 7.1 * * * LDAP_OPT_X_TLS_CRL_PEER - * integer + * int * 7.1 * * * LDAP_OPT_X_TLS_CRL_ALL - * integer + * int * 7.1 * * @@ -613,7 +615,7 @@ function ldap_get_entries($link_identifier, $result_identifier): array * 7.1 * * - * LDAP_OPT_X_TLS_KEYILE + * LDAP_OPT_X_TLS_KEYFILE * string * 7.1 * @@ -624,7 +626,7 @@ function ldap_get_entries($link_identifier, $result_identifier): array * * * LDAP_OPT_X_TLS_PROTOCOL_MIN - * integer + * int * 7.1 * * @@ -634,20 +636,20 @@ function ldap_get_entries($link_identifier, $result_identifier): array * * * LDAP_OPT_X_TLS_REQUIRE_CERT - * integer + * int * * * * * - * @param mixed $retval This will be set to the option value. + * @param mixed $value This will be set to the option value. * @throws LdapException * */ -function ldap_get_option($link_identifier, int $option, &$retval): void +function ldap_get_option($ldap, int $option, &$value = null): void { error_clear_last(); - $result = \ldap_get_option($link_identifier, $option, $retval); + $result = \ldap_get_option($ldap, $option, $value); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -660,8 +662,8 @@ function ldap_get_option($link_identifier, int $option, &$retval): void * This function is used exactly like ldap_get_values * except that it handles binary data and not string data. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_entry_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $entry An LDAP\ResultEntry instance. * @param string $attribute * @return array Returns an array of values for the attribute on success and FALSE on * error. Individual values are accessed by integer index in the array. The @@ -670,10 +672,10 @@ function ldap_get_option($link_identifier, int $option, &$retval): void * @throws LdapException * */ -function ldap_get_values_len($link_identifier, $result_entry_identifier, string $attribute): array +function ldap_get_values_len($ldap, $entry, string $attribute): array { error_clear_last(); - $result = \ldap_get_values_len($link_identifier, $result_entry_identifier, $attribute); + $result = \ldap_get_values_len($ldap, $entry, $attribute); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -684,7 +686,7 @@ function ldap_get_values_len($link_identifier, $result_entry_identifier, string /** * Reads all the values of the attribute in the entry in the result. * - * This call needs a result_entry_identifier, + * This call needs a entry, * so needs to be preceded by one of the ldap search calls and one * of the calls to get an individual entry. * @@ -693,8 +695,8 @@ function ldap_get_values_len($link_identifier, $result_entry_identifier, string * the ldap_get_attributes call to work out * what attributes exist for a given entry. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_entry_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $entry An LDAP\ResultEntry instance. * @param string $attribute * @return array Returns an array of values for the attribute on success and FALSE on * error. The number of values can be found by indexing "count" in the @@ -714,130 +716,10 @@ function ldap_get_values_len($link_identifier, $result_entry_identifier, string * @throws LdapException * */ -function ldap_get_values($link_identifier, $result_entry_identifier, string $attribute): array +function ldap_get_values($ldap, $entry, string $attribute): array { error_clear_last(); - $result = \ldap_get_values($link_identifier, $result_entry_identifier, $attribute); - if ($result === false) { - throw LdapException::createFromPhpError(); - } - return $result; -} - - -/** - * Performs the search for a specified filter on the - * directory with the scope LDAP_SCOPE_ONELEVEL. - * - * LDAP_SCOPE_ONELEVEL means that the search should only - * return information that is at the level immediately below the - * base_dn given in the call. - * (Equivalent to typing "ls" and getting a list of files and folders in the - * current working directory.) - * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param string $base_dn The base DN for the directory. - * @param string $filter - * @param array $attributes An array of the required attributes, e.g. array("mail", "sn", "cn"). - * Note that the "dn" is always returned irrespective of which attributes - * types are requested. - * - * Using this parameter is much more efficient than the default action - * (which is to return all attributes and their associated values). - * The use of this parameter should therefore be considered good - * practice. - * @param int $attrsonly Should be set to 1 if only attribute types are wanted. If set to 0 - * both attributes types and attribute values are fetched which is the - * default behaviour. - * @param int $sizelimit Enables you to limit the count of entries fetched. Setting this to 0 - * means no limit. - * - * This parameter can NOT override server-side preset sizelimit. You can - * set it lower though. - * - * Some directory server hosts will be configured to return no more than - * a preset number of entries. If this occurs, the server will indicate - * that it has only returned a partial results set. This also occurs if - * you use this parameter to limit the count of fetched entries. - * @param int $timelimit Sets the number of seconds how long is spend on the search. Setting - * this to 0 means no limit. - * - * This parameter can NOT override server-side preset timelimit. You can - * set it lower though. - * @param int $deref Specifies how aliases should be handled during the search. It can be - * one of the following: - * - * - * - * LDAP_DEREF_NEVER - (default) aliases are never - * dereferenced. - * - * - * - * - * LDAP_DEREF_SEARCHING - aliases should be - * dereferenced during the search but not when locating the base object - * of the search. - * - * - * - * - * LDAP_DEREF_FINDING - aliases should be - * dereferenced when locating the base object but not during the search. - * - * - * - * - * LDAP_DEREF_ALWAYS - aliases should be dereferenced - * always. - * - * - * - * @param array $serverctrls Array of LDAP Controls to send with the request. - * @return resource Returns a search result identifier. - * @throws LdapException - * - */ -function ldap_list($link_identifier, string $base_dn, string $filter, array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $serverctrls = null) -{ - error_clear_last(); - if ($serverctrls !== null) { - $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls); - } elseif ($deref !== LDAP_DEREF_NEVER) { - $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref); - } elseif ($timelimit !== -1) { - $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit); - } elseif ($sizelimit !== -1) { - $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit); - } elseif ($attrsonly !== 0) { - $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly); - } elseif ($attributes !== null) { - $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes); - } else { - $result = \ldap_list($link_identifier, $base_dn, $filter); - } - if ($result === false) { - throw LdapException::createFromPhpError(); - } - return $result; -} - - -/** - * Does the same thing as ldap_mod_add but returns the LDAP result resource to be parsed with ldap_parse_result. - * - * @param resource $link_identifier - * @param string $dn - * @param array $entry - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. - * @throws LdapException - * - */ -function ldap_mod_add_ext($link_identifier, string $dn, array $entry, array $serverctrls = null) -{ - error_clear_last(); - $result = \ldap_mod_add_ext($link_identifier, $dn, $entry, $serverctrls); + $result = \ldap_get_values($ldap, $entry, $attribute); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -849,42 +731,24 @@ function ldap_mod_add_ext($link_identifier, string $dn, array $entry, array $ser * Adds one or more attribute values to the specified dn. * To add a whole new object see ldap_add function. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry An associative array listing the attirbute values to add. If an attribute was not existing yet it will be added. If an attribute is existing you can only add values to it if it supports multiple values. - * @param array $serverctrls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_mod_add($link_identifier, string $dn, array $entry, array $serverctrls = null): void +function ldap_mod_add($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); - $result = \ldap_mod_add($link_identifier, $dn, $entry, $serverctrls); - if ($result === false) { - throw LdapException::createFromPhpError(); + if ($controls !== null) { + $result = \ldap_mod_add($ldap, $dn, $entry, $controls); + } else { + $result = \ldap_mod_add($ldap, $dn, $entry); } -} - - -/** - * Does the same thing as ldap_mod_del but returns the LDAP result resource to be parsed with ldap_parse_result. - * - * @param resource $link_identifier - * @param string $dn - * @param array $entry - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. - * @throws LdapException - * - */ -function ldap_mod_del_ext($link_identifier, string $dn, array $entry, array $serverctrls = null) -{ - error_clear_last(); - $result = \ldap_mod_del_ext($link_identifier, $dn, $entry, $serverctrls); if ($result === false) { throw LdapException::createFromPhpError(); } - return $result; } @@ -893,42 +757,24 @@ function ldap_mod_del_ext($link_identifier, string $dn, array $entry, array $ser * Object deletions are done by the * ldap_delete function. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry - * @param array $serverctrls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_mod_del($link_identifier, string $dn, array $entry, array $serverctrls = null): void +function ldap_mod_del($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); - $result = \ldap_mod_del($link_identifier, $dn, $entry, $serverctrls); - if ($result === false) { - throw LdapException::createFromPhpError(); + if ($controls !== null) { + $result = \ldap_mod_del($ldap, $dn, $entry, $controls); + } else { + $result = \ldap_mod_del($ldap, $dn, $entry); } -} - - -/** - * Does the same thing as ldap_mod_replace but returns the LDAP result resource to be parsed with ldap_parse_result. - * - * @param resource $link_identifier - * @param string $dn - * @param array $entry - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. - * @throws LdapException - * - */ -function ldap_mod_replace_ext($link_identifier, string $dn, array $entry, array $serverctrls = null) -{ - error_clear_last(); - $result = \ldap_mod_replace_ext($link_identifier, $dn, $entry, $serverctrls); if ($result === false) { throw LdapException::createFromPhpError(); } - return $result; } @@ -936,17 +782,21 @@ function ldap_mod_replace_ext($link_identifier, string $dn, array $entry, array * Replaces one or more attributes from the specified dn. * It may also add or remove attributes. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. * @param array $entry An associative array listing the attributes to replace. Sending an empty array as value will remove the attribute, while sending an attribute not existing yet on this entry will add it. - * @param array $serverctrls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_mod_replace($link_identifier, string $dn, array $entry, array $serverctrls = null): void +function ldap_mod_replace($ldap, string $dn, array $entry, array $controls = null): void { error_clear_last(); - $result = \ldap_mod_replace($link_identifier, $dn, $entry, $serverctrls); + if ($controls !== null) { + $result = \ldap_mod_replace($ldap, $dn, $entry, $controls); + } else { + $result = \ldap_mod_replace($ldap, $dn, $entry); + } if ($result === false) { throw LdapException::createFromPhpError(); } @@ -957,9 +807,9 @@ function ldap_mod_replace($link_identifier, string $dn, array $entry, array $ser * Modifies an existing entry in the LDAP directory. Allows detailed * specification of the modifications to perform. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP resource, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. - * @param array $entry An array that specifies the modifications to make. Each entry in this + * @param array $modifications_info An array that specifies the modifications to make. Each entry in this * array is an associative array with two or three keys: * attrib maps to the name of the attribute to modify, * modtype maps to the type of modification to perform, @@ -1032,16 +882,20 @@ function ldap_mod_replace($link_identifier, string $dn, array $entry, array $ser * value for values must be an array of strings, and * any value for modtype must be one of the * LDAP_MODIFY_BATCH_* constants listed above. - * @param array $serverctrls Each value specified through values is added (as + * @param array $controls Each value specified through values is added (as * an additional value) to the attribute named by * attrib. * @throws LdapException * */ -function ldap_modify_batch($link_identifier, string $dn, array $entry, array $serverctrls = null): void +function ldap_modify_batch($ldap, string $dn, array $modifications_info, array $controls = null): void { error_clear_last(); - $result = \ldap_modify_batch($link_identifier, $dn, $entry, $serverctrls); + if ($controls !== null) { + $result = \ldap_modify_batch($ldap, $dn, $modifications_info, $controls); + } else { + $result = \ldap_modify_batch($ldap, $dn, $modifications_info); + } if ($result === false) { throw LdapException::createFromPhpError(); } @@ -1051,20 +905,20 @@ function ldap_modify_batch($link_identifier, string $dn, array $entry, array $se /** * Retrieves the attributes in an entry. The first call to * ldap_next_attribute is made with the - * result_entry_identifier returned from + * entry returned from * ldap_first_attribute. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param resource $result_entry_identifier + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $entry An LDAP\ResultEntry instance. * @return string Returns the next attribute in an entry on success and FALSE on * error. * @throws LdapException * */ -function ldap_next_attribute($link_identifier, $result_entry_identifier): string +function ldap_next_attribute($ldap, $entry): string { error_clear_last(); - $result = \ldap_next_attribute($link_identifier, $result_entry_identifier); + $result = \ldap_next_attribute($ldap, $entry); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -1075,17 +929,17 @@ function ldap_next_attribute($link_identifier, $result_entry_identifier): string /** * Parse LDAP extended operation data from result object result * - * @param resource $link An LDAP link identifier, returned by ldap_connect. - * @param resource $result An LDAP result resource, returned by ldap_exop. - * @param string|null $retdata Will be filled by the response data. - * @param string|null $retoid Will be filled by the response OID. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $result An LDAP\Result instance, returned by ldap_list or ldap_search. + * @param string|null $response_data Will be filled by the response data. + * @param string|null $response_oid Will be filled by the response OID. * @throws LdapException * */ -function ldap_parse_exop($link, $result, ?string &$retdata = null, ?string &$retoid = null): void +function ldap_parse_exop($ldap, $result, ?string &$response_data = null, ?string &$response_oid = null): void { error_clear_last(); - $result = \ldap_parse_exop($link, $result, $retdata, $retoid); + $result = \ldap_parse_exop($ldap, $result, $response_data, $response_oid); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -1095,170 +949,52 @@ function ldap_parse_exop($link, $result, ?string &$retdata = null, ?string &$ret /** * Parses an LDAP search result. * - * @param resource $link An LDAP link identifier, returned by ldap_connect. - * @param resource $result An LDAP result resource, returned by ldap_list or - * ldap_search. - * @param int|null $errcode A reference to a variable that will be set to the LDAP error code in + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. + * @param resource $result An LDAP\Result instance, returned by ldap_list or ldap_search. + * @param int|null $error_code A reference to a variable that will be set to the LDAP error code in * the result, or 0 if no error occurred. - * @param string|null $matcheddn A reference to a variable that will be set to a matched DN if one was + * @param string|null $matched_dn A reference to a variable that will be set to a matched DN if one was * recognised within the request, otherwise it will be set to NULL. - * @param string|null $errmsg A reference to a variable that will be set to the LDAP error message in + * @param string|null $error_message A reference to a variable that will be set to the LDAP error message in * the result, or an empty string if no error occurred. * @param array|null $referrals A reference to a variable that will be set to an array set * to all of the referral strings in the result, or an empty array if no * referrals were returned. - * @param array|null $serverctrls An array of LDAP Controls which have been sent with the response. - * @throws LdapException - * - */ -function ldap_parse_result($link, $result, ?int &$errcode, ?string &$matcheddn = null, ?string &$errmsg = null, ?array &$referrals = null, ?array &$serverctrls = null): void -{ - error_clear_last(); - $result = \ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $serverctrls); - if ($result === false) { - throw LdapException::createFromPhpError(); - } -} - - -/** - * Performs the search for a specified filter on the - * directory with the scope LDAP_SCOPE_BASE. So it is - * equivalent to reading an entry from the directory. - * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param string $base_dn The base DN for the directory. - * @param string $filter An empty filter is not allowed. If you want to retrieve absolutely all - * information for this entry, use a filter of - * objectClass=*. If you know which entry types are - * used on the directory server, you might use an appropriate filter such - * as objectClass=inetOrgPerson. - * @param array $attributes An array of the required attributes, e.g. array("mail", "sn", "cn"). - * Note that the "dn" is always returned irrespective of which attributes - * types are requested. - * - * Using this parameter is much more efficient than the default action - * (which is to return all attributes and their associated values). - * The use of this parameter should therefore be considered good - * practice. - * @param int $attrsonly Should be set to 1 if only attribute types are wanted. If set to 0 - * both attributes types and attribute values are fetched which is the - * default behaviour. - * @param int $sizelimit Enables you to limit the count of entries fetched. Setting this to 0 - * means no limit. - * - * This parameter can NOT override server-side preset sizelimit. You can - * set it lower though. - * - * Some directory server hosts will be configured to return no more than - * a preset number of entries. If this occurs, the server will indicate - * that it has only returned a partial results set. This also occurs if - * you use this parameter to limit the count of fetched entries. - * @param int $timelimit Sets the number of seconds how long is spend on the search. Setting - * this to 0 means no limit. - * - * This parameter can NOT override server-side preset timelimit. You can - * set it lower though. - * @param int $deref Specifies how aliases should be handled during the search. It can be - * one of the following: - * - * - * - * LDAP_DEREF_NEVER - (default) aliases are never - * dereferenced. - * - * - * - * - * LDAP_DEREF_SEARCHING - aliases should be - * dereferenced during the search but not when locating the base object - * of the search. - * - * - * - * - * LDAP_DEREF_FINDING - aliases should be - * dereferenced when locating the base object but not during the search. - * - * - * - * - * LDAP_DEREF_ALWAYS - aliases should be dereferenced - * always. - * - * - * - * @param array $serverctrls Array of LDAP Controls to send with the request. - * @return resource Returns a search result identifier. - * @throws LdapException - * - */ -function ldap_read($link_identifier, string $base_dn, string $filter, array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $serverctrls = null) -{ - error_clear_last(); - if ($serverctrls !== null) { - $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls); - } elseif ($deref !== LDAP_DEREF_NEVER) { - $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref); - } elseif ($timelimit !== -1) { - $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit); - } elseif ($sizelimit !== -1) { - $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit); - } elseif ($attrsonly !== 0) { - $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly); - } elseif ($attributes !== null) { - $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes); - } else { - $result = \ldap_read($link_identifier, $base_dn, $filter); - } - if ($result === false) { - throw LdapException::createFromPhpError(); - } - return $result; -} - - -/** - * Does the same thing as ldap_rename but returns the LDAP result resource to be parsed with ldap_parse_result. - * - * @param resource $link_identifier - * @param string $dn - * @param string $newrdn - * @param string $newparent - * @param bool $deleteoldrdn - * @param array $serverctrls - * @return resource Returns an LDAP result identifier. + * @param array|null $controls An array of LDAP Controls which have been sent with the response. * @throws LdapException * */ -function ldap_rename_ext($link_identifier, string $dn, string $newrdn, string $newparent, bool $deleteoldrdn, array $serverctrls = null) +function ldap_parse_result($ldap, $result, ?int &$error_code, ?string &$matched_dn = null, ?string &$error_message = null, ?array &$referrals = null, ?array &$controls = null): void { error_clear_last(); - $result = \ldap_rename_ext($link_identifier, $dn, $newrdn, $newparent, $deleteoldrdn, $serverctrls); + $result = \ldap_parse_result($ldap, $result, $error_code, $matched_dn, $error_message, $referrals, $controls); if ($result === false) { throw LdapException::createFromPhpError(); } - return $result; } /** * The entry specified by dn is renamed/moved. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @param string $dn The distinguished name of an LDAP entity. - * @param string $newrdn The new RDN. - * @param string $newparent The new parent/superior entry. - * @param bool $deleteoldrdn If TRUE the old RDN value(s) is removed, else the old RDN value(s) + * @param string $new_rdn The new RDN. + * @param string $new_parent The new parent/superior entry. + * @param bool $delete_old_rdn If TRUE the old RDN value(s) is removed, else the old RDN value(s) * is retained as non-distinguished values of the entry. - * @param array $serverctrls Array of LDAP Controls to send with the request. + * @param array $controls Array of LDAP Controls to send with the request. * @throws LdapException * */ -function ldap_rename($link_identifier, string $dn, string $newrdn, string $newparent, bool $deleteoldrdn, array $serverctrls = null): void +function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, array $controls = null): void { error_clear_last(); - $result = \ldap_rename($link_identifier, $dn, $newrdn, $newparent, $deleteoldrdn, $serverctrls); + if ($controls !== null) { + $result = \ldap_rename($ldap, $dn, $new_rdn, $new_parent, $delete_old_rdn, $controls); + } else { + $result = \ldap_rename($ldap, $dn, $new_rdn, $new_parent, $delete_old_rdn); + } if ($result === false) { throw LdapException::createFromPhpError(); } @@ -1268,142 +1004,47 @@ function ldap_rename($link_identifier, string $dn, string $newrdn, string $newpa /** * * - * @param resource $link - * @param string $binddn + * @param resource $ldap + * @param string $dn * @param string $password - * @param string $sasl_mech - * @param string $sasl_realm - * @param string $sasl_authc_id - * @param string $sasl_authz_id + * @param string $mech + * @param string $realm + * @param string $authc_id + * @param string $authz_id * @param string $props * @throws LdapException * */ -function ldap_sasl_bind($link, string $binddn = null, string $password = null, string $sasl_mech = null, string $sasl_realm = null, string $sasl_authc_id = null, string $sasl_authz_id = null, string $props = null): void -{ - error_clear_last(); - $result = \ldap_sasl_bind($link, $binddn, $password, $sasl_mech, $sasl_realm, $sasl_authc_id, $sasl_authz_id, $props); - if ($result === false) { - throw LdapException::createFromPhpError(); - } -} - - -/** - * Performs the search for a specified filter on the directory with the scope - * of LDAP_SCOPE_SUBTREE. This is equivalent to searching - * the entire directory. - * - * From 4.0.5 on it's also possible to do parallel searches. To do this - * you use an array of link identifiers, rather than a single identifier, - * as the first argument. If you don't want the same base DN and the - * same filter for all the searches, you can also use an array of base DNs - * and/or an array of filters. Those arrays must be of the same size as - * the link identifier array since the first entries of the arrays are - * used for one search, the second entries are used for another, and so - * on. When doing parallel searches an array of search result - * identifiers is returned, except in case of error, then the entry - * corresponding to the search will be FALSE. This is very much like - * the value normally returned, except that a result identifier is always - * returned when a search was made. There are some rare cases where the - * normal search returns FALSE while the parallel search returns an - * identifier. - * - * @param resource|array $link_identifier An LDAP link identifier, returned by ldap_connect. - * @param string $base_dn The base DN for the directory. - * @param string $filter The search filter can be simple or advanced, using boolean operators in - * the format described in the LDAP documentation (see the Netscape Directory SDK or - * RFC4515 for full - * information on filters). - * @param array $attributes An array of the required attributes, e.g. array("mail", "sn", "cn"). - * Note that the "dn" is always returned irrespective of which attributes - * types are requested. - * - * Using this parameter is much more efficient than the default action - * (which is to return all attributes and their associated values). - * The use of this parameter should therefore be considered good - * practice. - * @param int $attrsonly Should be set to 1 if only attribute types are wanted. If set to 0 - * both attributes types and attribute values are fetched which is the - * default behaviour. - * @param int $sizelimit Enables you to limit the count of entries fetched. Setting this to 0 - * means no limit. - * - * This parameter can NOT override server-side preset sizelimit. You can - * set it lower though. - * - * Some directory server hosts will be configured to return no more than - * a preset number of entries. If this occurs, the server will indicate - * that it has only returned a partial results set. This also occurs if - * you use this parameter to limit the count of fetched entries. - * @param int $timelimit Sets the number of seconds how long is spend on the search. Setting - * this to 0 means no limit. - * - * This parameter can NOT override server-side preset timelimit. You can - * set it lower though. - * @param int $deref Specifies how aliases should be handled during the search. It can be - * one of the following: - * - * - * - * LDAP_DEREF_NEVER - (default) aliases are never - * dereferenced. - * - * - * - * - * LDAP_DEREF_SEARCHING - aliases should be - * dereferenced during the search but not when locating the base object - * of the search. - * - * - * - * - * LDAP_DEREF_FINDING - aliases should be - * dereferenced when locating the base object but not during the search. - * - * - * - * - * LDAP_DEREF_ALWAYS - aliases should be dereferenced - * always. - * - * - * - * @param array $serverctrls Array of LDAP Controls to send with the request. - * @return resource Returns a search result identifier. - * @throws LdapException - * - */ -function ldap_search($link_identifier, string $base_dn, string $filter, array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $serverctrls = null) +function ldap_sasl_bind($ldap, string $dn = null, string $password = null, string $mech = null, string $realm = null, string $authc_id = null, string $authz_id = null, string $props = null): void { error_clear_last(); - if ($serverctrls !== null) { - $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls); - } elseif ($deref !== LDAP_DEREF_NEVER) { - $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref); - } elseif ($timelimit !== -1) { - $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit); - } elseif ($sizelimit !== -1) { - $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit); - } elseif ($attrsonly !== 0) { - $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly); - } elseif ($attributes !== null) { - $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes); + if ($props !== null) { + $result = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id, $authz_id, $props); + } elseif ($authz_id !== null) { + $result = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id, $authz_id); + } elseif ($authc_id !== null) { + $result = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id); + } elseif ($realm !== null) { + $result = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm); + } elseif ($mech !== null) { + $result = \ldap_sasl_bind($ldap, $dn, $password, $mech); + } elseif ($password !== null) { + $result = \ldap_sasl_bind($ldap, $dn, $password); + } elseif ($dn !== null) { + $result = \ldap_sasl_bind($ldap, $dn); } else { - $result = \ldap_search($link_identifier, $base_dn, $filter); + $result = \ldap_sasl_bind($ldap); } if ($result === false) { throw LdapException::createFromPhpError(); } - return $result; } /** - * Sets the value of the specified option to be newval. + * Sets the value of the specified option to be value. * - * @param resource|null $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource|null $ldap An LDAP\Connection instance, returned by ldap_connect. * @param int $option The parameter option can be one of: * * @@ -1417,32 +1058,32 @@ function ldap_search($link_identifier, string $base_dn, string $filter, array $a * * * LDAP_OPT_DEREF - * integer + * int * * * * LDAP_OPT_SIZELIMIT - * integer + * int * * * * LDAP_OPT_TIMELIMIT - * integer + * int * * * * LDAP_OPT_NETWORK_TIMEOUT - * integer - * PHP 5.3.0 + * int + * * * * LDAP_OPT_PROTOCOL_VERSION - * integer + * int * * * * LDAP_OPT_ERROR_NUMBER - * integer + * int * * * @@ -1522,7 +1163,7 @@ function ldap_search($link_identifier, string $base_dn, string $filter, array $a * * * LDAP_OPT_X_TLS_CRLCHECK - * integer + * int * PHP 7.1.0 * * @@ -1542,7 +1183,7 @@ function ldap_search($link_identifier, string $base_dn, string $filter, array $a * * * LDAP_OPT_X_TLS_PROTOCOL_MIN - * integer + * int * PHP 7.1.0 * * @@ -1552,7 +1193,7 @@ function ldap_search($link_identifier, string $base_dn, string $filter, array $a * * * LDAP_OPT_X_TLS_REQUIRE_CERT - * integer + * int * PHP 7.0.5 * * @@ -1572,14 +1213,14 @@ function ldap_search($link_identifier, string $base_dn, string $filter, array $a * iscritical defaults to FALSE * if not supplied. See draft-ietf-ldapext-ldap-c-api-xx.txt * for details. See also the second example below. - * @param mixed $newval The new value for the specified option. + * @param mixed $value The new value for the specified option. * @throws LdapException * */ -function ldap_set_option($link_identifier, int $option, $newval): void +function ldap_set_option($ldap, int $option, $value): void { error_clear_last(); - $result = \ldap_set_option($link_identifier, $option, $newval); + $result = \ldap_set_option($ldap, $option, $value); if ($result === false) { throw LdapException::createFromPhpError(); } @@ -1589,14 +1230,14 @@ function ldap_set_option($link_identifier, int $option, $newval): void /** * Unbinds from the LDAP directory. * - * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect. + * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. * @throws LdapException * */ -function ldap_unbind($link_identifier): void +function ldap_unbind($ldap): void { error_clear_last(); - $result = \ldap_unbind($link_identifier); + $result = \ldap_unbind($ldap); if ($result === false) { throw LdapException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/libxml.php b/vendor/thecodingmachine/safe/generated/libxml.php index cef784c42..74925c123 100644 --- a/vendor/thecodingmachine/safe/generated/libxml.php +++ b/vendor/thecodingmachine/safe/generated/libxml.php @@ -25,11 +25,46 @@ function libxml_get_last_error(): \LibXMLError /** * 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 that takes three arguments. Two strings, a public id - * and system id, and a context (an array with four keys) as the third argument. - * This callback should return a resource, a string from which a resource can be - * opened, or NULL. + * @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 * */ diff --git a/vendor/thecodingmachine/safe/generated/mbstring.php b/vendor/thecodingmachine/safe/generated/mbstring.php index fa0829438..49622015f 100644 --- a/vendor/thecodingmachine/safe/generated/mbstring.php +++ b/vendor/thecodingmachine/safe/generated/mbstring.php @@ -5,21 +5,66 @@ 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 $cp - * @param string $encoding - * @return string Returns a specific character. + * @param int $codepoint A Unicode codepoint value, e.g. 128024 for U+1F418 ELEPHANT + * @param 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 $cp, string $encoding = null): string +function mb_chr(int $codepoint, string $encoding = null): string { error_clear_last(); if ($encoding !== null) { - $result = \mb_chr($cp, $encoding); + $result = \mb_chr($codepoint, $encoding); + } else { + $result = \mb_chr($codepoint); + } + if ($result === false) { + throw MbstringException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 string|array $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 string|array 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) { + $result = \mb_convert_encoding($string, $to_encoding, $from_encoding); } else { - $result = \mb_chr($cp); + $result = \mb_convert_encoding($string, $to_encoding); } if ($result === false) { throw MbstringException::createFromPhpError(); @@ -30,12 +75,12 @@ function mb_chr(int $cp, string $encoding = null): string /** * Sets the automatic character - * encoding detection order to encoding_list. + * encoding detection order to encoding. * - * @param mixed $encoding_list encoding_list is an array or + * @param mixed $encoding encoding is an array or * comma separated list of character encoding. See supported encodings. * - * If encoding_list is omitted, it returns + * If encoding is omitted or NULL, it returns * the current character encoding detection order as array. * * This setting affects mb_detect_encoding and @@ -57,11 +102,11 @@ function mb_chr(int $cp, string $encoding = null): string * @throws MbstringException * */ -function mb_detect_order($encoding_list = null) +function mb_detect_order($encoding = null) { error_clear_last(); - if ($encoding_list !== null) { - $result = \mb_detect_order($encoding_list); + if ($encoding !== null) { + $result = \mb_detect_order($encoding); } else { $result = \mb_detect_order(); } @@ -118,15 +163,21 @@ function mb_encoding_aliases(string $encoding): array * clutter the function namespace with a callback function's name * not used anywhere else. * @param string $string The string being checked. - * @param string $option The search option. See mb_regex_set_options for explanation. - * @return string The resultant string on success. + * @param string $options The search option. See mb_regex_set_options for explanation. + * @return string|null 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 $option = "msr"): string +function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $options = null): ?string { error_clear_last(); - $result = \mb_ereg_replace_callback($pattern, $callback, $string, $option); + if ($options !== null) { + $result = \mb_ereg_replace_callback($pattern, $callback, $string, $options); + } else { + $result = \mb_ereg_replace_callback($pattern, $callback, $string); + } if ($result === false) { throw MbstringException::createFromPhpError(); } @@ -142,15 +193,21 @@ function mb_ereg_replace_callback(string $pattern, callable $callback, string $s * Multibyte characters may be used in pattern. * @param string $replacement The replacement text. * @param string $string The string being checked. - * @param string $option - * @return string The resultant string on success. + * @param string $options + * @return string|null 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 $option = "msr"): string +function mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null): ?string { error_clear_last(); - $result = \mb_ereg_replace($pattern, $replacement, $string, $option); + if ($options !== null) { + $result = \mb_ereg_replace($pattern, $replacement, $string, $options); + } else { + $result = \mb_ereg_replace($pattern, $replacement, $string); + } if ($result === false) { throw MbstringException::createFromPhpError(); } @@ -186,15 +243,15 @@ function mb_ereg_search_getregs(): array * * @param string $string The search string. * @param string $pattern The search pattern. - * @param string $option The search option. See mb_regex_set_options for explanation. + * @param 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 $option = "msr"): void +function mb_ereg_search_init(string $string, string $pattern = null, string $options = null): void { error_clear_last(); - if ($option !== "msr") { - $result = \mb_ereg_search_init($string, $pattern, $option); + if ($options !== null) { + $result = \mb_ereg_search_init($string, $pattern, $options); } elseif ($pattern !== null) { $result = \mb_ereg_search_init($string, $pattern); } else { @@ -210,16 +267,16 @@ function mb_ereg_search_init(string $string, string $pattern = null, string $opt * Returns the matched part of a multibyte regular expression. * * @param string $pattern The search pattern. - * @param string $option The search option. See mb_regex_set_options for explanation. + * @param 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 $option = "ms"): array +function mb_ereg_search_regs(string $pattern = null, string $options = null): array { error_clear_last(); - if ($option !== "ms") { - $result = \mb_ereg_search_regs($pattern, $option); + if ($options !== null) { + $result = \mb_ereg_search_regs($pattern, $options); } elseif ($pattern !== null) { $result = \mb_ereg_search_regs($pattern); } else { @@ -235,14 +292,14 @@ function mb_ereg_search_regs(string $pattern = null, string $option = "ms"): arr /** * * - * @param int $position The position to set. If it is negative, it counts from the end of the string. + * @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 $position): void +function mb_ereg_search_setpos(int $offset): void { error_clear_last(); - $result = \mb_ereg_search_setpos($position); + $result = \mb_ereg_search_setpos($offset); if ($result === false) { throw MbstringException::createFromPhpError(); } @@ -253,17 +310,61 @@ function mb_ereg_search_setpos(int $position): void * * * @param string $pattern The regular expression pattern. Multibyte characters may be used. The case will be ignored. - * @param string $replace The replacement text. + * @param string $replacement The replacement text. * @param string $string The searched string. - * @param string $option + * @param 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) { + $result = \mb_eregi_replace($pattern, $replacement, $string, $options); + } else { + $result = \mb_eregi_replace($pattern, $replacement, $string); + } + if ($result === false) { + throw MbstringException::createFromPhpError(); + } + return $result; +} + + +/** + * + * + * @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_eregi_replace(string $pattern, string $replace, string $string, string $option = "msri"): string +function mb_get_info(string $type = "all") { error_clear_last(); - $result = \mb_eregi_replace($pattern, $replace, $string, $option); + $result = \mb_get_info($type); if ($result === false) { throw MbstringException::createFromPhpError(); } @@ -336,21 +437,25 @@ function mb_internal_encoding(string $encoding = null) /** + * Returns the Unicode code point value of the given character. * + * This function complements mb_chr. * - * @param string $str - * @param string $encoding - * @return int Returns a code point of character. + * @param string $string A string + * @param 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 $str, string $encoding = null): int +function mb_ord(string $string, string $encoding = null): int { error_clear_last(); if ($encoding !== null) { - $result = \mb_ord($str, $encoding); + $result = \mb_ord($string, $encoding); } else { - $result = \mb_ord($str); + $result = \mb_ord($string); } if ($result === false) { throw MbstringException::createFromPhpError(); @@ -367,15 +472,15 @@ function mb_ord(string $str, string $encoding = null): int * encoding and set values to the result array or * global variables. * - * @param string $encoded_string The URL encoded data. + * @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 $encoded_string, ?array &$result): void +function mb_parse_str(string $string, ?array &$result): void { error_clear_last(); - $result = \mb_parse_str($encoded_string, $result); + $result = \mb_parse_str($string, $result); if ($result === false) { throw MbstringException::createFromPhpError(); } @@ -386,7 +491,7 @@ function mb_parse_str(string $encoded_string, ?array &$result): void * Set/Get character encoding for a multibyte regex. * * @param string $encoding The encoding - * parameter is the character encoding. If it is omitted, the internal character + * parameter is the character encoding. If it is omitted or NULL, the internal character * encoding value will be used. * @return string|bool * @throws MbstringException @@ -444,7 +549,7 @@ function mb_regex_encoding(string $encoding = null) * 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 string $additional_parameter additional_parameter is a MTA command line + * @param string $additional_params additional_params is a MTA command line * parameter. It is useful when setting the correct Return-Path * header when using sendmail. * @@ -464,10 +569,14 @@ function mb_regex_encoding(string $encoding = null) * @throws MbstringException * */ -function mb_send_mail(string $to, string $subject, string $message, $additional_headers = null, string $additional_parameter = null): void +function mb_send_mail(string $to, string $subject, string $message, $additional_headers = [], string $additional_params = null): void { error_clear_last(); - $result = \mb_send_mail($to, $subject, $message, $additional_headers, $additional_parameter); + if ($additional_params !== null) { + $result = \mb_send_mail($to, $subject, $message, $additional_headers, $additional_params); + } else { + $result = \mb_send_mail($to, $subject, $message, $additional_headers); + } if ($result === false) { throw MbstringException::createFromPhpError(); } @@ -493,34 +602,3 @@ function mb_split(string $pattern, string $string, int $limit = -1): array } return $result; } - - -/** - * This function will return an array of strings, it is a version of str_split with support for encodings of variable character size as well as fixed-size encodings of 1,2 or 4 byte characters. - * If the split_length parameter is specified, the string is broken down into chunks of the specified length in characters (not bytes). - * The encoding parameter can be optionally specified and it is good practice to do so. - * - * @param string $string The string to split into characters or chunks. - * @param int $split_length If specified, each element of the returned array will be composed of multiple characters instead of a single character. - * @param string $encoding The encoding - * parameter is the character encoding. If it is omitted, the internal character - * encoding value will be used. - * - * A string specifying one of the supported encodings. - * @return array mb_str_split returns an array of strings. - * @throws MbstringException - * - */ -function mb_str_split(string $string, int $split_length = 1, string $encoding = null): array -{ - error_clear_last(); - if ($encoding !== null) { - $result = \mb_str_split($string, $split_length, $encoding); - } else { - $result = \mb_str_split($string, $split_length); - } - if ($result === false) { - throw MbstringException::createFromPhpError(); - } - return $result; -} diff --git a/vendor/thecodingmachine/safe/generated/misc.php b/vendor/thecodingmachine/safe/generated/misc.php index ff636fd49..31ca61584 100644 --- a/vendor/thecodingmachine/safe/generated/misc.php +++ b/vendor/thecodingmachine/safe/generated/misc.php @@ -7,14 +7,14 @@ use Safe\Exceptions\MiscException; /** * Defines a named constant at runtime. * - * @param string $name The name of the constant. + * @param string $constant_name The name of the constant. * * It is possible to define constants with reserved or * even invalid names, whose value can (only) be retrieved with * constant. However, doing so is not recommended. * @param mixed $value The value of the constant. In PHP 5, value must - * be a scalar value (integer, - * float, string, boolean, or + * be a scalar value (int, + * float, string, bool, or * NULL). In PHP 7, array values are also accepted. * * While it is possible to define resource constants, it is @@ -28,10 +28,10 @@ use Safe\Exceptions\MiscException; * @throws MiscException * */ -function define(string $name, $value, bool $case_insensitive = false): void +function define(string $constant_name, $value, bool $case_insensitive = false): void { error_clear_last(); - $result = \define($name, $value, $case_insensitive); + $result = \define($constant_name, $value, $case_insensitive); if ($result === false) { throw MiscException::createFromPhpError(); } @@ -72,7 +72,7 @@ function highlight_file(string $filename, bool $return = false) /** * * - * @param string $str The PHP code to be highlighted. This should include the opening tag. + * @param string $string The PHP code to be highlighted. This should include the opening tag. * @param bool $return Set this parameter to TRUE to make this function return the * highlighted code. * @return string|bool If return is set to TRUE, returns the highlighted @@ -81,10 +81,34 @@ function highlight_file(string $filename, bool $return = false) * @throws MiscException * */ -function highlight_string(string $str, bool $return = false) +function highlight_string(string $string, bool $return = false) { error_clear_last(); - $result = \highlight_string($str, $return); + $result = \highlight_string($string, $return); + if ($result === false) { + throw MiscException::createFromPhpError(); + } + return $result; +} + + +/** + * + * + * @param bool $as_number Whether the high resolution time should be returned as array + * or number. + * @return array{0:int,1:int}|int|float Returns an array of integers in the form [seconds, nanoseconds], if the + * parameter as_number is false. Otherwise the nanoseconds + * are returned as int (64bit platforms) or float + * (32bit platforms). + * Returns FALSE on failure. + * @throws MiscException + * + */ +function hrtime(bool $as_number = false) +{ + error_clear_last(); + $result = \hrtime($as_number); if ($result === false) { throw MiscException::createFromPhpError(); } @@ -232,7 +256,7 @@ function highlight_string(string $str, bool $return = false) * * * Z - * NUL-padded string (new in PHP 5.5) + * NUL-padded string * * * @ @@ -241,16 +265,16 @@ function highlight_string(string $str, bool $return = false) * * * - * @param mixed $params + * @param mixed $values * @return string Returns a binary string containing data. * @throws MiscException * */ -function pack(string $format, ...$params): string +function pack(string $format, ...$values): string { error_clear_last(); - if ($params !== []) { - $result = \pack($format, ...$params); + if ($values !== []) { + $result = \pack($format, ...$values); } else { $result = \pack($format); } @@ -288,14 +312,14 @@ function sapi_windows_cp_conv($in_codepage, $out_codepage, string $subject): str /** * Set the codepage of the current process. * - * @param int $cp A codepage identifier. + * @param int $codepage A codepage identifier. * @throws MiscException * */ -function sapi_windows_cp_set(int $cp): void +function sapi_windows_cp_set(int $codepage): void { error_clear_last(); - $result = \sapi_windows_cp_set($cp); + $result = \sapi_windows_cp_set($codepage); if ($result === false) { throw MiscException::createFromPhpError(); } @@ -324,9 +348,50 @@ function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): void /** - * If enable is omitted, the function returns TRUE if the stream stream has VT100 control codes enabled, FALSE otherwise. + * Sets or removes a CTRL event handler, which allows Windows + * CLI processes to intercept or ignore CTRL+C and + * CTRL+BREAK events. Note that in multithreaded environments, + * this is only possible when called from the main thread. + * + * @param $handler A callback function to set or remove. If set, this function will be called + * whenever a CTRL+C or CTRL+BREAK event + * occurs. The function is supposed to have the following signature: + * + * voidhandler + * intevent + * + * + * + * event + * + * + * The CTRL event which has been received; + * either PHP_WINDOWS_EVENT_CTRL_C + * or PHP_WINDOWS_EVENT_CTRL_BREAK. + * + * + * + * + * Setting a NULL handler causes the process to ignore + * CTRL+C events, but not CTRL+BREAK events. + * @param bool $add + * @throws MiscException + * + */ +function sapi_windows_set_ctrl_handler($handler, bool $add = true): void +{ + error_clear_last(); + $result = \sapi_windows_set_ctrl_handler($handler, $add); + if ($result === false) { + throw MiscException::createFromPhpError(); + } +} + + +/** + * If enable is NULL, the function returns TRUE if the stream stream has VT100 control codes enabled, FALSE otherwise. * - * If enable is specified, the function will try to enable or disable the VT100 features of the stream stream. + * If enable is a bool, the function will try to enable or disable the VT100 features of the stream stream. * If the feature has been successfully enabled (or disabled). * * At startup, PHP tries to enable the VT100 feature of the STDOUT/STDERR streams. By the way, if those streams are redirected to a file, the VT100 features may not be enabled. @@ -335,7 +400,7 @@ function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): void * They allow the modification of the terminal's output. On Windows these sequences are called Console Virtual Terminal Sequences. * * @param resource $stream The stream on which the function will operate. - * @param bool $enable If specified, the VT100 feature will be enabled (if TRUE) or disabled (if FALSE). + * @param bool $enable If bool, the VT100 feature will be enabled (if TRUE) or disabled (if FALSE). * @throws MiscException * */ @@ -385,7 +450,7 @@ function sleep(int $seconds): int * * @param int $seconds Must be a non-negative integer. * @param int $nanoseconds Must be a non-negative integer less than 1 billion. - * @return array{0:int,1:int}|bool Returns TRUE on success. + * @return array{0:0|positive-int,1:0|positive-int}|bool Returns TRUE on success. * * If the delay was interrupted by a signal, an associative array will be * returned with the components: @@ -445,18 +510,33 @@ function time_sleep_until(float $timestamp): void * then each of the array keys will have a sequence number behind * the given name. * + * Changes were made to bring this function into line with Perl: + * + * + * The "a" code now retains trailing NULL bytes. + * + * + * The "A" code now strips all trailing ASCII whitespace (spaces, tabs, + * newlines, carriage returns, and NULL bytes). + * + * + * The "Z" code was added for NULL-padded strings, and removes trailing + * NULL bytes. + * + * + * * @param string $format See pack for an explanation of the format codes. - * @param string $data The packed data. + * @param string $string The packed data. * @param int $offset The offset to begin unpacking from. * @return array Returns an associative array containing unpacked elements of binary * string. * @throws MiscException * */ -function unpack(string $format, string $data, int $offset = 0): array +function unpack(string $format, string $string, int $offset = 0): array { error_clear_last(); - $result = \unpack($format, $data, $offset); + $result = \unpack($format, $string, $offset); if ($result === false) { throw MiscException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/msql.php b/vendor/thecodingmachine/safe/generated/msql.php deleted file mode 100644 index 331c1b6cd..000000000 --- a/vendor/thecodingmachine/safe/generated/msql.php +++ /dev/null @@ -1,443 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\MsqlException; - -/** - * Returns number of affected rows by the last SELECT, UPDATE or DELETE - * query associated with result. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @return int Returns the number of affected rows on success. - * @throws MsqlException - * - */ -function msql_affected_rows($result): int -{ - error_clear_last(); - $result = \msql_affected_rows($result); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_close closes the non-persistent connection to - * the mSQL server that's associated with the specified link identifier. - * - * Using msql_close isn't usually necessary, as - * non-persistent open links are automatically closed at the end of the - * script's execution. See also freeing resources. - * - * @param resource|null $link_identifier The mSQL connection. - * If not specified, the last link opened by msql_connect - * is assumed. If no such link is found, the function will try to establish a - * link as if msql_connect was called, and use it. - * @throws MsqlException - * - */ -function msql_close($link_identifier = null): void -{ - error_clear_last(); - if ($link_identifier !== null) { - $result = \msql_close($link_identifier); - } else { - $result = \msql_close(); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} - - -/** - * msql_connect establishes a connection to a mSQL - * server. - * - * If a second call is made to msql_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 - * msql_close. - * - * @param string $hostname The hostname can also include a port number. e.g. - * hostname,port. - * - * If not specified, the connection is established by the means of a Unix - * domain socket, being then more efficient then a localhost TCP socket - * connection. - * - * While this function will accept a colon (:) as a - * host/port separator, a comma (,) is the preferred - * method. - * @return resource Returns a positive mSQL link identifier on success. - * @throws MsqlException - * - */ -function msql_connect(string $hostname = null) -{ - error_clear_last(); - if ($hostname !== null) { - $result = \msql_connect($hostname); - } else { - $result = \msql_connect(); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_create_db attempts to create a new database on - * the mSQL server. - * - * @param string $database_name The name of the mSQL database. - * @param resource|null $link_identifier The mSQL connection. - * If not specified, the last link opened by msql_connect - * is assumed. If no such link is found, the function will try to establish a - * link as if msql_connect was called, and use it. - * @throws MsqlException - * - */ -function msql_create_db(string $database_name, $link_identifier = null): void -{ - error_clear_last(); - if ($link_identifier !== null) { - $result = \msql_create_db($database_name, $link_identifier); - } else { - $result = \msql_create_db($database_name); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} - - -/** - * msql_data_seek moves the internal row - * pointer of the mSQL result associated with the specified query - * identifier to point to the specified row number. The next call - * to msql_fetch_row would return that - * row. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @param int $row_number The seeked row number. - * @throws MsqlException - * - */ -function msql_data_seek($result, int $row_number): void -{ - error_clear_last(); - $result = \msql_data_seek($result, $row_number); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} - - -/** - * msql_db_query selects a database and executes a query - * on it. - * - * @param string $database The name of the mSQL database. - * @param string $query The SQL query. - * @param resource|null $link_identifier The mSQL connection. - * If not specified, the last link opened by msql_connect - * is assumed. If no such link is found, the function will try to establish a - * link as if msql_connect was called, and use it. - * @return resource Returns a positive mSQL query identifier to the query result. - * @throws MsqlException - * - */ -function msql_db_query(string $database, string $query, $link_identifier = null) -{ - error_clear_last(); - if ($link_identifier !== null) { - $result = \msql_db_query($database, $query, $link_identifier); - } else { - $result = \msql_db_query($database, $query); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_drop_db attempts to drop (remove) a database - * from the mSQL server. - * - * @param string $database_name The name of the database. - * @param resource|null $link_identifier The mSQL connection. - * If not specified, the last link opened by msql_connect - * is assumed. If no such link is found, the function will try to establish a - * link as if msql_connect was called, and use it. - * @throws MsqlException - * - */ -function msql_drop_db(string $database_name, $link_identifier = null): void -{ - error_clear_last(); - if ($link_identifier !== null) { - $result = \msql_drop_db($database_name, $link_identifier); - } else { - $result = \msql_drop_db($database_name); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} - - -/** - * msql_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 - * msql_query. - * @param int $field_offset The numerical field offset. The - * field_offset starts at 1. - * @return int Returns the length of the specified field. - * @throws MsqlException - * - */ -function msql_field_len($result, int $field_offset): int -{ - error_clear_last(); - $result = \msql_field_len($result, $field_offset); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_field_name gets the name of the specified field - * index. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @param int $field_offset The numerical field offset. The - * field_offset starts at 1. - * @return string The name of the field. - * @throws MsqlException - * - */ -function msql_field_name($result, int $field_offset): string -{ - error_clear_last(); - $result = \msql_field_name($result, $field_offset); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * Seeks to the specified field offset. If the next call to - * msql_fetch_field won't include a field offset, this - * field would be returned. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @param int $field_offset The numerical field offset. The - * field_offset starts at 1. - * @throws MsqlException - * - */ -function msql_field_seek($result, int $field_offset): void -{ - error_clear_last(); - $result = \msql_field_seek($result, $field_offset); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} - - -/** - * Returns the name of the table that the specified field is in. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @param int $field_offset The numerical field offset. The - * field_offset starts at 1. - * @return int The name of the table on success. - * @throws MsqlException - * - */ -function msql_field_table($result, int $field_offset): int -{ - error_clear_last(); - $result = \msql_field_table($result, $field_offset); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_field_type gets the type of the specified field - * index. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @param int $field_offset The numerical field offset. The - * field_offset starts at 1. - * @return string The type of the field. One of int, - * char, real, ident, - * null or unknown. This functions will - * return FALSE on failure. - * @throws MsqlException - * - */ -function msql_field_type($result, int $field_offset): string -{ - error_clear_last(); - $result = \msql_field_type($result, $field_offset); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_free_result frees the memory associated - * with query_identifier. When PHP completes a - * request, this memory is freed automatically, so you only need to - * call this function when you want to make sure you don't use too - * much memory while the script is running. - * - * @param resource $result The result resource that - * is being evaluated. This result comes from a call to - * msql_query. - * @throws MsqlException - * - */ -function msql_free_result($result): void -{ - error_clear_last(); - $result = \msql_free_result($result); - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} - - -/** - * msql_pconnect acts very much like - * msql_connect with two major differences. - * - * First, when connecting, the function would first try to find a - * (persistent) link that's already open with the same host. - * If one is found, an identifier for it will be returned instead of opening - * a new connection. - * - * Second, the connection to the SQL server will not be closed when the - * execution of the script ends. Instead, the link will remain open for - * future use (msql_close will not close links - * established by this function). - * - * @param string $hostname The hostname can also include a port number. e.g. - * hostname,port. - * - * If not specified, the connection is established by the means of a Unix - * domain socket, being more efficient than a localhost TCP socket - * connection. - * @return resource Returns a positive mSQL link identifier on success. - * @throws MsqlException - * - */ -function msql_pconnect(string $hostname = null) -{ - error_clear_last(); - if ($hostname !== null) { - $result = \msql_pconnect($hostname); - } else { - $result = \msql_pconnect(); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_query sends a query to the currently active - * database on the server that's associated with the specified link - * identifier. - * - * @param string $query The SQL query. - * @param resource|null $link_identifier The mSQL connection. - * If not specified, the last link opened by msql_connect - * is assumed. If no such link is found, the function will try to establish a - * link as if msql_connect was called, and use it. - * @return resource Returns a positive mSQL query identifier on success. - * @throws MsqlException - * - */ -function msql_query(string $query, $link_identifier = null) -{ - error_clear_last(); - if ($link_identifier !== null) { - $result = \msql_query($query, $link_identifier); - } else { - $result = \msql_query($query); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * msql_select_db sets the current active database on - * the server that's associated with the specified - * link_identifier. - * - * Subsequent calls to msql_query will be made on the - * active database. - * - * @param string $database_name The database name. - * @param resource|null $link_identifier The mSQL connection. - * If not specified, the last link opened by msql_connect - * is assumed. If no such link is found, the function will try to establish a - * link as if msql_connect was called, and use it. - * @throws MsqlException - * - */ -function msql_select_db(string $database_name, $link_identifier = null): void -{ - error_clear_last(); - if ($link_identifier !== null) { - $result = \msql_select_db($database_name, $link_identifier); - } else { - $result = \msql_select_db($database_name); - } - if ($result === false) { - throw MsqlException::createFromPhpError(); - } -} diff --git a/vendor/thecodingmachine/safe/generated/mysqli.php b/vendor/thecodingmachine/safe/generated/mysqli.php deleted file mode 100644 index c8807af4a..000000000 --- a/vendor/thecodingmachine/safe/generated/mysqli.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\MysqliException; - -/** - * Returns an empty array. - * Available only with mysqlnd. - * - * @return array Returns an empty array on success, FALSE otherwise. - * @throws MysqliException - * - */ -function mysqli_get_cache_stats(): array -{ - error_clear_last(); - $result = \mysqli_get_cache_stats(); - if ($result === false) { - throw MysqliException::createFromPhpError(); - } - return $result; -} - - -/** - * Returns client per-process statistics. - * Available only with mysqlnd. - * - * @return array Returns an array with client stats if success, FALSE otherwise. - * @throws MysqliException - * - */ -function mysqli_get_client_stats(): array -{ - error_clear_last(); - $result = \mysqli_get_client_stats(); - if ($result === false) { - throw MysqliException::createFromPhpError(); - } - return $result; -} diff --git a/vendor/thecodingmachine/safe/generated/mysqlndMs.php b/vendor/thecodingmachine/safe/generated/mysqlndMs.php deleted file mode 100644 index 2fd4f32a2..000000000 --- a/vendor/thecodingmachine/safe/generated/mysqlndMs.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\MysqlndMsException; - -/** - * Returns a list of currently configured servers. - * - * @param mixed $connection A MySQL connection handle obtained from any of the - * connect functions of the mysqli, - * mysql or - * PDO_MYSQL extensions. - * @return array FALSE on error. Otherwise, returns an array with two entries - * masters and slaves each of which contains - * an array listing all corresponding servers. - * - * The function can be used to check and debug the list of servers currently - * used by the plugin. It is mostly useful when the list of servers changes at - * runtime, for example, when using MySQL Fabric. - * - * masters and slaves server entries - * @throws MysqlndMsException - * - */ -function mysqlnd_ms_dump_servers($connection): array -{ - error_clear_last(); - $result = \mysqlnd_ms_dump_servers($connection); - if ($result === false) { - throw MysqlndMsException::createFromPhpError(); - } - return $result; -} - - -/** - * MySQL Fabric related. - * - * Switch the connection to the nodes handling global sharding queries - * for the given table name. - * - * @param mixed $connection A MySQL connection handle obtained from any of the - * connect functions of the mysqli, - * mysql or - * PDO_MYSQL extensions. - * @param mixed $table_name The table name to ask Fabric about. - * @return array FALSE on error. Otherwise, TRUE - * @throws MysqlndMsException - * - */ -function mysqlnd_ms_fabric_select_global($connection, $table_name): array -{ - error_clear_last(); - $result = \mysqlnd_ms_fabric_select_global($connection, $table_name); - if ($result === false) { - throw MysqlndMsException::createFromPhpError(); - } - return $result; -} - - -/** - * MySQL Fabric related. - * - * Switch the connection to the shards responsible for the - * given table name and shard key. - * - * @param mixed $connection A MySQL connection handle obtained from any of the - * connect functions of the mysqli, - * mysql or - * PDO_MYSQL extensions. - * @param mixed $table_name The table name to ask Fabric about. - * @param mixed $shard_key The shard key to ask Fabric about. - * @return array FALSE on error. Otherwise, TRUE - * @throws MysqlndMsException - * - */ -function mysqlnd_ms_fabric_select_shard($connection, $table_name, $shard_key): array -{ - error_clear_last(); - $result = \mysqlnd_ms_fabric_select_shard($connection, $table_name, $shard_key); - if ($result === false) { - throw MysqlndMsException::createFromPhpError(); - } - return $result; -} - - -/** - * Returns an array which describes the last used connection from the plugins - * connection pool currently pointed to by the user connection handle. If using the - * plugin, a user connection handle represents a pool of database connections. - * It is not possible to tell from the user connection handles properties to which - * database server from the pool the user connection handle points. - * - * The function can be used to debug or monitor PECL mysqlnd_ms. - * - * @param mixed $connection A MySQL connection handle obtained from any of the - * connect functions of the mysqli, - * mysql or - * PDO_MYSQL extensions. - * @return array FALSE on error. Otherwise, an - * array which describes the connection used to - * execute the last statement on. - * - * Array which describes the connection. - * @throws MysqlndMsException - * - */ -function mysqlnd_ms_get_last_used_connection($connection): array -{ - error_clear_last(); - $result = \mysqlnd_ms_get_last_used_connection($connection); - if ($result === false) { - throw MysqlndMsException::createFromPhpError(); - } - return $result; -} diff --git a/vendor/thecodingmachine/safe/generated/mysqlndQc.php b/vendor/thecodingmachine/safe/generated/mysqlndQc.php deleted file mode 100644 index 9a99a379c..000000000 --- a/vendor/thecodingmachine/safe/generated/mysqlndQc.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\MysqlndQcException; - -/** - * Flush all cache contents. - * - * Flushing the cache is a storage handler responsibility. - * All built-in storage handler but the - * memcache storage - * handler support flushing the cache. The - * memcache - * storage handler cannot flush its cache contents. - * - * User-defined storage handler may or may not support the operation. - * - * @throws MysqlndQcException - * - */ -function mysqlnd_qc_clear_cache(): void -{ - error_clear_last(); - $result = \mysqlnd_qc_clear_cache(); - if ($result === false) { - throw MysqlndQcException::createFromPhpError(); - } -} - - -/** - * Installs a callback which decides whether a statement is cached. - * - * There are several ways of hinting PELC/mysqlnd_qc to cache a query. - * By default, PECL/mysqlnd_qc attempts to cache a if caching of all statements - * is enabled or the query string begins with a certain SQL hint. - * The plugin internally calls a function named is_select() - * to find out. This internal function can be replaced with a user-defined callback. - * Then, the user-defined callback is responsible to decide whether the plugin - * attempts to cache a statement. Because the internal function is replaced - * with the callback, the callback gains full control. The callback is free - * to ignore the configuration setting mysqlnd_qc.cache_by_default - * and SQL hints. - * - * The callback is invoked for every statement inspected by the plugin. - * It is given the statements string as a parameter. The callback returns - * FALSE if the statement shall not be cached. It returns TRUE to - * make the plugin attempt to cache the statements result set, if any. - * A so-created cache entry is given the default TTL set with the - * PHP configuration directive mysqlnd_qc.ttl. - * If a different TTL shall be used, the callback returns a numeric - * value to be used as the TTL. - * - * The internal is_select function is part of the internal - * cache storage handler interface. Thus, a user-defined storage handler - * offers the same capabilities. - * - * @param string $callback - * @return mixed Returns TRUE on success. - * @throws MysqlndQcException - * - */ -function mysqlnd_qc_set_is_select(string $callback) -{ - error_clear_last(); - $result = \mysqlnd_qc_set_is_select($callback); - if ($result === false) { - throw MysqlndQcException::createFromPhpError(); - } - return $result; -} - - -/** - * Sets the storage handler used by the query cache. A list of available - * storage handler can be obtained from - * mysqlnd_qc_get_available_handlers. - * Which storage are available depends on the compile time - * configuration of the query cache plugin. The - * default storage handler is always available. - * All other storage handler must be enabled explicitly when building the - * extension. - * - * @param string $handler Handler can be of type string representing the name of a - * built-in storage handler or an object of type - * mysqlnd_qc_handler_default. - * The names of the built-in storage handler are - * default, - * APC, - * MEMCACHE, - * sqlite. - * @throws MysqlndQcException - * - */ -function mysqlnd_qc_set_storage_handler(string $handler): void -{ - error_clear_last(); - $result = \mysqlnd_qc_set_storage_handler($handler); - if ($result === false) { - throw MysqlndQcException::createFromPhpError(); - } -} diff --git a/vendor/thecodingmachine/safe/generated/network.php b/vendor/thecodingmachine/safe/generated/network.php index 6d46b6ce3..21186d1fa 100644 --- a/vendor/thecodingmachine/safe/generated/network.php +++ b/vendor/thecodingmachine/safe/generated/network.php @@ -53,10 +53,11 @@ function closelog(): void * always return every record, the slower DNS_ALL * will collect all records more reliably. * - * DNS_CAA is not supported on Windows. - * @param array|null $authns Passed by reference and, if given, will be populated with Resource + * Windows: DNS_CAA is not supported. + * Support for DNS_A6 is not implemented. + * @param array|null $authoritative_name_servers Passed by reference and, if given, will be populated with Resource * Records for the Authoritative Name Servers. - * @param array|null $addtl Passed by reference and, if given, will be populated with any + * @param array|null $additional_records Passed by reference and, if given, will be populated with any * Additional Records. * @param bool $raw The type will be interpreted as a raw DNS type ID * (the DNS_* constants cannot be used). @@ -208,7 +209,7 @@ function closelog(): void * * * - * A6(PHP >= 5.1.0) + * A6 * * masklen: Length (in bits) to inherit from the target * specified by chain. @@ -245,10 +246,10 @@ function closelog(): void * @throws NetworkException * */ -function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authns = null, ?array &$addtl = null, bool $raw = false): array +function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authoritative_name_servers = null, ?array &$additional_records = null, bool $raw = false): array { error_clear_last(); - $result = \dns_get_record($hostname, $type, $authns, $addtl, $raw); + $result = \dns_get_record($hostname, $type, $authoritative_name_servers, $additional_records, $raw); if ($result === false) { throw NetworkException::createFromPhpError(); } @@ -280,16 +281,17 @@ function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authns = * @param int $port The port number. This can be omitted and skipped with * -1 for transports that do not use ports, such as * unix://. - * @param int|null $errno If provided, holds the system level error number that occurred in the + * @param int|null $error_code If provided, holds the system level error number that occurred in the * system-level connect() call. * - * If the value returned in errno is + * If the value returned in error_code is * 0 and the function returned FALSE, it is an * indication that the error occurred before the * connect() call. This is most likely due to a * problem initializing the socket. - * @param string|null $errstr The error message as a string. - * @param float $timeout The connection timeout, in seconds. + * @param string|null $error_message The error message as a string. + * @param float $timeout The connection timeout, in seconds. When NULL, the + * default_socket_timeout php.ini setting is used. * * If you need to set a timeout for reading/writing data over the * socket, use stream_set_timeout, as the @@ -304,13 +306,13 @@ function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authns = * @throws NetworkException * */ -function fsockopen(string $hostname, int $port = -1, ?int &$errno = null, ?string &$errstr = null, float $timeout = null) +function fsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null) { error_clear_last(); if ($timeout !== null) { - $result = \fsockopen($hostname, $port, $errno, $errstr, $timeout); + $result = \fsockopen($hostname, $port, $error_code, $error_message, $timeout); } else { - $result = \fsockopen($hostname, $port, $errno, $errstr); + $result = \fsockopen($hostname, $port, $error_code, $error_message); } if ($result === false) { throw NetworkException::createFromPhpError(); @@ -341,18 +343,18 @@ function gethostname(): string /** * getprotobyname returns the protocol number - * associated with the protocol name as per + * associated with the protocol protocol as per * /etc/protocols. * - * @param string $name The protocol name. + * @param string $protocol The protocol name. * @return int Returns the protocol number. * @throws NetworkException * */ -function getprotobyname(string $name): int +function getprotobyname(string $protocol): int { error_clear_last(); - $result = \getprotobyname($name); + $result = \getprotobyname($protocol); if ($result === false) { throw NetworkException::createFromPhpError(); } @@ -362,18 +364,41 @@ function getprotobyname(string $name): int /** * getprotobynumber returns the protocol name - * associated with protocol number as per + * associated with protocol protocol as per * /etc/protocols. * - * @param int $number The protocol number. + * @param int $protocol The protocol number. * @return string Returns the protocol name as a string. * @throws NetworkException * */ -function getprotobynumber(int $number): string +function getprotobynumber(int $protocol): string { error_clear_last(); - $result = \getprotobynumber($number); + $result = \getprotobynumber($protocol); + if ($result === false) { + throw NetworkException::createFromPhpError(); + } + return $result; +} + + +/** + * getservbyport returns the Internet service + * associated with port for the specified + * protocol as per /etc/services. + * + * @param int $port The port number. + * @param string $protocol protocol is either "tcp" + * or "udp" (in lowercase). + * @return string Returns the Internet service name as a string. + * @throws NetworkException + * + */ +function getservbyport(int $port, string $protocol): string +{ + error_clear_last(); + $result = \getservbyport($port, $protocol); if ($result === false) { throw NetworkException::createFromPhpError(); } @@ -406,15 +431,141 @@ function header_register_callback(callable $callback): void /** * * - * @param string $in_addr A 32bit IPv4, or 128bit IPv6 address. + * @param string $ip A 32bit IPv4, or 128bit IPv6 address. * @return string Returns a string representation of the address. * @throws NetworkException * */ -function inet_ntop(string $in_addr): string +function inet_ntop(string $ip): string +{ + error_clear_last(); + $result = \inet_ntop($ip); + if ($result === false) { + throw NetworkException::createFromPhpError(); + } + return $result; +} + + +/** + * The function long2ip generates an Internet address + * in dotted format (i.e.: aaa.bbb.ccc.ddd) from the long integer + * representation. + * + * @param int $ip A proper address representation in long integer. + * @return string Returns the Internet IP address as a string. + * @throws NetworkException + * + */ +function long2ip(int $ip): string +{ + error_clear_last(); + $result = \long2ip($ip); + if ($result === false) { + throw NetworkException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns an enumeration of network interfaces (adapters) on the local machine. + * + * @return array Returns an associative array where the key is the name of the interface and + * the value an associative array of interface attributes. + * + * Each interface associative array contains: + * + * Interface attributes + * + * + * + * Name + * Description + * + * + * + * + * description + * + * Optional string value for description of the interface. + * Windows only. + * + * + * + * mac + * + * Optional string value for MAC address of the interface. + * Windows only. + * + * + * + * mtu + * + * Integer value for Maximum transmission unit (MTU) of the interface. + * Windows only. + * + * + * + * unicast + * + * Array of associative arrays, see Unicast attributes below. + * + * + * + * up + * + * Boolean status (on/off) for interface. + * + * + * + * + * + * + * + * Unicast attributes + * + * + * + * Name + * Description + * + * + * + * + * flags + * + * Integer value. + * + * + * + * family + * + * Integer value. + * + * + * + * address + * + * String value for address in either IPv4 or IPv6. + * + * + * + * netmask + * + * String value for netmask in either IPv4 or IPv6. + * + * + * + * + * + * @throws NetworkException + * + */ +function net_get_interfaces(): array { error_clear_last(); - $result = \inet_ntop($in_addr); + $result = \net_get_interfaces(); if ($result === false) { throw NetworkException::createFromPhpError(); } @@ -428,11 +579,11 @@ function inet_ntop(string $in_addr): string * * The use of openlog is optional. It * will automatically be called by syslog if - * necessary, in which case ident will default + * necessary, in which case prefix will default * to FALSE. * - * @param string $ident The string ident is added to each message. - * @param int $option The option argument is used to indicate + * @param string $prefix The string prefix is added to each message. + * @param int $flags The flags argument is used to indicate * what logging options will be used when generating a log message. * * openlog Options @@ -554,13 +705,46 @@ function inet_ntop(string $in_addr): string * @throws NetworkException * */ -function openlog(string $ident, int $option, int $facility): void +function openlog(string $prefix, int $flags, int $facility): void +{ + error_clear_last(); + $result = \openlog($prefix, $flags, $facility); + if ($result === false) { + throw NetworkException::createFromPhpError(); + } +} + + +/** + * This function behaves exactly as fsockopen with the + * difference that the connection is not closed after the script finishes. + * It is the persistent version of fsockopen. + * + * @param string $hostname + * @param int $port + * @param int|null $error_code + * @param string|null $error_message + * @param float $timeout + * @return resource pfsockopen returns a file pointer which may be used + * together with the other file functions (such as + * fgets, fgetss, + * fwrite, fclose, and + * feof). + * @throws NetworkException + * + */ +function pfsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null) { error_clear_last(); - $result = \openlog($ident, $option, $facility); + if ($timeout !== null) { + $result = \pfsockopen($hostname, $port, $error_code, $error_message, $timeout); + } else { + $result = \pfsockopen($hostname, $port, $error_code, $error_message); + } if ($result === false) { throw NetworkException::createFromPhpError(); } + return $result; } @@ -622,10 +806,7 @@ function openlog(string $ident, int $option, int $facility): void * * * - * @param string $message The message to send, except that the two characters - * %m will be replaced by the error message string - * (strerror) corresponding to the present value of - * errno. + * @param string $message The message to send. * @throws NetworkException * */ diff --git a/vendor/thecodingmachine/safe/generated/oci8.php b/vendor/thecodingmachine/safe/generated/oci8.php index f2bac2781..4a7e38806 100644 --- a/vendor/thecodingmachine/safe/generated/oci8.php +++ b/vendor/thecodingmachine/safe/generated/oci8.php @@ -5,15 +5,15 @@ namespace Safe; use Safe\Exceptions\Oci8Exception; /** - * Binds the PHP array var_array to the Oracle - * placeholder name, which points to an Oracle PL/SQL + * Binds the PHP array var to the Oracle + * placeholder param, which points to an Oracle PL/SQL * array. Whether it will be used for input or output will be determined at * run-time. * * @param resource $statement A valid OCI statement identifier. - * @param string $name The Oracle placeholder. - * @param array $var_array An array. - * @param int $max_table_length Sets the maximum length both for incoming and result arrays. + * @param string $param The Oracle placeholder. + * @param array $var An array. + * @param int $max_array_length Sets the maximum length both for incoming and result arrays. * @param int $max_item_length Sets maximum length for array items. If not specified or equals to -1, * oci_bind_array_by_name will find the longest * element in the incoming array and will use it as the maximum length. @@ -101,10 +101,10 @@ use Safe\Exceptions\Oci8Exception; * @throws Oci8Exception * */ -function oci_bind_array_by_name($statement, string $name, array &$var_array, int $max_table_length, int $max_item_length = -1, int $type = SQLT_AFC): void +function oci_bind_array_by_name($statement, string $param, array &$var, int $max_array_length, int $max_item_length = -1, int $type = SQLT_AFC): void { error_clear_last(); - $result = \oci_bind_array_by_name($statement, $name, $var_array, $max_table_length, $max_item_length, $type); + $result = \oci_bind_array_by_name($statement, $param, $var, $max_array_length, $max_item_length, $type); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -112,8 +112,8 @@ function oci_bind_array_by_name($statement, string $name, array &$var_array, int /** - * Binds a PHP variable variable to the Oracle - * bind variable placeholder bv_name. Binding + * Binds a PHP variable var to the Oracle + * bind variable placeholder param. Binding * is important for Oracle database performance and also as a way to * avoid SQL Injection security issues. * @@ -136,12 +136,12 @@ function oci_bind_array_by_name($statement, string $name, array &$var_array, int * bind variable will be used for input or output is determined at * run-time. * - * You must specify maxlength when using + * You must specify max_length when using * an OUT bind so that PHP allocates enough memory * to hold the returned value. * * For IN binds it is recommended to set - * the maxlength length if the statement is + * the max_length length if the statement is * re-executed multiple times with different values for the PHP * variable. Otherwise Oracle may truncate data to the length of the * initial PHP variable value. If you don't know what the maximum @@ -168,16 +168,16 @@ function oci_bind_array_by_name($statement, string $name, array &$var_array, int * SQL statement, as this can be a security risk if unfiltered user * text is concatenated. * - * @param resource $statement A valid OCI8 statement identifer. - * @param string $bv_name The colon-prefixed bind variable placeholder used in the + * @param resource $statement A valid OCI8 statement identifier. + * @param string $param The colon-prefixed bind variable placeholder used in the * statement. The colon is optional - * in bv_name. Oracle does not use question + * in param. Oracle does not use question * marks for placeholders. - * @param mixed $variable The PHP variable to be associated with bv_name - * @param int $maxlength Sets the maximum length for the data. If you set it to -1, this + * @param mixed $var The PHP variable to be associated with param + * @param int $max_length Sets the maximum length for the data. If you set it to -1, this * function will use the current length - * of variable to set the maximum - * length. In this case the variable must + * of var to set the maximum + * length. In this case the var must * exist and contain data * when oci_bind_by_name is called. * @param int $type The datatype that Oracle will treat the data as. The @@ -307,10 +307,10 @@ function oci_bind_array_by_name($statement, string $name, array &$var_array, int * @throws Oci8Exception * */ -function oci_bind_by_name($statement, string $bv_name, &$variable, int $maxlength = -1, int $type = SQLT_CHR): void +function oci_bind_by_name($statement, string $param, &$var, int $max_length = -1, int $type = 0): void { error_clear_last(); - $result = \oci_bind_by_name($statement, $bv_name, $variable, $maxlength, $type); + $result = \oci_bind_by_name($statement, $param, $var, $max_length, $type); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -336,31 +336,6 @@ function oci_cancel($statement): void /** - * Unsets connection. The underlying database - * connection is closed if no other resources are using it and if it - * was created with oci_connect - * or oci_new_connect. - * - * It is recommended to close connections that are no longer needed - * because this makes database resources available for other users. - * - * @param resource $connection An Oracle connection identifier returned by - * oci_connect, oci_pconnect, - * or oci_new_connect. - * @throws Oci8Exception - * - */ -function oci_close($connection): void -{ - error_clear_last(); - $result = \oci_close($connection); - if ($result === false) { - throw Oci8Exception::createFromPhpError(); - } -} - - -/** * Commits the outstanding transaction for the * Oracle connection. A commit ends the * current transaction and makes permanent all changes. It releases @@ -395,9 +370,11 @@ function oci_commit($connection): void /** * Returns a connection identifier needed for most other OCI8 operations. * - * See Connection Handling for - * general information on connection management and connection - * pooling. + * For performance, most applications should use persistent connections + * with oci_pconnect instead + * of oci_connect. + * See Connection Handling for general + * information on connection management and connection pooling. * * From PHP 5.1.2 (PECL OCI8 1.1) oci_close can * be used to close the connection. @@ -419,7 +396,7 @@ function oci_commit($connection): void * the tnsnames.ora file, or the name of a local * Oracle instance. * - * If not specified, PHP uses + * If not specified or NULL, PHP uses * environment variables such as TWO_TASK (on Linux) * or LOCAL (on Windows) * and ORACLE_SID to determine the @@ -432,19 +409,19 @@ function oci_commit($connection): void * [//]host_name[:port][/service_name]. From Oracle * 11g, the syntax is: * [//]host_name[:port][/service_name][:server_type][/instance_name]. - * Service names can be found by running the Oracle - * utility lsnrctl status on the database server + * Further options were introduced with Oracle 19c, including timeout and keep-alive + * settings. Refer to Oracle documentation. Service names can be found by running + * the Oracle utility lsnrctl status on the database server * machine. * * - * The tnsnames.ora file can be in the Oracle Net - * search path, which - * includes $ORACLE_HOME/network/admin - * and /etc. Alternatively - * set TNS_ADMIN so - * that $TNS_ADMIN/tnsnames.ora is read. Make sure - * the web daemon has read access to the file. - * @param string $character_set Determines + * The tnsnames.ora file can be in the Oracle Net search path, + * which + * includes /your/path/to/instantclient/network/admin, $ORACLE_HOME/network/admin + * and /etc. Alternatively set TNS_ADMIN + * so that $TNS_ADMIN/tnsnames.ora is read. Make sure the web + * daemon has read access to the file. + * @param string $encoding Determines * the character set used by the Oracle Client libraries. The character * set does not need to match the character set used by the database. If * it doesn't match, Oracle will do its best to convert data to and from @@ -489,13 +466,13 @@ function oci_commit($connection): void * @throws Oci8Exception * */ -function oci_connect(string $username, string $password, string $connection_string = null, string $character_set = null, int $session_mode = null) +function oci_connect(string $username, string $password, string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) { error_clear_last(); - if ($session_mode !== null) { - $result = \oci_connect($username, $password, $connection_string, $character_set, $session_mode); - } elseif ($character_set !== null) { - $result = \oci_connect($username, $password, $connection_string, $character_set); + if ($session_mode !== OCI_DEFAULT) { + $result = \oci_connect($username, $password, $connection_string, $encoding, $session_mode); + } elseif ($encoding !== "") { + $result = \oci_connect($username, $password, $connection_string, $encoding); } elseif ($connection_string !== null) { $result = \oci_connect($username, $password, $connection_string); } else { @@ -518,12 +495,12 @@ function oci_connect(string $username, string $password, string $connection_stri * identifier created by oci_parse and executed * by oci_execute, or a REF * CURSOR statement identifier. - * @param string $column_name The column name used in the query. + * @param string $column The column name used in the query. * * Use uppercase for Oracle's default, non-case sensitive column * names. Use the exact column name case for case-sensitive * column names. - * @param mixed $variable The PHP variable that will contain the returned column value. + * @param mixed $var The PHP variable that will contain the returned column value. * @param int $type The data type to be returned. Generally not needed. Note that * Oracle-style data conversions are not performed. For example, * SQLT_INT will be ignored and the returned @@ -534,10 +511,10 @@ function oci_connect(string $username, string $password, string $connection_stri * @throws Oci8Exception * */ -function oci_define_by_name($statement, string $column_name, &$variable, int $type = SQLT_CHR): void +function oci_define_by_name($statement, string $column, &$var, int $type = 0): void { error_clear_last(); - $result = \oci_define_by_name($statement, $column_name, $variable, $type); + $result = \oci_define_by_name($statement, $column, $var, $type); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -632,121 +609,18 @@ function oci_execute($statement, int $mode = OCI_COMMIT_ON_SUCCESS): void /** - * Fetches multiple rows from a query into a two-dimensional array. - * By default, all rows are returned. - * - * This function can be called only once for each query executed - * with oci_execute. - * - * @param resource $statement A valid OCI8 statement - * identifier created by oci_parse and executed - * by oci_execute, or a REF - * CURSOR statement identifier. - * @param array|null $output The variable to contain the returned rows. - * - * LOB columns are returned as strings, where Oracle supports - * conversion. - * - * See oci_fetch_array for more information - * on how data and types are fetched. - * @param int $skip The number of initial rows to discard when fetching the - * result. The default value is 0, so the first row onwards is - * returned. - * @param int $maxrows The number of rows to return. The default is -1 meaning return - * all the rows from skip + 1 onwards. - * @param int $flags Parameter flags indicates the array - * structure and whether associative arrays should be used. - * - * oci_fetch_all Array Structure Modes - * - * - * - * Constant - * Description - * - * - * - * - * OCI_FETCHSTATEMENT_BY_ROW - * The outer array will contain one sub-array per query - * row. - * - * - * OCI_FETCHSTATEMENT_BY_COLUMN - * The outer array will contain one sub-array per query - * column. This is the default. - * - * - * - * - * - * Arrays can be indexed either by column heading or numerically. - * Only one index mode will be returned. - * - * oci_fetch_all Array Index Modes - * - * - * - * Constant - * Description - * - * - * - * - * OCI_NUM - * Numeric indexes are used for each column's array. - * - * - * OCI_ASSOC - * Associative indexes are used for each column's - * array. This is the default. - * - * - * - * - * - * Use the addition operator "+" to choose a combination - * of array structure and index modes. - * - * Oracle's default, non-case sensitive column names will have - * uppercase array keys. Case-sensitive column names will have - * array keys using the exact column case. - * Use var_dump - * on output to verify the appropriate case - * to use for each query. - * - * Queries that have more than one column with the same name - * should use column aliases. Otherwise only one of the columns - * will appear in an associative array. - * @return int Returns the number of rows in output, which - * may be 0 or more. - * @throws Oci8Exception - * - */ -function oci_fetch_all($statement, ?array &$output, int $skip = 0, int $maxrows = -1, int $flags = OCI_FETCHSTATEMENT_BY_COLUMN + OCI_ASSOC): int -{ - error_clear_last(); - $result = \oci_fetch_all($statement, $output, $skip, $maxrows, $flags); - if ($result === false) { - throw Oci8Exception::createFromPhpError(); - } - return $result; -} - - -/** - * Returns the name of the field. + * Returns the name of the column. * * @param resource $statement A valid OCI statement identifier. - * @param mixed $field Can be the field's index (1-based) or name. - * @return string Returns the name as a strings. + * @param mixed $column Can be the field's index (1-based) or name. + * @return string Returns the name as a string * @throws Oci8Exception * */ -function oci_field_name($statement, $field): string +function oci_field_name($statement, $column): string { error_clear_last(); - $result = \oci_field_name($statement, $field); + $result = \oci_field_name($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -755,22 +629,22 @@ function oci_field_name($statement, $field): string /** - * Returns precision of the field. + * Returns precision of the column. * * For FLOAT columns, precision is nonzero and scale is -127. * If precision is 0, then column is NUMBER. Else it's * NUMBER(precision, scale). * * @param resource $statement A valid OCI statement identifier. - * @param mixed $field Can be the field's index (1-based) or name. - * @return int Returns the precision as an integers. + * @param mixed $column Can be the field's index (1-based) or name. + * @return int Returns the precision as an integer * @throws Oci8Exception * */ -function oci_field_precision($statement, $field): int +function oci_field_precision($statement, $column): int { error_clear_last(); - $result = \oci_field_precision($statement, $field); + $result = \oci_field_precision($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -779,22 +653,22 @@ function oci_field_precision($statement, $field): int /** - * Returns the scale of the column with field index. + * Returns the scale of the column with column index. * * For FLOAT columns, precision is nonzero and scale is -127. * If precision is 0, then column is NUMBER. Else it's * NUMBER(precision, scale). * * @param resource $statement A valid OCI statement identifier. - * @param mixed $field Can be the field's index (1-based) or name. - * @return int Returns the scale as an integers. + * @param mixed $column Can be the field's index (1-based) or name. + * @return int Returns the scale as an integer * @throws Oci8Exception * */ -function oci_field_scale($statement, $field): int +function oci_field_scale($statement, $column): int { error_clear_last(); - $result = \oci_field_scale($statement, $field); + $result = \oci_field_scale($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -803,18 +677,18 @@ function oci_field_scale($statement, $field): int /** - * Returns the size of a field. + * Returns the size of a column. * * @param resource $statement A valid OCI statement identifier. - * @param mixed $field Can be the field's index (1-based) or name. - * @return int Returns the size of a field in bytess. + * @param mixed $column Can be the field's index (1-based) or name. + * @return int Returns the size of a column in bytes * @throws Oci8Exception * */ -function oci_field_size($statement, $field): int +function oci_field_size($statement, $column): int { error_clear_last(); - $result = \oci_field_size($statement, $field); + $result = \oci_field_size($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -823,20 +697,20 @@ function oci_field_size($statement, $field): int /** - * Returns Oracle's raw "SQLT" data type of the field. + * Returns Oracle's raw "SQLT" data type of the column. * * If you want a field's type name, then use oci_field_type instead. * * @param resource $statement A valid OCI statement identifier. - * @param mixed $field Can be the field's index (1-based) or name. - * @return int Returns Oracle's raw data type as a numbers. + * @param mixed $column Can be the field's index (1-based) or name. + * @return int Returns Oracle's raw data type as a number * @throws Oci8Exception * */ -function oci_field_type_raw($statement, $field): int +function oci_field_type_raw($statement, $column): int { error_clear_last(); - $result = \oci_field_type_raw($statement, $field); + $result = \oci_field_type_raw($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -848,15 +722,15 @@ function oci_field_type_raw($statement, $field): int * Returns a field's data type name. * * @param resource $statement A valid OCI statement identifier. - * @param mixed $field Can be the field's index (1-based) or name. - * @return mixed Returns the field data type as a strings. + * @param mixed $column Can be the field's index (1-based) or name. + * @return mixed Returns the field data type as a string or an integer * @throws Oci8Exception * */ -function oci_field_type($statement, $field) +function oci_field_type($statement, $column) { error_clear_last(); - $result = \oci_field_type($statement, $field); + $result = \oci_field_type($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -867,14 +741,14 @@ function oci_field_type($statement, $field) /** * Frees a descriptor allocated by oci_new_descriptor. * - * @param resource $descriptor + * @param \OCILob $lob Descriptor allocated by oci_new_descriptor. * @throws Oci8Exception * */ -function oci_free_descriptor($descriptor): void +function oci_free_descriptor(\OCILob $lob): void { error_clear_last(); - $result = \oci_free_descriptor($descriptor); + $result = \oci_free_descriptor($lob); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -905,17 +779,21 @@ function oci_free_statement($statement): void * * @param resource $connection An Oracle connection identifier, returned by * oci_connect or oci_pconnect. - * @param string $tdo Should be a valid named type (uppercase). + * @param string $type_name Should be a valid named type (uppercase). * @param string $schema Should point to the scheme, where the named type was created. The name - * of the current user is the default value. + * of the current user is used when NULL is passed. * @return \OCI-Collection Returns a new OCICollection object. * @throws Oci8Exception * */ -function oci_new_collection($connection, string $tdo, string $schema = null) +function oci_new_collection($connection, string $type_name, string $schema = null) { error_clear_last(); - $result = \oci_new_collection($connection, $tdo, $schema); + if ($schema !== null) { + $result = \oci_new_collection($connection, $type_name, $schema); + } else { + $result = \oci_new_collection($connection, $type_name); + } if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -941,7 +819,7 @@ function oci_new_collection($connection, string $tdo, string $schema = null) * the tnsnames.ora file, or the name of a local * Oracle instance. * - * If not specified, PHP uses + * If not specified or NULL, PHP uses * environment variables such as TWO_TASK (on Linux) * or LOCAL (on Windows) * and ORACLE_SID to determine the @@ -954,19 +832,19 @@ function oci_new_collection($connection, string $tdo, string $schema = null) * [//]host_name[:port][/service_name]. From Oracle * 11g, the syntax is: * [//]host_name[:port][/service_name][:server_type][/instance_name]. - * Service names can be found by running the Oracle - * utility lsnrctl status on the database server + * Further options were introduced with Oracle 19c, including timeout and keep-alive + * settings. Refer to Oracle documentation. Service names can be found by running + * the Oracle utility lsnrctl status on the database server * machine. * * - * The tnsnames.ora file can be in the Oracle Net - * search path, which - * includes $ORACLE_HOME/network/admin - * and /etc. Alternatively - * set TNS_ADMIN so - * that $TNS_ADMIN/tnsnames.ora is read. Make sure - * the web daemon has read access to the file. - * @param string $character_set Determines + * The tnsnames.ora file can be in the Oracle Net search path, + * which + * includes /your/path/to/instantclient/network/admin, $ORACLE_HOME/network/admin + * and /etc. Alternatively set TNS_ADMIN + * so that $TNS_ADMIN/tnsnames.ora is read. Make sure the web + * daemon has read access to the file. + * @param string $encoding Determines * the character set used by the Oracle Client libraries. The character * set does not need to match the character set used by the database. If * it doesn't match, Oracle will do its best to convert data to and from @@ -1011,13 +889,13 @@ function oci_new_collection($connection, string $tdo, string $schema = null) * @throws Oci8Exception * */ -function oci_new_connect(string $username, string $password, string $connection_string = null, string $character_set = null, int $session_mode = null) +function oci_new_connect(string $username, string $password, string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) { error_clear_last(); - if ($session_mode !== null) { - $result = \oci_new_connect($username, $password, $connection_string, $character_set, $session_mode); - } elseif ($character_set !== null) { - $result = \oci_new_connect($username, $password, $connection_string, $character_set); + if ($session_mode !== OCI_DEFAULT) { + $result = \oci_new_connect($username, $password, $connection_string, $encoding, $session_mode); + } elseif ($encoding !== "") { + $result = \oci_new_connect($username, $password, $connection_string, $encoding); } elseif ($connection_string !== null) { $result = \oci_new_connect($username, $password, $connection_string); } else { @@ -1058,7 +936,7 @@ function oci_new_cursor($connection) * @param int $type Valid values for type are: * OCI_DTYPE_FILE, OCI_DTYPE_LOB and * OCI_DTYPE_ROWID. - * @return \OCI-Lob Returns a new LOB or FILE descriptor on success, FALSE on error. + * @return \OCI-Lob|false Returns a new LOB or FILE descriptor on success. * @throws Oci8Exception * */ @@ -1066,26 +944,7 @@ function oci_new_descriptor($connection, int $type = OCI_DTYPE_LOB) { error_clear_last(); $result = \oci_new_descriptor($connection, $type); - if ($result === false) { - throw Oci8Exception::createFromPhpError(); - } - return $result; -} - - -/** - * Gets the number of columns in the given statement. - * - * @param resource $statement A valid OCI statement identifier. - * @return int Returns the number of columns as an integers. - * @throws Oci8Exception - * - */ -function oci_num_fields($statement): int -{ - error_clear_last(); - $result = \oci_num_fields($statement); - if ($result === false) { + if ($result === null) { throw Oci8Exception::createFromPhpError(); } return $result; @@ -1096,7 +955,7 @@ function oci_num_fields($statement): int * Gets the number of rows affected during statement execution. * * @param resource $statement A valid OCI statement identifier. - * @return int Returns the number of rows affected as an integers. + * @return int Returns the number of rows affected as an integer * @throws Oci8Exception * */ @@ -1112,7 +971,7 @@ function oci_num_rows($statement): int /** - * Prepares sql_text using + * Prepares sql using * connection and returns the statement identifier, * which can be used with oci_bind_by_name, * oci_execute and other functions. @@ -1123,7 +982,7 @@ function oci_num_rows($statement): int * * @param resource $connection An Oracle connection identifier, returned by * oci_connect, oci_pconnect, or oci_new_connect. - * @param string $sql_text The SQL or PL/SQL statement. + * @param string $sql The SQL or PL/SQL statement. * * SQL statements should not end with a * semi-colon (";"). PL/SQL @@ -1133,10 +992,10 @@ function oci_num_rows($statement): int * @throws Oci8Exception * */ -function oci_parse($connection, string $sql_text) +function oci_parse($connection, string $sql) { error_clear_last(); - $result = \oci_parse($connection, $sql_text); + $result = \oci_parse($connection, $sql); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -1147,11 +1006,12 @@ function oci_parse($connection, string $sql_text) /** * Creates a persistent connection to an Oracle server and logs on. * - * Persistent connections are cached and re-used between requests, resulting - * in reduced overhead on each page load; a typical PHP application will have - * a single persistent connection open against an Oracle server per Apache - * child process (or PHP FastCGI/CGI process). See the Persistent Database - * Connections section for more information. + * Persistent connections are cached and re-used between requests, resulting in + * reduced overhead on each page load; a typical PHP application will have a + * single persistent connection open against an Oracle server per Apache child + * process (or PHP FPM process). See the OCI8 + * Connection Handling and Connection Pooling section for more + * information. * * @param string $username The Oracle user name. * @param string $password The password for username. @@ -1162,7 +1022,7 @@ function oci_parse($connection, string $sql_text) * the tnsnames.ora file, or the name of a local * Oracle instance. * - * If not specified, PHP uses + * If not specified or NULL, PHP uses * environment variables such as TWO_TASK (on Linux) * or LOCAL (on Windows) * and ORACLE_SID to determine the @@ -1175,19 +1035,19 @@ function oci_parse($connection, string $sql_text) * [//]host_name[:port][/service_name]. From Oracle * 11g, the syntax is: * [//]host_name[:port][/service_name][:server_type][/instance_name]. - * Service names can be found by running the Oracle - * utility lsnrctl status on the database server + * Further options were introduced with Oracle 19c, including timeout and keep-alive + * settings. Refer to Oracle documentation. Service names can be found by running + * the Oracle utility lsnrctl status on the database server * machine. * * - * The tnsnames.ora file can be in the Oracle Net - * search path, which - * includes $ORACLE_HOME/network/admin - * and /etc. Alternatively - * set TNS_ADMIN so - * that $TNS_ADMIN/tnsnames.ora is read. Make sure - * the web daemon has read access to the file. - * @param string $character_set Determines + * The tnsnames.ora file can be in the Oracle Net search path, + * which + * includes /your/path/to/instantclient/network/admin, $ORACLE_HOME/network/admin + * and /etc. Alternatively set TNS_ADMIN + * so that $TNS_ADMIN/tnsnames.ora is read. Make sure the web + * daemon has read access to the file. + * @param string $encoding Determines * the character set used by the Oracle Client libraries. The character * set does not need to match the character set used by the database. If * it doesn't match, Oracle will do its best to convert data to and from @@ -1232,13 +1092,13 @@ function oci_parse($connection, string $sql_text) * @throws Oci8Exception * */ -function oci_pconnect(string $username, string $password, string $connection_string = null, string $character_set = null, int $session_mode = null) +function oci_pconnect(string $username, string $password, string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) { error_clear_last(); - if ($session_mode !== null) { - $result = \oci_pconnect($username, $password, $connection_string, $character_set, $session_mode); - } elseif ($character_set !== null) { - $result = \oci_pconnect($username, $password, $connection_string, $character_set); + if ($session_mode !== OCI_DEFAULT) { + $result = \oci_pconnect($username, $password, $connection_string, $encoding, $session_mode); + } elseif ($encoding !== "") { + $result = \oci_pconnect($username, $password, $connection_string, $encoding); } elseif ($connection_string !== null) { $result = \oci_pconnect($username, $password, $connection_string); } else { @@ -1252,7 +1112,45 @@ function oci_pconnect(string $username, string $password, string $connection_str /** - * Returns the data from field in the current row, + * Registers a user-defined callback function to connection. + * If connection fails due to instance or network failure, + * the registered callback function will be invoked for several times during + * failover. See OCI8 Transparent Application Failover + * (TAF) Support for information. + * + * When oci_register_taf_callback is called multiple times, + * each registration overwrites the previous one. + * + * Use oci_unregister_taf_callback to explicitly unregister a + * user-defined callback. + * + * TAF callback registration will NOT be saved across + * persistent connections, therefore the callback needs to be re-registered for + * a new persistent connection. + * + * @param resource $connection An Oracle connection identifier. + * @param callable $callback A user-defined callback to register for Oracle TAF. It can be a + * string of the function name or a Closure (anonymous function). + * + * The interface of a TAF user-defined callback function is as follows: + * + * See the parameter description and an example on + * OCI8 Transparent Application Failover (TAF) Support page. + * @throws Oci8Exception + * + */ +function oci_register_taf_callback($connection, callable $callback): void +{ + error_clear_last(); + $result = \oci_register_taf_callback($connection, $callback); + if ($result === false) { + throw Oci8Exception::createFromPhpError(); + } +} + + +/** + * Returns the data from column in the current row, * fetched by oci_fetch. * * For details on the data type mapping performed by @@ -1260,7 +1158,7 @@ function oci_pconnect(string $username, string $password, string $connection_str * supported by the driver * * @param resource $statement - * @param mixed $field Can be either use the column number (1-based) or the column name. + * @param mixed $column Can be either use the column number (1-based) or the column name. * The case of the column name must be the case that Oracle meta data * describes the column as, which is uppercase for columns created * case insensitively. @@ -1269,10 +1167,10 @@ function oci_pconnect(string $username, string $password, string $connection_str * @throws Oci8Exception * */ -function oci_result($statement, $field): string +function oci_result($statement, $column): string { error_clear_last(); - $result = \oci_result($statement, $field); + $result = \oci_result($statement, $column); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -1349,14 +1247,14 @@ function oci_server_version($connection): string * @param resource $connection An Oracle connection identifier, * returned by oci_connect, oci_pconnect, * or oci_new_connect. - * @param string $action_name User chosen string up to 32 bytes long. + * @param string $action User chosen string up to 32 bytes long. * @throws Oci8Exception * */ -function oci_set_action($connection, string $action_name): void +function oci_set_action($connection, string $action): void { error_clear_last(); - $result = \oci_set_action($connection, $action_name); + $result = \oci_set_action($connection, $action); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -1391,14 +1289,14 @@ function oci_set_action($connection, string $action_name): void * @param resource $connection An Oracle connection identifier, * returned by oci_connect, oci_pconnect, * or oci_new_connect. - * @param int $time_out The maximum time in milliseconds that any single round-trip between PHP and Oracle Database may take. + * @param int $timeout The maximum time in milliseconds that any single round-trip between PHP and Oracle Database may take. * @throws Oci8Exception * */ -function oci_set_call_timeout($connection, int $time_out): void +function oci_set_call_timeout($connection, int $timeout): void { error_clear_last(); - $result = \oci_set_call_timeout($connection, $time_out); + $result = \oci_set_call_timeout($connection, $timeout); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -1426,14 +1324,14 @@ function oci_set_call_timeout($connection, int $time_out): void * @param resource $connection An Oracle connection identifier, * returned by oci_connect, oci_pconnect, * or oci_new_connect. - * @param string $client_identifier User chosen string up to 64 bytes long. + * @param string $client_id User chosen string up to 64 bytes long. * @throws Oci8Exception * */ -function oci_set_client_identifier($connection, string $client_identifier): void +function oci_set_client_identifier($connection, string $client_id): void { error_clear_last(); - $result = \oci_set_client_identifier($connection, $client_identifier); + $result = \oci_set_client_identifier($connection, $client_id); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -1485,14 +1383,14 @@ function oci_set_client_info($connection, string $client_info): void * @param resource $connection An Oracle connection identifier, * returned by oci_connect, oci_pconnect, * or oci_new_connect. - * @param string $dbop User chosen string. + * @param string $action User chosen string. * @throws Oci8Exception * */ -function oci_set_db_operation($connection, string $dbop): void +function oci_set_db_operation($connection, string $action): void { error_clear_last(); - $result = \oci_set_db_operation($connection, $dbop); + $result = \oci_set_db_operation($connection, $action); if ($result === false) { throw Oci8Exception::createFromPhpError(); } @@ -1550,14 +1448,50 @@ function oci_set_edition(string $edition): void * @param resource $connection An Oracle connection identifier, * returned by oci_connect, oci_pconnect, * or oci_new_connect. - * @param string $module_name User chosen string up to 48 bytes long. + * @param string $name User chosen string up to 48 bytes long. + * @throws Oci8Exception + * + */ +function oci_set_module_name($connection, string $name): void +{ + error_clear_last(); + $result = \oci_set_module_name($connection, $name); + if ($result === false) { + throw Oci8Exception::createFromPhpError(); + } +} + + +/** + * Sets the internal buffer size used to fetch each CLOB or BLOB value when the + * implementation gets the internal Oracle LOB locator from the database after + * a successful query call to oci_execute and for each + * subsequent internal fetch request to the database. Increasing this value + * can improve the performance of fetching smaller LOBs by reducing round-trips + * between PHP and the database. Memory usage will change. + * + * The value affects LOBs returned as OCILob instances and also those returned + * using OCI_RETURN_LOBS. + * + * Call oci_set_prefetch_lob before + * calling oci_execute. If it is not called, the value + * of oci8.prefetch_lob_size + * is used. + * + * The LOB prefetch value should only be set with Oracle Database 12.2 or later. + * + * @param resource $statement A valid OCI8 statement + * identifier created by oci_parse and executed + * by oci_execute, or a REF + * CURSOR statement identifier. + * @param int $prefetch_lob_size The number of bytes of each LOB to be prefetched, >= 0 * @throws Oci8Exception * */ -function oci_set_module_name($connection, string $module_name): void +function oci_set_prefetch_lob($statement, int $prefetch_lob_size): void { error_clear_last(); - $result = \oci_set_module_name($connection, $module_name); + $result = \oci_set_prefetch_lob($statement, $prefetch_lob_size); if ($result === false) { throw Oci8Exception::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/opcache.php b/vendor/thecodingmachine/safe/generated/opcache.php index 04a58205f..dcac85493 100644 --- a/vendor/thecodingmachine/safe/generated/opcache.php +++ b/vendor/thecodingmachine/safe/generated/opcache.php @@ -9,14 +9,14 @@ use Safe\Exceptions\OpcacheException; * 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 $file The path to the PHP script to be compiled. + * @param string $filename The path to the PHP script to be compiled. * @throws OpcacheException * */ -function opcache_compile_file(string $file): void +function opcache_compile_file(string $filename): void { error_clear_last(); - $result = \opcache_compile_file($file); + $result = \opcache_compile_file($filename); if ($result === false) { throw OpcacheException::createFromPhpError(); } @@ -24,17 +24,18 @@ function opcache_compile_file(string $file): void /** - * This function returns state information about the cache instance + * This function returns state information about the in-memory cache instance. It will not return any + * information about the file cache. * - * @param bool $get_scripts Include script specific state information + * @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 $get_scripts = true): array +function opcache_get_status(bool $include_scripts = true): array { error_clear_last(); - $result = \opcache_get_status($get_scripts); + $result = \opcache_get_status($include_scripts); if ($result === false) { throw OpcacheException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/openssl.php b/vendor/thecodingmachine/safe/generated/openssl.php index 117b53d6a..b201ebc6c 100644 --- a/vendor/thecodingmachine/safe/generated/openssl.php +++ b/vendor/thecodingmachine/safe/generated/openssl.php @@ -7,15 +7,15 @@ use Safe\Exceptions\OpensslException; /** * Gets the cipher initialization vector (iv) length. * - * @param string $method The cipher method, see openssl_get_cipher_methods for a list of potential values. + * @param string $cipher_algo The cipher method, see openssl_get_cipher_methods for a list of potential values. * @return int Returns the cipher length on success. * @throws OpensslException * */ -function openssl_cipher_iv_length(string $method): int +function openssl_cipher_iv_length(string $cipher_algo): int { error_clear_last(); - $result = \openssl_cipher_iv_length($method); + $result = \openssl_cipher_iv_length($cipher_algo); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -24,13 +24,157 @@ function openssl_cipher_iv_length(string $method): int /** + * Decrypts a CMS message. + * + * @param string $input_filename The name of a file containing encrypted content. + * @param string $output_filename The name of the file to deposit the decrypted content. + * @param $certificate The name of the file containing a certificate of the recipient. + * @param $private_key The name of the file containing a PKCS#8 key. + * @param int $encoding The encoding of the input file. One of OPENSSL_ENCODING_SMIME, + * OPENSSL_ENCODING_DER or OPENSSL_ENCODING_PEM. + * @throws OpensslException + * + */ +function openssl_cms_decrypt(string $input_filename, string $output_filename, $certificate, $private_key = null, int $encoding = OPENSSL_ENCODING_SMIME): void +{ + error_clear_last(); + if ($encoding !== OPENSSL_ENCODING_SMIME) { + $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate, $private_key, $encoding); + } elseif ($private_key !== null) { + $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate, $private_key); + } else { + $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate); + } + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * This function encrypts content to one or more recipients, + * based on the certificates that are passed to it. + * + * @param string $input_filename The file to be encrypted. + * @param string $output_filename The output file. + * @param $certificate Recipients to encrypt to. + * @param $headers Headers to include when S/MIME is used. + * @param int $flags Flags to be passed to CMS_sign. + * @param int $encoding An encoding to output. One of OPENSSL_ENCODING_SMIME, + * OPENSSL_ENCODING_DER or OPENSSL_ENCODING_PEM. + * @param int $cipher_algo A cypher to use. + * @throws OpensslException + * + */ +function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): void +{ + error_clear_last(); + $result = \openssl_cms_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $encoding, $cipher_algo); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * Performs the exact analog to openssl_pkcs7_read. + * + * @param string $input_filename + * @param array $certificates + * @throws OpensslException + * + */ +function openssl_cms_read(string $input_filename, array &$certificates): void +{ + error_clear_last(); + $result = \openssl_cms_read($input_filename, $certificates); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * This function signs a file with an X.509 certificate and key. + * + * @param string $input_filename The name of the file to be signed. + * @param string $output_filename The name of the file to deposit the results. + * @param $certificate The signing certificate. + * See Key/Certificate parameters for a list of valid values. + * @param $private_key The key associated with certificate. + * See Key/Certificate parameters for a list of valid values. + * @param $headers An array of headers to be included in S/MIME output. + * @param int $flags Flags to be passed to cms_sign. + * @param int $encoding The encoding of the output file. One of OPENSSL_ENCODING_SMIME, + * OPENSSL_ENCODING_DER or OPENSSL_ENCODING_PEM. + * @param $untrusted_certificates_filename Intermediate certificates to be included in the signature. + * @throws OpensslException + * + */ +function openssl_cms_sign(string $input_filename, string $output_filename, $certificate, $private_key, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, $untrusted_certificates_filename = null): void +{ + error_clear_last(); + if ($untrusted_certificates_filename !== null) { + $result = \openssl_cms_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $encoding, $untrusted_certificates_filename); + } else { + $result = \openssl_cms_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $encoding); + } + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * This function verifies a CMS signature, either attached or detached, with the specified encoding. + * + * @param string $input_filename The input file. + * @param int $flags Flags to pass to cms_verify. + * @param $certificates A file with the signer certificate and optionally intermediate certificates. + * @param array $ca_info An array containing self-signed certificate authority certificates. + * @param $untrusted_certificates_filename A file containing additional intermediate certificates. + * @param $content A file pointing to the content when signatures are detached. + * @param $pk7 + * @param $sigfile A file to save the signature to. + * @param int $encoding The encoding of the input file. One of OPENSSL_ENCODING_SMIME, + * OPENSSL_ENCODING_DER or OPENSSL_ENCODING_PEM. + * @throws OpensslException + * + */ +function openssl_cms_verify(string $input_filename, int $flags = 0, $certificates = null, array $ca_info = [], $untrusted_certificates_filename = null, $content = null, $pk7 = null, $sigfile = null, int $encoding = OPENSSL_ENCODING_SMIME): void +{ + error_clear_last(); + if ($encoding !== OPENSSL_ENCODING_SMIME) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7, $sigfile, $encoding); + } elseif ($sigfile !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7, $sigfile); + } elseif ($pk7 !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7); + } elseif ($content !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content); + } elseif ($untrusted_certificates_filename !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename); + } elseif ($ca_info !== []) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info); + } elseif ($certificates !== null) { + $result = \openssl_cms_verify($input_filename, $flags, $certificates); + } else { + $result = \openssl_cms_verify($input_filename, $flags); + } + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** * openssl_csr_export_to_file takes the Certificate * Signing Request represented by csr and saves it - * in PEM format into the file named by outfilename. + * in PEM format into the file named by output_filename. * * @param string|resource $csr See CSR parameters for a list of valid values. - * @param string $outfilename Path to the output file. - * @param bool $notext + * @param string $output_filename Path to the output file. + * @param bool $no_text * The optional parameter notext affects * the verbosity of the output; if it is FALSE, then additional human-readable * information is included in the output. The default value of @@ -38,10 +182,10 @@ function openssl_cipher_iv_length(string $method): int * @throws OpensslException * */ -function openssl_csr_export_to_file($csr, string $outfilename, bool $notext = true): void +function openssl_csr_export_to_file($csr, string $output_filename, bool $no_text = true): void { error_clear_last(); - $result = \openssl_csr_export_to_file($csr, $outfilename, $notext); + $result = \openssl_csr_export_to_file($csr, $output_filename, $no_text); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -51,12 +195,12 @@ function openssl_csr_export_to_file($csr, string $outfilename, bool $notext = tr /** * openssl_csr_export takes the Certificate Signing * Request represented by csr and stores it in - * PEM format in out, which is passed by + * PEM format in output, which is passed by * reference. * * @param string|resource $csr See CSR parameters for a list of valid values. - * @param string|null $out on success, this string will contain the PEM encoded CSR - * @param bool $notext + * @param string|null $output on success, this string will contain the PEM encoded CSR + * @param bool $no_text * The optional parameter notext affects * the verbosity of the output; if it is FALSE, then additional human-readable * information is included in the output. The default value of @@ -64,13 +208,34 @@ function openssl_csr_export_to_file($csr, string $outfilename, bool $notext = tr * @throws OpensslException * */ -function openssl_csr_export($csr, ?string &$out, bool $notext = true): void +function openssl_csr_export($csr, ?string &$output, bool $no_text = true): void +{ + error_clear_last(); + $result = \openssl_csr_export($csr, $output, $no_text); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * openssl_csr_get_public_key extracts the public key + * from csr and prepares it for use by other functions. + * + * @param string|resource $csr See CSR parameters for a list of valid values. + * @param bool $short_names This parameter is ignored + * @return resource Returns an OpenSSLAsymmetricKey on success. + * @throws OpensslException + * + */ +function openssl_csr_get_public_key($csr, bool $short_names = true) { error_clear_last(); - $result = \openssl_csr_export($csr, $out, $notext); + $result = \openssl_csr_get_public_key($csr, $short_names); if ($result === false) { throw OpensslException::createFromPhpError(); } + return $result; } @@ -80,7 +245,7 @@ function openssl_csr_export($csr, ?string &$out, bool $notext = true): void * including fields commonName (CN), organizationName (O), countryName (C) etc. * * @param string|resource $csr See CSR parameters for a list of valid values. - * @param bool $use_shortnames shortnames controls how the data is indexed in the + * @param bool $short_names shortnames controls how the data is indexed in the * array - if shortnames is TRUE (the default) then * fields will be indexed with the short name form, otherwise, the long name * form will be used - e.g.: CN is the shortname form of commonName. @@ -88,10 +253,10 @@ function openssl_csr_export($csr, ?string &$out, bool $notext = true): void * @throws OpensslException * */ -function openssl_csr_get_subject($csr, bool $use_shortnames = true): array +function openssl_csr_get_subject($csr, bool $short_names = true): array { error_clear_last(); - $result = \openssl_csr_get_subject($csr, $use_shortnames); + $result = \openssl_csr_get_subject($csr, $short_names); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -101,21 +266,21 @@ function openssl_csr_get_subject($csr, bool $use_shortnames = true): array /** * openssl_csr_new generates a new CSR (Certificate Signing Request) - * based on the information provided by dn. + * based on the information provided by distinguished_names. * - * @param array $dn The Distinguished Name or subject fields to be used in the certificate. - * @param resource $privkey privkey should be set to a private key that was + * @param array $distinguished_names The Distinguished Name or subject fields to be used in the certificate. + * @param resource $private_key private_key should be set to a private key that was * previously generated by openssl_pkey_new (or * otherwise obtained from the other openssl_pkey family of functions). * The corresponding public portion of the key will be used to sign the * CSR. - * @param array $configargs By default, the information in your system openssl.conf + * @param array $options By default, the information in your system openssl.conf * is used to initialize the request; you can specify a configuration file * section by setting the config_section_section key of - * configargs. You can also specify an alternative + * options. You can also specify an alternative * openssl configuration file by setting the value of the * config key to the path of the file you want to use. - * The following keys, if present in configargs + * The following keys, if present in options * behave as their equivalents in the openssl.conf, as * listed in the table below. * @@ -123,7 +288,7 @@ function openssl_csr_get_subject($csr, bool $use_shortnames = true): array * * * - * configargs key + * options key * type * openssl.conf equivalent * description @@ -151,14 +316,14 @@ function openssl_csr_get_subject($csr, bool $use_shortnames = true): array * * * private_key_bits - * integer + * int * default_bits * Specifies how many bits should be used to generate a private * key * * * private_key_type - * integer + * int * none * Specifies the type of private key to create. This can be one * of OPENSSL_KEYTYPE_DSA, @@ -170,13 +335,13 @@ function openssl_csr_get_subject($csr, bool $use_shortnames = true): array * * * encrypt_key - * boolean + * bool * encrypt_key * Should an exported key (with passphrase) be encrypted? * * * encrypt_key_cipher - * integer + * int * none * * One of cipher constants. @@ -201,23 +366,23 @@ function openssl_csr_get_subject($csr, bool $use_shortnames = true): array * * * - * @param array $extraattribs extraattribs is used to specify additional - * configuration options for the CSR. Both dn and - * extraattribs are associative arrays whose keys are + * @param array $extra_attributes extra_attributes is used to specify additional + * configuration options for the CSR. Both distinguished_names and + * extra_attributes are associative arrays whose keys are * converted to OIDs and applied to the relevant part of the request. * @return resource Returns the CSR. * @throws OpensslException * */ -function openssl_csr_new(array $dn, &$privkey, array $configargs = null, array $extraattribs = null) +function openssl_csr_new(array $distinguished_names, &$private_key, array $options = null, array $extra_attributes = null) { error_clear_last(); - if ($extraattribs !== null) { - $result = \openssl_csr_new($dn, $privkey, $configargs, $extraattribs); - } elseif ($configargs !== null) { - $result = \openssl_csr_new($dn, $privkey, $configargs); + if ($extra_attributes !== null) { + $result = \openssl_csr_new($distinguished_names, $private_key, $options, $extra_attributes); + } elseif ($options !== null) { + $result = \openssl_csr_new($distinguished_names, $private_key, $options); } else { - $result = \openssl_csr_new($dn, $privkey); + $result = \openssl_csr_new($distinguished_names, $private_key); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -227,38 +392,37 @@ function openssl_csr_new(array $dn, &$privkey, array $configargs = null, array $ /** - * openssl_csr_sign generates an x509 certificate - * resource from the given CSR. + * openssl_csr_sign generates an x509 certificate from the given CSR. * * @param string|resource $csr A CSR previously generated by openssl_csr_new. * It can also be the path to a PEM encoded CSR when specified as * file://path/to/csr or an exported string generated * by openssl_csr_export. - * @param mixed $cacert The generated certificate will be signed by cacert. - * If cacert is NULL, the generated certificate + * @param string|resource|null $ca_certificate The generated certificate will be signed by ca_certificate. + * If ca_certificate is NULL, the generated certificate * will be a self-signed certificate. - * @param string|resource|array $priv_key priv_key is the private key that corresponds to - * cacert. + * @param string|resource|array $private_key private_key is the private key that corresponds to + * ca_certificate. * @param int $days days specifies the length of time for which the * generated certificate will be valid, in days. - * @param array $configargs You can finetune the CSR signing by configargs. + * @param array $options You can finetune the CSR signing by options. * See openssl_csr_new for more information about - * configargs. + * options. * @param int $serial An optional the serial number of issued certificate. If not specified * it will default to 0. - * @return resource Returns an x509 certificate resource on success, FALSE on failure. + * @return resource Returns an OpenSSLCertificate on success, FALSE on failure. * @throws OpensslException * */ -function openssl_csr_sign($csr, $cacert, $priv_key, int $days, array $configargs = null, int $serial = 0) +function openssl_csr_sign($csr, $ca_certificate, $private_key, int $days, array $options = null, int $serial = 0) { error_clear_last(); if ($serial !== 0) { - $result = \openssl_csr_sign($csr, $cacert, $priv_key, $days, $configargs, $serial); - } elseif ($configargs !== null) { - $result = \openssl_csr_sign($csr, $cacert, $priv_key, $days, $configargs); + $result = \openssl_csr_sign($csr, $ca_certificate, $private_key, $days, $options, $serial); + } elseif ($options !== null) { + $result = \openssl_csr_sign($csr, $ca_certificate, $private_key, $days, $options); } else { - $result = \openssl_csr_sign($csr, $cacert, $priv_key, $days); + $result = \openssl_csr_sign($csr, $ca_certificate, $private_key, $days); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -271,23 +435,29 @@ function openssl_csr_sign($csr, $cacert, $priv_key, int $days, array $configargs * Takes a raw or base64 encoded string and decrypts it using a given method and key. * * @param string $data The encrypted message to be decrypted. - * @param string $method The cipher method. For a list of available cipher methods, use + * @param string $cipher_algo The cipher method. For a list of available cipher methods, use * openssl_get_cipher_methods. - * @param string $key The key. + * @param string $passphrase The key. * @param int $options options can be one of * OPENSSL_RAW_DATA, * OPENSSL_ZERO_PADDING. * @param string $iv A non-NULL Initialization Vector. * @param string $tag The authentication tag in AEAD cipher mode. If it is incorrect, the authentication fails and the function returns FALSE. - * @param string $aad Additional authentication data. + * @param string $aad Additional authenticated data. * @return string The decrypted string on success. * @throws OpensslException * */ -function openssl_decrypt(string $data, string $method, string $key, int $options = 0, string $iv = "", string $tag = "", string $aad = ""): string +function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = "", string $tag = null, string $aad = ""): string { error_clear_last(); - $result = \openssl_decrypt($data, $method, $key, $options, $iv, $tag, $aad); + if ($aad !== "") { + $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv, $tag, $aad); + } elseif ($tag !== null) { + $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv, $tag); + } else { + $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv); + } if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -300,16 +470,16 @@ function openssl_decrypt(string $data, string $method, string $key, int $options * often used as an encryption key to secretly communicate with a remote party. * This is known as the Diffie-Hellman key exchange. * - * @param string $pub_key DH Public key of the remote party. - * @param resource $dh_key A local DH private key, corresponding to the public key to be shared with the remote party. + * @param string $public_key DH Public key of the remote party. + * @param resource $private_key A local DH private key, corresponding to the public key to be shared with the remote party. * @return string Returns shared secret on success. * @throws OpensslException * */ -function openssl_dh_compute_key(string $pub_key, $dh_key): string +function openssl_dh_compute_key(string $public_key, $private_key): string { error_clear_last(); - $result = \openssl_dh_compute_key($pub_key, $dh_key); + $result = \openssl_dh_compute_key($public_key, $private_key); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -322,17 +492,79 @@ function openssl_dh_compute_key(string $pub_key, $dh_key): string * and returns a raw or binhex encoded string. * * @param string $data The data. - * @param string $method The digest method to use, e.g. "sha256", see openssl_get_md_methods for a list of available digest methods. - * @param bool $raw_output Setting to TRUE will return as raw output data, otherwise the return + * @param string $digest_algo The digest method to use, e.g. "sha256", see openssl_get_md_methods for a list of available digest methods. + * @param bool $binary Setting to TRUE will return as raw output data, otherwise the return * value is binhex encoded. * @return string Returns the digested hash value on success. * @throws OpensslException * */ -function openssl_digest(string $data, string $method, bool $raw_output = false): string +function openssl_digest(string $data, string $digest_algo, bool $binary = false): string { error_clear_last(); - $result = \openssl_digest($data, $method, $raw_output); + $result = \openssl_digest($data, $digest_algo, $binary); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets the list of available curve names for use in Elliptic curve + * cryptography (ECC) for public/private key operations. The two most widely + * standardized/supported curves are prime256v1 + * (NIST P-256) and secp384r1 (NIST P-384). + * + * Approximate Equivalancies of AES, RSA, DSA and ECC Keysizes + * + * + * + * AES Symmetric Keysize (Bits) + * RSA and DSA Keysize (Bits) + * ECC Keysize (Bits) + * + * + * + * + * 80 + * 1024 + * 160 + * + * + * 112 + * 2048 + * 224 + * + * + * 128 + * 3072 + * 256 + * + * + * 192 + * 7680 + * 384 + * + * + * 256 + * 15360 + * 512 + * + * + * + * + * NIST + * recommends using ECC curves with at least 256 bits. + * + * @return array An array of available curve names. + * @throws OpensslException + * + */ +function openssl_get_curve_names(): array +{ + error_clear_last(); + $result = \openssl_get_curve_names(); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -342,31 +574,37 @@ function openssl_digest(string $data, string $method, bool $raw_output = false): /** * openssl_open opens (decrypts) - * sealed_data using the private key associated with - * the key identifier priv_key_id and the envelope key - * env_key, and fills - * open_data with the decrypted data. + * data using the private key associated with + * the key identifier private_key and the envelope key + * encrypted_key, and fills + * output with the decrypted data. * The envelope key is generated when the * data are sealed and can only be used by one specific private key. See * openssl_seal for more information. * - * @param string $sealed_data - * @param string|null $open_data If the call is successful the opened data is returned in this + * @param string $data + * @param string|null $output If the call is successful the opened data is returned in this * parameter. - * @param string $env_key - * @param string|array|resource $priv_key_id - * @param string $method The cipher method. + * @param string $encrypted_key + * @param string|array|resource $private_key + * @param string $cipher_algo The cipher method. + * + * + * The default value ('RC4') is considered insecure. + * It is strongly recommended to explicitly specify a secure cipher method. + * + * * @param string $iv The initialization vector. * @throws OpensslException * */ -function openssl_open(string $sealed_data, ?string &$open_data, string $env_key, $priv_key_id, string $method = "RC4", string $iv = null): void +function openssl_open(string $data, ?string &$output, string $encrypted_key, $private_key, string $cipher_algo, string $iv = null): void { error_clear_last(); if ($iv !== null) { - $result = \openssl_open($sealed_data, $open_data, $env_key, $priv_key_id, $method, $iv); + $result = \openssl_open($data, $output, $encrypted_key, $private_key, $cipher_algo, $iv); } else { - $result = \openssl_open($sealed_data, $open_data, $env_key, $priv_key_id, $method); + $result = \openssl_open($data, $output, $encrypted_key, $private_key, $cipher_algo); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -383,15 +621,15 @@ function openssl_open(string $sealed_data, ?string &$open_data, string $env_key, * @param int $key_length Length of desired output key. * @param int $iterations The number of iterations desired. NIST * recommends at least 10,000. - * @param string $digest_algorithm Optional hash or digest algorithm from openssl_get_md_methods. Defaults to SHA-1. + * @param string $digest_algo Optional hash or digest algorithm from openssl_get_md_methods. Defaults to SHA-1. * @return string Returns raw binary string. * @throws OpensslException * */ -function openssl_pbkdf2(string $password, string $salt, int $key_length, int $iterations, string $digest_algorithm = "sha1"): string +function openssl_pbkdf2(string $password, string $salt, int $key_length, int $iterations, string $digest_algo = "sha1"): string { error_clear_last(); - $result = \openssl_pbkdf2($password, $salt, $key_length, $iterations, $digest_algorithm); + $result = \openssl_pbkdf2($password, $salt, $key_length, $iterations, $digest_algo); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -401,15 +639,15 @@ function openssl_pbkdf2(string $password, string $salt, int $key_length, int $it /** * openssl_pkcs12_export_to_file stores - * x509 into a file named by - * filename in a PKCS#12 file format. + * certificate into a file named by + * output_filename in a PKCS#12 file format. * - * @param string|resource $x509 See Key/Certificate parameters for a list of valid values. - * @param string $filename Path to the output file. - * @param string|array|resource $priv_key Private key component of PKCS#12 file. + * @param string|resource $certificate See Key/Certificate parameters for a list of valid values. + * @param string $output_filename Path to the output file. + * @param string|array|resource $private_key Private key component of PKCS#12 file. * See Public/Private Key parameters for a list of valid values. - * @param string $pass Encryption password for unlocking the PKCS#12 file. - * @param array $args Optional array, other keys will be ignored. + * @param string $passphrase Encryption password for unlocking the PKCS#12 file. + * @param array $options Optional array, other keys will be ignored. * * * @@ -433,14 +671,10 @@ function openssl_pbkdf2(string $password, string $salt, int $key_length, int $it * @throws OpensslException * */ -function openssl_pkcs12_export_to_file($x509, string $filename, $priv_key, string $pass, array $args = null): void +function openssl_pkcs12_export_to_file($certificate, string $output_filename, $private_key, string $passphrase, array $options = []): void { error_clear_last(); - if ($args !== null) { - $result = \openssl_pkcs12_export_to_file($x509, $filename, $priv_key, $pass, $args); - } else { - $result = \openssl_pkcs12_export_to_file($x509, $filename, $priv_key, $pass); - } + $result = \openssl_pkcs12_export_to_file($certificate, $output_filename, $private_key, $passphrase, $options); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -449,15 +683,15 @@ function openssl_pkcs12_export_to_file($x509, string $filename, $priv_key, strin /** * openssl_pkcs12_export stores - * x509 into a string named by - * out in a PKCS#12 file format. + * certificate into a string named by + * output in a PKCS#12 file format. * - * @param string|resource $x509 See Key/Certificate parameters for a list of valid values. - * @param string|null $out On success, this will hold the PKCS#12. - * @param string|array|resource $priv_key Private key component of PKCS#12 file. + * @param string|resource $certificate See Key/Certificate parameters for a list of valid values. + * @param string|null $output On success, this will hold the PKCS#12. + * @param string|array|resource $private_key Private key component of PKCS#12 file. * See Public/Private Key parameters for a list of valid values. - * @param string $pass Encryption password for unlocking the PKCS#12 file. - * @param array $args Optional array, other keys will be ignored. + * @param string $passphrase Encryption password for unlocking the PKCS#12 file. + * @param array $options Optional array, other keys will be ignored. * * * @@ -481,14 +715,10 @@ function openssl_pkcs12_export_to_file($x509, string $filename, $priv_key, strin * @throws OpensslException * */ -function openssl_pkcs12_export($x509, ?string &$out, $priv_key, string $pass, array $args = null): void +function openssl_pkcs12_export($certificate, ?string &$output, $private_key, string $passphrase, array $options = []): void { error_clear_last(); - if ($args !== null) { - $result = \openssl_pkcs12_export($x509, $out, $priv_key, $pass, $args); - } else { - $result = \openssl_pkcs12_export($x509, $out, $priv_key, $pass); - } + $result = \openssl_pkcs12_export($certificate, $output, $private_key, $passphrase, $options); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -498,18 +728,18 @@ function openssl_pkcs12_export($x509, ?string &$out, $priv_key, string $pass, ar /** * openssl_pkcs12_read parses the PKCS#12 certificate store supplied by * pkcs12 into a array named - * certs. + * certificates. * * @param string $pkcs12 The certificate store contents, not its file name. - * @param array|null $certs On success, this will hold the Certificate Store Data. - * @param string $pass Encryption password for unlocking the PKCS#12 file. + * @param array|null $certificates On success, this will hold the Certificate Store Data. + * @param string $passphrase Encryption password for unlocking the PKCS#12 file. * @throws OpensslException * */ -function openssl_pkcs12_read(string $pkcs12, ?array &$certs, string $pass): void +function openssl_pkcs12_read(string $pkcs12, ?array &$certificates, string $passphrase): void { error_clear_last(); - $result = \openssl_pkcs12_read($pkcs12, $certs, $pass); + $result = \openssl_pkcs12_read($pkcs12, $certificates, $passphrase); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -518,25 +748,25 @@ function openssl_pkcs12_read(string $pkcs12, ?array &$certs, string $pass): void /** * Decrypts the S/MIME encrypted message contained in the file specified by - * infilename using the certificate and its - * associated private key specified by recipcert and - * recipkey. - * - * @param string $infilename - * @param string $outfilename The decrypted message is written to the file specified by - * outfilename. - * @param string|resource $recipcert - * @param string|resource|array $recipkey + * input_filename using the certificate and its + * associated private key specified by certificate and + * private_key. + * + * @param string $input_filename + * @param string $output_filename The decrypted message is written to the file specified by + * output_filename. + * @param string|resource $certificate + * @param string|resource|array $private_key * @throws OpensslException * */ -function openssl_pkcs7_decrypt(string $infilename, string $outfilename, $recipcert, $recipkey = null): void +function openssl_pkcs7_decrypt(string $input_filename, string $output_filename, $certificate, $private_key = null): void { error_clear_last(); - if ($recipkey !== null) { - $result = \openssl_pkcs7_decrypt($infilename, $outfilename, $recipcert, $recipkey); + if ($private_key !== null) { + $result = \openssl_pkcs7_decrypt($input_filename, $output_filename, $certificate, $private_key); } else { - $result = \openssl_pkcs7_decrypt($infilename, $outfilename, $recipcert); + $result = \openssl_pkcs7_decrypt($input_filename, $output_filename, $certificate); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -546,13 +776,13 @@ function openssl_pkcs7_decrypt(string $infilename, string $outfilename, $recipce /** * openssl_pkcs7_encrypt takes the contents of the - * file named infile and encrypts them using an RC2 + * file named input_filename and encrypts them using an RC2 * 40-bit cipher so that they can only be read by the intended recipients - * specified by recipcerts. + * specified by certificate. * - * @param string $infile - * @param string $outfile - * @param string|resource|array $recipcerts Either a lone X.509 certificate, or an array of X.509 certificates. + * @param string $input_filename + * @param string $output_filename + * @param string|resource|array $certificate Either a lone X.509 certificate, or an array of X.509 certificates. * @param array $headers headers is an array of headers that * will be prepended to the data after it has been encrypted. * @@ -562,14 +792,14 @@ function openssl_pkcs7_decrypt(string $infilename, string $outfilename, $recipce * @param int $flags flags can be used to specify options that affect * the encoding process - see PKCS7 * constants. - * @param int $cipherid One of cipher constants. + * @param int $cipher_algo One of cipher constants. * @throws OpensslException * */ -function openssl_pkcs7_encrypt(string $infile, string $outfile, $recipcerts, array $headers, int $flags = 0, int $cipherid = OPENSSL_CIPHER_RC2_40): void +function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, $certificate, array $headers, int $flags = 0, int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): void { error_clear_last(); - $result = \openssl_pkcs7_encrypt($infile, $outfile, $recipcerts, $headers, $flags, $cipherid); + $result = \openssl_pkcs7_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $cipher_algo); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -579,15 +809,15 @@ function openssl_pkcs7_encrypt(string $infile, string $outfile, $recipcerts, arr /** * * - * @param string $infilename - * @param array|null $certs + * @param string $data The string of data you wish to parse (p7b format). + * @param array|null $certificates The array of PEM certificates from the p7b input data. * @throws OpensslException * */ -function openssl_pkcs7_read(string $infilename, ?array &$certs): void +function openssl_pkcs7_read(string $data, ?array &$certificates): void { error_clear_last(); - $result = \openssl_pkcs7_read($infilename, $certs); + $result = \openssl_pkcs7_read($data, $certificates); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -596,35 +826,35 @@ function openssl_pkcs7_read(string $infilename, ?array &$certs): void /** * openssl_pkcs7_sign takes the contents of the file - * named infilename and signs them using the + * named input_filename and signs them using the * certificate and its matching private key specified by - * signcert and privkey + * certificate and private_key * parameters. * - * @param string $infilename The input file you are intending to digitally sign. - * @param string $outfilename The file which the digital signature will be written to. - * @param string|resource $signcert The X.509 certificate used to digitally sign infilename. + * @param string $input_filename The input file you are intending to digitally sign. + * @param string $output_filename The file which the digital signature will be written to. + * @param string|resource $certificate The X.509 certificate used to digitally sign input_filename. * See Key/Certificate parameters for a list of valid values. - * @param string|resource|array $privkey privkey is the private key corresponding to signcert. + * @param string|resource|array $private_key private_key is the private key corresponding to certificate. * See Public/Private Key parameters for a list of valid values. * @param array $headers headers is an array of headers that * will be prepended to the data after it has been signed (see * openssl_pkcs7_encrypt for more information about * the format of this parameter). * @param int $flags flags can be used to alter the output - see PKCS7 constants. - * @param string $extracerts extracerts specifies the name of a file containing + * @param string $untrusted_certificates_filename untrusted_certificates_filename specifies the name of a file containing * a bunch of extra certificates to include in the signature which can for * example be used to help the recipient to verify the certificate that you used. * @throws OpensslException * */ -function openssl_pkcs7_sign(string $infilename, string $outfilename, $signcert, $privkey, array $headers, int $flags = PKCS7_DETACHED, string $extracerts = null): void +function openssl_pkcs7_sign(string $input_filename, string $output_filename, $certificate, $private_key, array $headers, int $flags = PKCS7_DETACHED, string $untrusted_certificates_filename = null): void { error_clear_last(); - if ($extracerts !== null) { - $result = \openssl_pkcs7_sign($infilename, $outfilename, $signcert, $privkey, $headers, $flags, $extracerts); + if ($untrusted_certificates_filename !== null) { + $result = \openssl_pkcs7_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $untrusted_certificates_filename); } else { - $result = \openssl_pkcs7_sign($infilename, $outfilename, $signcert, $privkey, $headers, $flags); + $result = \openssl_pkcs7_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -633,30 +863,54 @@ function openssl_pkcs7_sign(string $infilename, string $outfilename, $signcert, /** + * openssl_pkey_derive takes a set of a public_key + * and private_key and derives a shared secret, for either DH or EC keys. + * + * @param resource $public_key public_key is the public key for the derivation. + * See Public/Private Key parameters for a list of valid values. + * @param resource $private_key private_key is the private key for the derivation. + * See Public/Private Key parameters for a list of valid values. + * @param int $key_length If not zero, will set the desired length of the derived secret. + * @return string The derived secret on success. + * @throws OpensslException + * + */ +function openssl_pkey_derive($public_key, $private_key, int $key_length = 0): string +{ + error_clear_last(); + $result = \openssl_pkey_derive($public_key, $private_key, $key_length); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } + return $result; +} + + +/** * openssl_pkey_export_to_file saves an ascii-armoured * (PEM encoded) rendition of key into the file named - * by outfilename. + * by output_filename. * * @param resource|string|array $key - * @param string $outfilename Path to the output file. - * @param string $passphrase The key can be optionally protected by a + * @param string $output_filename Path to the output file. + * @param string|null $passphrase The key can be optionally protected by a * passphrase. - * @param array $configargs configargs can be used to fine-tune the export + * @param array $options options can be used to fine-tune the export * process by specifying and/or overriding options for the openssl * configuration file. See openssl_csr_new for more - * information about configargs. + * information about options. * @throws OpensslException * */ -function openssl_pkey_export_to_file($key, string $outfilename, string $passphrase = null, array $configargs = null): void +function openssl_pkey_export_to_file($key, string $output_filename, ?string $passphrase = null, array $options = null): void { error_clear_last(); - if ($configargs !== null) { - $result = \openssl_pkey_export_to_file($key, $outfilename, $passphrase, $configargs); + if ($options !== null) { + $result = \openssl_pkey_export_to_file($key, $output_filename, $passphrase, $options); } elseif ($passphrase !== null) { - $result = \openssl_pkey_export_to_file($key, $outfilename, $passphrase); + $result = \openssl_pkey_export_to_file($key, $output_filename, $passphrase); } else { - $result = \openssl_pkey_export_to_file($key, $outfilename); + $result = \openssl_pkey_export_to_file($key, $output_filename); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -667,27 +921,27 @@ function openssl_pkey_export_to_file($key, string $outfilename, string $passphra /** * openssl_pkey_export exports * key as a PEM encoded string and stores it into - * out (which is passed by reference). + * output (which is passed by reference). * * @param resource $key - * @param string|null $out - * @param string $passphrase The key is optionally protected by passphrase. - * @param array $configargs configargs can be used to fine-tune the export + * @param string|null $output + * @param string|null $passphrase The key is optionally protected by passphrase. + * @param array $options options can be used to fine-tune the export * process by specifying and/or overriding options for the openssl * configuration file. See openssl_csr_new for more - * information about configargs. + * information about options. * @throws OpensslException * */ -function openssl_pkey_export($key, ?string &$out, string $passphrase = null, array $configargs = null): void +function openssl_pkey_export($key, ?string &$output, ?string $passphrase = null, array $options = null): void { error_clear_last(); - if ($configargs !== null) { - $result = \openssl_pkey_export($key, $out, $passphrase, $configargs); + if ($options !== null) { + $result = \openssl_pkey_export($key, $output, $passphrase, $options); } elseif ($passphrase !== null) { - $result = \openssl_pkey_export($key, $out, $passphrase); + $result = \openssl_pkey_export($key, $output, $passphrase); } else { - $result = \openssl_pkey_export($key, $out); + $result = \openssl_pkey_export($key, $output); } if ($result === false) { throw OpensslException::createFromPhpError(); @@ -697,9 +951,9 @@ function openssl_pkey_export($key, ?string &$out, string $passphrase = null, arr /** * openssl_pkey_get_private parses - * key and prepares it for use by other functions. + * private_key and prepares it for use by other functions. * - * @param string $key key can be one of the following: + * @param string $private_key private_key can be one of the following: * * a string having the format * file://path/to/file.pem. The named file must @@ -710,14 +964,18 @@ function openssl_pkey_export($key, ?string &$out, string $passphrase = null, arr * * @param string $passphrase The optional parameter passphrase must be used * if the specified key is encrypted (protected by a passphrase). - * @return resource Returns a positive key resource identifier on success. + * @return resource Returns an OpenSSLAsymmetricKey instance on success. * @throws OpensslException * */ -function openssl_pkey_get_private(string $key, string $passphrase = "") +function openssl_pkey_get_private(string $private_key, string $passphrase = null) { error_clear_last(); - $result = \openssl_pkey_get_private($key, $passphrase); + if ($passphrase !== null) { + $result = \openssl_pkey_get_private($private_key, $passphrase); + } else { + $result = \openssl_pkey_get_private($private_key); + } if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -727,12 +985,12 @@ function openssl_pkey_get_private(string $key, string $passphrase = "") /** * openssl_pkey_get_public extracts the public key from - * certificate and prepares it for use by other + * public_key and prepares it for use by other * functions. * - * @param resource|string $certificate certificate can be one of the following: + * @param resource|string $public_key public_key can be one of the following: * - * an X.509 certificate resource + * an OpenSSLAsymmetricKey instance * a string having the format * file://path/to/file.pem. The named file must * contain a PEM encoded certificate/public key (it may contain both). @@ -740,14 +998,14 @@ function openssl_pkey_get_private(string $key, string $passphrase = "") * * A PEM formatted public key. * - * @return resource Returns a positive key resource identifier on success. + * @return resource Returns an OpenSSLAsymmetricKey instance on success. * @throws OpensslException * */ -function openssl_pkey_get_public($certificate) +function openssl_pkey_get_public($public_key) { error_clear_last(); - $result = \openssl_pkey_get_public($certificate); + $result = \openssl_pkey_get_public($public_key); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -756,23 +1014,23 @@ function openssl_pkey_get_public($certificate) /** - * openssl_pkey_new generates a new private and public - * key pair. The public component of the key can be obtained using - * openssl_pkey_get_public. + * openssl_pkey_new generates a new private + * key. + * How to obtain the public component of the key is shown in an example below. * - * @param array $configargs You can finetune the key generation (such as specifying the number of - * bits) using configargs. See + * @param array $options You can finetune the key generation (such as specifying the number of + * bits) using options. See * openssl_csr_new for more information about - * configargs. - * @return resource Returns a resource identifier for the pkey on success. + * options. + * @return resource Returns an OpenSSLAsymmetricKey instance for the pkey on success. * @throws OpensslException * */ -function openssl_pkey_new(array $configargs = null) +function openssl_pkey_new(array $options = null) { error_clear_last(); - if ($configargs !== null) { - $result = \openssl_pkey_new($configargs); + if ($options !== null) { + $result = \openssl_pkey_new($options); } else { $result = \openssl_pkey_new(); } @@ -787,13 +1045,13 @@ function openssl_pkey_new(array $configargs = null) * openssl_private_decrypt decrypts * data that was previously encrypted via * openssl_public_encrypt and stores the result into - * decrypted. + * decrypted_data. * * You can use this function e.g. to decrypt data which is supposed to only be available to you. * * @param string $data - * @param string|null $decrypted - * @param string|resource|array $key key must be the private key corresponding that + * @param string|null $decrypted_data + * @param string|resource|array $private_key private_key must be the private key corresponding that * was used to encrypt the data. * @param int $padding padding can be one of * OPENSSL_PKCS1_PADDING, @@ -803,10 +1061,10 @@ function openssl_pkey_new(array $configargs = null) * @throws OpensslException * */ -function openssl_private_decrypt(string $data, ?string &$decrypted, $key, int $padding = OPENSSL_PKCS1_PADDING): void +function openssl_private_decrypt(string $data, ?string &$decrypted_data, $private_key, int $padding = OPENSSL_PKCS1_PADDING): void { error_clear_last(); - $result = \openssl_private_decrypt($data, $decrypted, $key, $padding); + $result = \openssl_private_decrypt($data, $decrypted_data, $private_key, $padding); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -815,26 +1073,26 @@ function openssl_private_decrypt(string $data, ?string &$decrypted, $key, int $p /** * openssl_private_encrypt encrypts data - * with private key and stores the result into - * crypted. Encrypted data can be decrypted via + * with private private_key and stores the result into + * encrypted_data. Encrypted data can be decrypted via * openssl_public_decrypt. * * This function can be used e.g. to sign data (or its hash) to prove that it * is not written by someone else. * * @param string $data - * @param string|null $crypted - * @param string|resource|array $key + * @param string|null $encrypted_data + * @param string|resource|array $private_key * @param int $padding padding can be one of * OPENSSL_PKCS1_PADDING, * OPENSSL_NO_PADDING. * @throws OpensslException * */ -function openssl_private_encrypt(string $data, ?string &$crypted, $key, int $padding = OPENSSL_PKCS1_PADDING): void +function openssl_private_encrypt(string $data, ?string &$encrypted_data, $private_key, int $padding = OPENSSL_PKCS1_PADDING): void { error_clear_last(); - $result = \openssl_private_encrypt($data, $crypted, $key, $padding); + $result = \openssl_private_encrypt($data, $encrypted_data, $private_key, $padding); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -845,14 +1103,14 @@ function openssl_private_encrypt(string $data, ?string &$crypted, $key, int $pad * openssl_public_decrypt decrypts * data that was previous encrypted via * openssl_private_encrypt and stores the result into - * decrypted. + * decrypted_data. * * You can use this function e.g. to check if the message was written by the * owner of the private key. * * @param string $data - * @param string|null $decrypted - * @param string|resource $key key must be the public key corresponding that + * @param string|null $decrypted_data + * @param string|resource $public_key public_key must be the public key corresponding that * was used to encrypt the data. * @param int $padding padding can be one of * OPENSSL_PKCS1_PADDING, @@ -860,10 +1118,10 @@ function openssl_private_encrypt(string $data, ?string &$crypted, $key, int $pad * @throws OpensslException * */ -function openssl_public_decrypt(string $data, ?string &$decrypted, $key, int $padding = OPENSSL_PKCS1_PADDING): void +function openssl_public_decrypt(string $data, ?string &$decrypted_data, $public_key, int $padding = OPENSSL_PKCS1_PADDING): void { error_clear_last(); - $result = \openssl_public_decrypt($data, $decrypted, $key, $padding); + $result = \openssl_public_decrypt($data, $decrypted_data, $public_key, $padding); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -872,8 +1130,8 @@ function openssl_public_decrypt(string $data, ?string &$decrypted, $key, int $pa /** * openssl_public_encrypt encrypts data - * with public key and stores the result into - * crypted. Encrypted data can be decrypted via + * with public public_key and stores the result into + * encrypted_data. Encrypted data can be decrypted via * openssl_private_decrypt. * * This function can be used e.g. to encrypt message which can be then read @@ -881,8 +1139,8 @@ function openssl_public_decrypt(string $data, ?string &$decrypted, $key, int $pa * in database. * * @param string $data - * @param string|null $crypted This will hold the result of the encryption. - * @param string|resource $key The public key. + * @param string|null $encrypted_data This will hold the result of the encryption. + * @param string|resource $public_key The public key. * @param int $padding padding can be one of * OPENSSL_PKCS1_PADDING, * OPENSSL_SSLV23_PADDING, @@ -891,10 +1149,10 @@ function openssl_public_decrypt(string $data, ?string &$decrypted, $key, int $pa * @throws OpensslException * */ -function openssl_public_encrypt(string $data, ?string &$crypted, $key, int $padding = OPENSSL_PKCS1_PADDING): void +function openssl_public_encrypt(string $data, ?string &$encrypted_data, $public_key, int $padding = OPENSSL_PKCS1_PADDING): void { error_clear_last(); - $result = \openssl_public_encrypt($data, $crypted, $key, $padding); + $result = \openssl_public_encrypt($data, $encrypted_data, $public_key, $padding); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -906,22 +1164,22 @@ function openssl_public_encrypt(string $data, ?string &$crypted, $key, int $padd * determined by the length parameter. * * It also indicates if a cryptographically strong algorithm was used to produce the - * pseudo-random bytes, and does this via the optional crypto_strong + * pseudo-random bytes, and does this via the optional strong_result * parameter. It's rare for this to be FALSE, but some systems may be broken or old. * * @param int $length The length of the desired string of bytes. Must be a positive integer. PHP will * try to cast this parameter to a non-null integer to use it. - * @param bool|null $crypto_strong If passed into the function, this will hold a boolean value that determines + * @param bool|null $strong_result If passed into the function, this will hold a bool value that determines * if the algorithm used was "cryptographically strong", e.g., safe for usage with GPG, * passwords, etc. TRUE if it did, otherwise FALSE * @return string Returns the generated string of bytes on success. * @throws OpensslException * */ -function openssl_random_pseudo_bytes(int $length, ?bool &$crypto_strong = null): string +function openssl_random_pseudo_bytes(int $length, ?bool &$strong_result = null): string { error_clear_last(); - $result = \openssl_random_pseudo_bytes($length, $crypto_strong); + $result = \openssl_random_pseudo_bytes($length, $strong_result); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -931,32 +1189,38 @@ function openssl_random_pseudo_bytes(int $length, ?bool &$crypto_strong = null): /** * openssl_seal seals (encrypts) - * data by using the given method with a randomly generated + * data by using the given cipher_algo with a randomly generated * secret key. The key is encrypted with each of the public keys - * associated with the identifiers in pub_key_ids + * associated with the identifiers in public_key * and each encrypted key is returned - * in env_keys. This means that one can send + * in encrypted_keys. This means that one can send * sealed data to multiple recipients (provided one has obtained their * public keys). Each recipient must receive both the sealed data and * the envelope key that was encrypted with the recipient's public key. * * @param string $data The data to seal. * @param string|null $sealed_data The sealed data. - * @param array $env_keys Array of encrypted keys. - * @param array $pub_key_ids Array of public key resource identifiers. - * @param string $method The cipher method. - * @param string $iv The initialization vector. + * @param array|null $encrypted_keys Array of encrypted keys. + * @param array $public_key Array of OpenSSLAsymmetricKey instances containing public keys. + * @param string $cipher_algo The cipher method. + * + * + * The default value ('RC4') is considered insecure. + * It is strongly recommended to explicitly specify a secure cipher method. + * + * + * @param string|null $iv The initialization vector. * @return int Returns the length of the sealed data on success. * If successful the sealed data is returned in * sealed_data, and the envelope keys in - * env_keys. + * encrypted_keys. * @throws OpensslException * */ -function openssl_seal(string $data, ?string &$sealed_data, array &$env_keys, array $pub_key_ids, string $method = "RC4", string &$iv = null): int +function openssl_seal(string $data, ?string &$sealed_data, ?array &$encrypted_keys, array $public_key, string $cipher_algo, ?string &$iv = null): int { error_clear_last(); - $result = \openssl_seal($data, $sealed_data, $env_keys, $pub_key_ids, $method, $iv); + $result = \openssl_seal($data, $sealed_data, $encrypted_keys, $public_key, $cipher_algo, $iv); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -968,39 +1232,151 @@ function openssl_seal(string $data, ?string &$sealed_data, array &$env_keys, arr * openssl_sign computes a signature for the * specified data by generating a cryptographic * digital signature using the private key associated with - * priv_key_id. Note that the data itself is + * private_key. Note that the data itself is * not encrypted. * * @param string $data The string of data you wish to sign * @param string|null $signature If the call was successful the signature is returned in * signature. - * @param resource|string $priv_key_id resource - a key, returned by openssl_get_privatekey + * @param resource|string $private_key OpenSSLAsymmetricKey - a key, returned by openssl_get_privatekey * * string - a PEM formatted key - * @param int|string $signature_alg int - one of these Signature Algorithms. + * @param int|string $algorithm int - one of these Signature Algorithms. * * string - a valid string returned by openssl_get_md_methods example, "sha256WithRSAEncryption" or "sha384". * @throws OpensslException * */ -function openssl_sign(string $data, ?string &$signature, $priv_key_id, $signature_alg = OPENSSL_ALGO_SHA1): void +function openssl_sign(string $data, ?string &$signature, $private_key, $algorithm = OPENSSL_ALGO_SHA1): void +{ + error_clear_last(); + $result = \openssl_sign($data, $signature, $private_key, $algorithm); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * Exports challenge from encoded signed public key and challenge + * + * @param string $spki Expects a valid signed public key and challenge + * @return string|null Returns the associated challenge string. + * @throws OpensslException + * + */ +function openssl_spki_export_challenge(string $spki): ?string +{ + error_clear_last(); + $result = \openssl_spki_export_challenge($spki); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } + return $result; +} + + +/** + * Exports PEM formatted public key from encoded signed public key and challenge + * + * @param string $spki Expects a valid signed public key and challenge + * @return string|null Returns the associated PEM formatted public key. + * @throws OpensslException + * + */ +function openssl_spki_export(string $spki): ?string +{ + error_clear_last(); + $result = \openssl_spki_export($spki); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } + return $result; +} + + +/** + * Generates a signed public key and challenge using specified hashing algorithm + * + * @param resource $private_key private_key should be set to a private key that was + * previously generated by openssl_pkey_new (or + * otherwise obtained from the other openssl_pkey family of functions). + * The corresponding public portion of the key will be used to sign the + * CSR. + * @param string $challenge The challenge associated to associate with the SPKAC + * @param int $digest_algo The digest algorithm. See openssl_get_md_method(). + * @return string|null Returns a signed public key and challenge string. + * @throws OpensslException + * + */ +function openssl_spki_new($private_key, string $challenge, int $digest_algo = OPENSSL_ALGO_MD5): ?string +{ + error_clear_last(); + $result = \openssl_spki_new($private_key, $challenge, $digest_algo); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } + return $result; +} + + +/** + * Validates the supplied signed public key and challenge + * + * @param string $spki Expects a valid signed public key and challenge + * @throws OpensslException + * + */ +function openssl_spki_verify(string $spki): void +{ + error_clear_last(); + $result = \openssl_spki_verify($spki); + if ($result === false) { + throw OpensslException::createFromPhpError(); + } +} + + +/** + * openssl_verify verifies that the + * signature is correct for the specified + * data using the public key associated with + * public_key. This must be the public key + * corresponding to the private key used for signing. + * + * @param string $data The string of data used to generate the signature previously + * @param string $signature A raw binary string, generated by openssl_sign or similar means + * @param resource|string $public_key OpenSSLAsymmetricKey - a key, returned by openssl_get_publickey + * + * string - a PEM formatted key, example, "-----BEGIN PUBLIC KEY----- + * MIIBCgK..." + * @param int|string $algorithm int - one of these Signature Algorithms. + * + * string - a valid string returned by openssl_get_md_methods example, "sha1WithRSAEncryption" or "sha512". + * @return int Returns 1 if the signature is correct, 0 if it is incorrect, and + * -1. + * @throws OpensslException + * + */ +function openssl_verify(string $data, string $signature, $public_key, $algorithm = OPENSSL_ALGO_SHA1): int { error_clear_last(); - $result = \openssl_sign($data, $signature, $priv_key_id, $signature_alg); + $result = \openssl_verify($data, $signature, $public_key, $algorithm); if ($result === false) { throw OpensslException::createFromPhpError(); } + return $result; } /** * openssl_x509_export_to_file stores - * x509 into a file named by - * outfilename in a PEM encoded format. + * certificate into a file named by + * output_filename in a PEM encoded format. * - * @param string|resource $x509 See Key/Certificate parameters for a list of valid values. - * @param string $outfilename Path to the output file. - * @param bool $notext + * @param string|resource $certificate See Key/Certificate parameters for a list of valid values. + * @param string $output_filename Path to the output file. + * @param bool $no_text * The optional parameter notext affects * the verbosity of the output; if it is FALSE, then additional human-readable * information is included in the output. The default value of @@ -1008,10 +1384,10 @@ function openssl_sign(string $data, ?string &$signature, $priv_key_id, $signatur * @throws OpensslException * */ -function openssl_x509_export_to_file($x509, string $outfilename, bool $notext = true): void +function openssl_x509_export_to_file($certificate, string $output_filename, bool $no_text = true): void { error_clear_last(); - $result = \openssl_x509_export_to_file($x509, $outfilename, $notext); + $result = \openssl_x509_export_to_file($certificate, $output_filename, $no_text); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -1020,12 +1396,12 @@ function openssl_x509_export_to_file($x509, string $outfilename, bool $notext = /** * openssl_x509_export stores - * x509 into a string named by + * certificate into a string named by * output in a PEM encoded format. * - * @param string|resource $x509 See Key/Certificate parameters for a list of valid values. + * @param string|resource $certificate See Key/Certificate parameters for a list of valid values. * @param string|null $output On success, this will hold the PEM. - * @param bool $notext + * @param bool $no_text * The optional parameter notext affects * the verbosity of the output; if it is FALSE, then additional human-readable * information is included in the output. The default value of @@ -1033,10 +1409,10 @@ function openssl_x509_export_to_file($x509, string $outfilename, bool $notext = * @throws OpensslException * */ -function openssl_x509_export($x509, ?string &$output, bool $notext = true): void +function openssl_x509_export($certificate, ?string &$output, bool $no_text = true): void { error_clear_last(); - $result = \openssl_x509_export($x509, $output, $notext); + $result = \openssl_x509_export($certificate, $output, $no_text); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -1045,21 +1421,21 @@ function openssl_x509_export($x509, ?string &$output, bool $notext = true): void /** * openssl_x509_fingerprint returns the digest of - * x509 as a string. + * certificate as a string. * - * @param string|resource $x509 See Key/Certificate parameters for a list of valid values. - * @param string $hash_algorithm The digest method or hash algorithm to use, e.g. "sha256", one of openssl_get_md_methods. - * @param bool $raw_output When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits. - * @return string Returns a string containing the calculated certificate fingerprint as lowercase hexits unless raw_output is set to TRUE in which case the raw binary representation of the message digest is returned. + * @param string|resource $certificate See Key/Certificate parameters for a list of valid values. + * @param string $digest_algo The digest method or hash algorithm to use, e.g. "sha256", one of openssl_get_md_methods. + * @param bool $binary When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits. + * @return string Returns a string containing the calculated certificate fingerprint as lowercase hexits unless binary is set to TRUE in which case the raw binary representation of the message digest is returned. * * Returns FALSE on failure. * @throws OpensslException * */ -function openssl_x509_fingerprint($x509, string $hash_algorithm = "sha1", bool $raw_output = false): string +function openssl_x509_fingerprint($certificate, string $digest_algo = "sha1", bool $binary = false): string { error_clear_last(); - $result = \openssl_x509_fingerprint($x509, $hash_algorithm, $raw_output); + $result = \openssl_x509_fingerprint($certificate, $digest_algo, $binary); if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -1069,18 +1445,18 @@ function openssl_x509_fingerprint($x509, string $hash_algorithm = "sha1", bool $ /** * openssl_x509_read parses the certificate supplied by - * x509certdata and returns a resource identifier for + * certificate and returns an OpenSSLCertificate object for * it. * - * @param string|resource $x509certdata X509 certificate. See Key/Certificate parameters for a list of valid values. - * @return resource Returns a resource identifier on success. + * @param string|resource $certificate X509 certificate. See Key/Certificate parameters for a list of valid values. + * @return resource Returns an OpenSSLCertificate on success. * @throws OpensslException * */ -function openssl_x509_read($x509certdata) +function openssl_x509_read($certificate) { error_clear_last(); - $result = \openssl_x509_read($x509certdata); + $result = \openssl_x509_read($certificate); if ($result === false) { throw OpensslException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/outcontrol.php b/vendor/thecodingmachine/safe/generated/outcontrol.php index fce7c6dd8..e52c4a081 100644 --- a/vendor/thecodingmachine/safe/generated/outcontrol.php +++ b/vendor/thecodingmachine/safe/generated/outcontrol.php @@ -5,6 +5,29 @@ 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(); + $result = \ob_clean(); + if ($result === 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 @@ -56,6 +79,134 @@ function ob_end_flush(): void /** + * 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(); + $result = \ob_flush(); + if ($result === false) { + throw OutcontrolException::createFromPhpError(); + } +} + + +/** + * 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 string|array|callable|null $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) { + $result = \ob_start($callback, $chunk_size, $flags); + } elseif ($chunk_size !== 0) { + $result = \ob_start($callback, $chunk_size); + } elseif ($callback !== null) { + $result = \ob_start($callback); + } else { + $result = \ob_start(); + } + if ($result === 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 diff --git a/vendor/thecodingmachine/safe/generated/password.php b/vendor/thecodingmachine/safe/generated/password.php deleted file mode 100644 index 3808e02b9..000000000 --- a/vendor/thecodingmachine/safe/generated/password.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\PasswordException; - -/** - * password_hash creates a new password hash using a strong one-way hashing - * algorithm. password_hash is compatible with crypt. - * Therefore, password hashes created by crypt can be used with - * password_hash. - * - * - * - * - * PASSWORD_DEFAULT - Use the bcrypt algorithm (default as of PHP 5.5.0). - * Note that this constant is designed to change over time as new and stronger algorithms are added - * to PHP. For that reason, the length of the result from using this identifier can change over - * time. Therefore, it is recommended to store the result in a database column that can expand - * beyond 60 characters (255 characters would be a good choice). - * - * - * - * - * PASSWORD_BCRYPT - Use the CRYPT_BLOWFISH algorithm to - * create the hash. This will produce a standard crypt compatible hash using - * the "$2y$" identifier. The result will always be a 60 character string. - * - * - * - * - * PASSWORD_ARGON2I - Use the Argon2i hashing algorithm to create the hash. - * This algorithm is only available if PHP has been compiled with Argon2 support. - * - * - * - * - * PASSWORD_ARGON2ID - Use the Argon2id hashing algorithm to create the hash. - * This algorithm is only available if PHP has been compiled with Argon2 support. - * - * - * - * - * - * - * - * salt (string) - to manually provide a salt to use when hashing the password. - * Note that this will override and prevent a salt from being automatically generated. - * - * - * If omitted, a random salt will be generated by password_hash for - * each password hashed. This is the intended mode of operation. - * - * - * - * The salt option has been deprecated as of PHP 7.0.0. It is now - * preferred to simply use the salt that is generated by default. - * - * - * - * - * - * cost (integer) - which denotes the algorithmic cost that should be used. - * Examples of these values can be found on the crypt page. - * - * - * If omitted, a default value of 10 will be used. This is a good - * baseline cost, but you may want to consider increasing it depending on your hardware. - * - * - * - * - * - * - * - * memory_cost (integer) - Maximum memory (in kibibytes) that may - * be used to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_MEMORY_COST. - * - * - * - * - * time_cost (integer) - Maximum amount of time it may - * take to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_TIME_COST. - * - * - * - * - * threads (integer) - Number of threads to use for computing - * the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_THREADS. - * - * - * - * - * @param string $password The user's password. - * - * Using the PASSWORD_BCRYPT as the - * algorithm, will result - * in the password parameter being truncated to a - * maximum length of 72 characters. - * @param int|string|null $algo A password algorithm constant denoting the algorithm to use when hashing the password. - * @param array $options An associative array containing options. See the password algorithm constants for documentation on the supported options for each algorithm. - * - * If omitted, a random salt will be created and the default cost will be - * used. - * @return string Returns the hashed password. - * - * The used algorithm, cost and salt are returned as part of the hash. Therefore, - * all information that's needed to verify the hash is included in it. This allows - * the password_verify function to verify the hash without - * needing separate storage for the salt or algorithm information. - * @throws PasswordException - * - */ -function password_hash(string $password, $algo, array $options = null): string -{ - error_clear_last(); - if ($options !== null) { - $result = \password_hash($password, $algo, $options); - } else { - $result = \password_hash($password, $algo); - } - if ($result === false) { - throw PasswordException::createFromPhpError(); - } - return $result; -} diff --git a/vendor/thecodingmachine/safe/generated/pcntl.php b/vendor/thecodingmachine/safe/generated/pcntl.php index 1cb721e22..d05f7ff3d 100644 --- a/vendor/thecodingmachine/safe/generated/pcntl.php +++ b/vendor/thecodingmachine/safe/generated/pcntl.php @@ -5,58 +5,27 @@ namespace Safe; use Safe\Exceptions\PcntlException; /** - * Executes the program with the given arguments. - * - * @param string $path path must be the path to a binary executable or a - * script with a valid path pointing to an executable in the shebang ( - * #!/usr/local/bin/perl for example) as the first line. See your system's - * man execve(2) page for additional information. - * @param array $args args is an array of argument strings passed to the - * program. - * @param array $envs envs is an array of strings which are passed as - * environment to the program. The array is in the format of name => value, - * the key being the name of the environmental variable and the value being - * the value of that variable. - * @throws PcntlException - * - */ -function pcntl_exec(string $path, array $args = null, array $envs = null): void -{ - error_clear_last(); - if ($envs !== null) { - $result = \pcntl_exec($path, $args, $envs); - } elseif ($args !== null) { - $result = \pcntl_exec($path, $args); - } else { - $result = \pcntl_exec($path); - } - if ($result === false) { - throw PcntlException::createFromPhpError(); - } -} - - -/** * pcntl_getpriority gets the priority of - * pid. Because priority levels can differ between + * 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 $pid If not specified, the pid of the current process is used. - * @param int $process_identifier One of PRIO_PGRP, PRIO_USER - * or PRIO_PROCESS. + * @param int $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 $pid = null, int $process_identifier = PRIO_PROCESS): int +function pcntl_getpriority(int $process_id = null, int $mode = PRIO_PROCESS): int { error_clear_last(); - if ($process_identifier !== PRIO_PROCESS) { - $result = \pcntl_getpriority($pid, $process_identifier); - } elseif ($pid !== null) { - $result = \pcntl_getpriority($pid); + if ($mode !== PRIO_PROCESS) { + $result = \pcntl_getpriority($process_id, $mode); + } elseif ($process_id !== null) { + $result = \pcntl_getpriority($process_id); } else { $result = \pcntl_getpriority(); } @@ -69,7 +38,7 @@ function pcntl_getpriority(int $pid = null, int $process_identifier = PRIO_PROCE /** * pcntl_setpriority sets the priority of - * pid. + * process_id. * * @param int $priority priority is generally a value in the range * -20 to 20. The default priority @@ -77,19 +46,20 @@ function pcntl_getpriority(int $pid = null, int $process_identifier = PRIO_PROCE * 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 $pid If not specified, the pid of the current process is used. - * @param int $process_identifier One of PRIO_PGRP, PRIO_USER - * or PRIO_PROCESS. + * @param int $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 $pid = null, int $process_identifier = PRIO_PROCESS): void +function pcntl_setpriority(int $priority, int $process_id = null, int $mode = PRIO_PROCESS): void { error_clear_last(); - if ($process_identifier !== PRIO_PROCESS) { - $result = \pcntl_setpriority($priority, $pid, $process_identifier); - } elseif ($pid !== null) { - $result = \pcntl_setpriority($priority, $pid); + if ($mode !== PRIO_PROCESS) { + $result = \pcntl_setpriority($priority, $process_id, $mode); + } elseif ($process_id !== null) { + $result = \pcntl_setpriority($priority, $process_id); } else { $result = \pcntl_setpriority($priority); } @@ -118,10 +88,65 @@ function pcntl_signal_dispatch(): void /** + * 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(); + $result = \pcntl_signal($signal, $handler, $restart_syscalls); + if ($result === false) { + throw PcntlException::createFromPhpError(); + } +} + + +/** * The pcntl_sigprocmask function adds, removes or sets blocked - * signals, depending on the how parameter. + * signals, depending on the mode parameter. * - * @param int $how Sets the behavior of pcntl_sigprocmask. Possible + * @param int $mode Sets the behavior of pcntl_sigprocmask. Possible * values: * * SIG_BLOCK: Add the signals to the @@ -131,16 +156,16 @@ function pcntl_signal_dispatch(): void * SIG_SETMASK: Replace the currently * blocked signals by the given list of signals. * - * @param array $set List of signals. - * @param array|null $oldset The oldset parameter is set to an array + * @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 $how, array $set, ?array &$oldset = null): void +function pcntl_sigprocmask(int $mode, array $signals, ?array &$old_signals = null): void { error_clear_last(); - $result = \pcntl_sigprocmask($how, $set, $oldset); + $result = \pcntl_sigprocmask($mode, $signals, $old_signals); if ($result === false) { throw PcntlException::createFromPhpError(); } @@ -148,17 +173,81 @@ function pcntl_sigprocmask(int $how, array $set, ?array &$oldset = null): void /** + * 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(); + $result = \pcntl_sigtimedwait($signals, $info, $seconds, $nanoseconds); + if ($result === false) { + throw PcntlException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 * - * @param int $errno - * @return string Returns error description on success. + * @return int Returns a signal number on success. * @throws PcntlException * */ -function pcntl_strerror(int $errno): string +function pcntl_sigwaitinfo(array $signals, ?array &$info = []): int { error_clear_last(); - $result = \pcntl_strerror($errno); + $result = \pcntl_sigwaitinfo($signals, $info); if ($result === false) { throw PcntlException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/pcre.php b/vendor/thecodingmachine/safe/generated/pcre.php index c40f14cc2..4ebb9839e 100644 --- a/vendor/thecodingmachine/safe/generated/pcre.php +++ b/vendor/thecodingmachine/safe/generated/pcre.php @@ -5,6 +5,32 @@ 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(); + $result = \preg_grep($pattern, $array, $flags); + if ($result === false) { + throw PcreException::createFromPhpError(); + } + return $result; +} + + +/** * Searches subject for all matches to the regular * expression given in pattern and puts them in * matches in the order specified by @@ -15,7 +41,7 @@ use Safe\Exceptions\PcreException; * * @param string $pattern The pattern to search for, as a string. * @param string $subject The input string. - * @param array $matches Array of all matches in multi-dimensional array ordered according to + * @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 @@ -343,11 +369,11 @@ use Safe\Exceptions\PcreException; * * * The above example will output: - * @return int Returns the number of full pattern matches (which might be zero). + * @return int|null 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 = PREG_PATTERN_ORDER, int $offset = 0): int +function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): ?int { error_clear_last(); $result = \preg_match_all($pattern, $subject, $matches, $flags, $offset); @@ -364,7 +390,7 @@ function preg_match_all(string $pattern, string $subject, array &$matches = null * * @param string $pattern The pattern to search for, as a string. * @param string $subject The input string. - * @param array $matches If matches is provided, then it is filled with + * @param string[]|null $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 @@ -584,7 +610,7 @@ function preg_match_all(string $pattern, string $subject, array &$matches = null * @throws PcreException * */ -function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int +function preg_match(string $pattern, string $subject, ?iterable &$matches = null, int $flags = 0, int $offset = 0): int { error_clear_last(); $result = \preg_match($pattern, $subject, $matches, $flags, $offset); diff --git a/vendor/thecodingmachine/safe/generated/pdf.php b/vendor/thecodingmachine/safe/generated/pdf.php deleted file mode 100644 index d039b27a9..000000000 --- a/vendor/thecodingmachine/safe/generated/pdf.php +++ /dev/null @@ -1,1553 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\PdfException; - -/** - * Activates a previously created structure element or other content item. - * Returns TRUE on success. - * - * @param resource $pdfdoc - * @param int $id - * @throws PdfException - * - */ -function PDF_activate_item($pdfdoc, int $id): void -{ - error_clear_last(); - $result = \PDF_activate_item($pdfdoc, $id); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Add a link annotation to a target within the current PDF file. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_create_action with type=GoTo - * and PDF_create_annotation with - * type=Link instead. - * - * @param resource $pdfdoc - * @param float $lowerleftx - * @param float $lowerlefty - * @param float $upperrightx - * @param float $upperrighty - * @param int $page - * @param string $dest - * @throws PdfException - * - */ -function PDF_add_locallink($pdfdoc, float $lowerleftx, float $lowerlefty, float $upperrightx, float $upperrighty, int $page, string $dest): void -{ - error_clear_last(); - $result = \PDF_add_locallink($pdfdoc, $lowerleftx, $lowerlefty, $upperrightx, $upperrighty, $page, $dest); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Creates a named destination on an arbitrary page in the current document. - * Returns TRUE on success. - * - * @param resource $pdfdoc - * @param string $name - * @param string $optlist - * @throws PdfException - * - */ -function PDF_add_nameddest($pdfdoc, string $name, string $optlist): void -{ - error_clear_last(); - $result = \PDF_add_nameddest($pdfdoc, $name, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets an annotation for the current page. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_create_annotation with - * type=Text instead. - * - * @param resource $pdfdoc - * @param float $llx - * @param float $lly - * @param float $urx - * @param float $ury - * @param string $contents - * @param string $title - * @param string $icon - * @param int $open - * @throws PdfException - * - */ -function PDF_add_note($pdfdoc, float $llx, float $lly, float $urx, float $ury, string $contents, string $title, string $icon, int $open): void -{ - error_clear_last(); - $result = \PDF_add_note($pdfdoc, $llx, $lly, $urx, $ury, $contents, $title, $icon, $open); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Add a file link annotation to a PDF target. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_create_action with - * type=GoToR and - * PDF_create_annotation with - * type=Link instead. - * - * @param resource $pdfdoc - * @param float $bottom_left_x - * @param float $bottom_left_y - * @param float $up_right_x - * @param float $up_right_y - * @param string $filename - * @param int $page - * @param string $dest - * @throws PdfException - * - */ -function PDF_add_pdflink($pdfdoc, float $bottom_left_x, float $bottom_left_y, float $up_right_x, float $up_right_y, string $filename, int $page, string $dest): void -{ - error_clear_last(); - $result = \PDF_add_pdflink($pdfdoc, $bottom_left_x, $bottom_left_y, $up_right_x, $up_right_y, $filename, $page, $dest); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Adds an existing image as thumbnail for the current page. - * Returns TRUE on success. - * - * @param resource $pdfdoc - * @param int $image - * @throws PdfException - * - */ -function PDF_add_thumbnail($pdfdoc, int $image): void -{ - error_clear_last(); - $result = \PDF_add_thumbnail($pdfdoc, $image); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Adds a weblink annotation to a target url on the Web. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_create_action with type=URI - * and PDF_create_annotation with - * type=Link instead. - * - * @param resource $pdfdoc - * @param float $lowerleftx - * @param float $lowerlefty - * @param float $upperrightx - * @param float $upperrighty - * @param string $url - * @throws PdfException - * - */ -function PDF_add_weblink($pdfdoc, float $lowerleftx, float $lowerlefty, float $upperrightx, float $upperrighty, string $url): void -{ - error_clear_last(); - $result = \PDF_add_weblink($pdfdoc, $lowerleftx, $lowerlefty, $upperrightx, $upperrighty, $url); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Adds a file attachment annotation. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_create_annotation with - * type=FileAttachment instead. - * - * @param resource $pdfdoc - * @param float $llx - * @param float $lly - * @param float $urx - * @param float $ury - * @param string $filename - * @param string $description - * @param string $author - * @param string $mimetype - * @param string $icon - * @throws PdfException - * - */ -function PDF_attach_file($pdfdoc, float $llx, float $lly, float $urx, float $ury, string $filename, string $description, string $author, string $mimetype, string $icon): void -{ - error_clear_last(); - $result = \PDF_attach_file($pdfdoc, $llx, $lly, $urx, $ury, $filename, $description, $author, $mimetype, $icon); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Starts a layer for subsequent output on the page. Returns TRUE on success. - * - * This function requires PDF 1.5. - * - * @param resource $pdfdoc - * @param int $layer - * @throws PdfException - * - */ -function PDF_begin_layer($pdfdoc, int $layer): void -{ - error_clear_last(); - $result = \PDF_begin_layer($pdfdoc, $layer); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Adds a new page to the document, and specifies various options. - * The parameters width and height - * are the dimensions of the new page in points. Returns TRUE on success. - * - * - * Common Page Sizes in Points - * - * - * - * name - * size - * - * - * - * - * A0 - * 2380 x 3368 - * - * - * A1 - * 1684 x 2380 - * - * - * A2 - * 1190 x 1684 - * - * - * A3 - * 842 x 1190 - * - * - * A4 - * 595 x 842 - * - * - * A5 - * 421 x 595 - * - * - * A6 - * 297 x 421 - * - * - * B5 - * 501 x 709 - * - * - * letter (8.5" x 11") - * 612 x 792 - * - * - * legal (8.5" x 14") - * 612 x 1008 - * - * - * ledger (17" x 11") - * 1224 x 792 - * - * - * 11" x 17" - * 792 x 1224 - * - * - * - * - * - * @param resource $pdfdoc - * @param float $width - * @param float $height - * @param string $optlist - * @throws PdfException - * - */ -function PDF_begin_page_ext($pdfdoc, float $width, float $height, string $optlist): void -{ - error_clear_last(); - $result = \PDF_begin_page_ext($pdfdoc, $width, $height, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Adds a new page to the document. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_begin_page_ext instead. - * - * @param resource $pdfdoc - * @param float $width - * @param float $height - * @throws PdfException - * - */ -function PDF_begin_page($pdfdoc, float $width, float $height): void -{ - error_clear_last(); - $result = \PDF_begin_page($pdfdoc, $width, $height); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Adds a circle. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param float $x - * @param float $y - * @param float $r - * @throws PdfException - * - */ -function PDF_circle($pdfdoc, float $x, float $y, float $r): void -{ - error_clear_last(); - $result = \PDF_circle($pdfdoc, $x, $y, $r); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Uses the current path as clipping path, and terminate the path. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_clip($p): void -{ - error_clear_last(); - $result = \PDF_clip($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Closes the page handle, and frees all page-related resources. Returns TRUE on success. - * - * @param resource $p - * @param int $page - * @throws PdfException - * - */ -function PDF_close_pdi_page($p, int $page): void -{ - error_clear_last(); - $result = \PDF_close_pdi_page($p, $page); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Closes all open page handles, and closes the input PDF document. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 7, - * use PDF_close_pdi_document instead. - * - * @param resource $p - * @param int $doc - * @throws PdfException - * - */ -function PDF_close_pdi($p, int $doc): void -{ - error_clear_last(); - $result = \PDF_close_pdi($p, $doc); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Closes the generated PDF file, and frees all document-related resources. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_end_document instead. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_close($p): void -{ - error_clear_last(); - $result = \PDF_close($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Closes the path, fills, and strokes it. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_closepath_fill_stroke($p): void -{ - error_clear_last(); - $result = \PDF_closepath_fill_stroke($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Closes the path, and strokes it. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_closepath_stroke($p): void -{ - error_clear_last(); - $result = \PDF_closepath_stroke($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Closes the current path. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_closepath($p): void -{ - error_clear_last(); - $result = \PDF_closepath($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Concatenates a matrix to the current transformation matrix (CTM). Returns TRUE on success. - * - * @param resource $p - * @param float $a - * @param float $b - * @param float $c - * @param float $d - * @param float $e - * @param float $f - * @throws PdfException - * - */ -function PDF_concat($p, float $a, float $b, float $c, float $d, float $e, float $f): void -{ - error_clear_last(); - $result = \PDF_concat($p, $a, $b, $c, $d, $e, $f); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Prints text at the next line. Returns TRUE on success. - * - * @param resource $p - * @param string $text - * @throws PdfException - * - */ -function PDF_continue_text($p, string $text): void -{ - error_clear_last(); - $result = \PDF_continue_text($p, $text); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Draws a Bezier curve from the current point, using 3 more control points. - * Returns TRUE on success. - * - * @param resource $p - * @param float $x1 - * @param float $y1 - * @param float $x2 - * @param float $y2 - * @param float $x3 - * @param float $y3 - * @throws PdfException - * - */ -function PDF_curveto($p, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3): void -{ - error_clear_last(); - $result = \PDF_curveto($p, $x1, $y1, $x2, $y2, $x3, $y3); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Deletes a PDFlib object, and frees all internal resources. Returns TRUE on success. - * - * @param resource $pdfdoc - * @throws PdfException - * - */ -function PDF_delete($pdfdoc): void -{ - error_clear_last(); - $result = \PDF_delete($pdfdoc); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Deactivates all active layers. Returns TRUE on success. - * - * This function requires PDF 1.5. - * - * @param resource $pdfdoc - * @throws PdfException - * - */ -function PDF_end_layer($pdfdoc): void -{ - error_clear_last(); - $result = \PDF_end_layer($pdfdoc); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Finishes a page, and applies various options. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param string $optlist - * @throws PdfException - * - */ -function PDF_end_page_ext($pdfdoc, string $optlist): void -{ - error_clear_last(); - $result = \PDF_end_page_ext($pdfdoc, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Finishes the page. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_end_page($p): void -{ - error_clear_last(); - $result = \PDF_end_page($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Finishes the pattern definition. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_end_pattern($p): void -{ - error_clear_last(); - $result = \PDF_end_pattern($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Finishes a template definition. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_end_template($p): void -{ - error_clear_last(); - $result = \PDF_end_template($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Fills and strokes the current path with the current fill and stroke color. - * Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_fill_stroke($p): void -{ - error_clear_last(); - $result = \PDF_fill_stroke($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Fills the interior of the current path with the current fill color. - * Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_fill($p): void -{ - error_clear_last(); - $result = \PDF_fill($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Places an image or template on the page, subject to various options. - * Returns TRUE on success. - * - * @param resource $pdfdoc - * @param int $image - * @param float $x - * @param float $y - * @param string $optlist - * @throws PdfException - * - */ -function PDF_fit_image($pdfdoc, int $image, float $x, float $y, string $optlist): void -{ - error_clear_last(); - $result = \PDF_fit_image($pdfdoc, $image, $x, $y, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Places an imported PDF page on the page, subject to various options. - * Returns TRUE on success. - * - * @param resource $pdfdoc - * @param int $page - * @param float $x - * @param float $y - * @param string $optlist - * @throws PdfException - * - */ -function PDF_fit_pdi_page($pdfdoc, int $page, float $x, float $y, string $optlist): void -{ - error_clear_last(); - $result = \PDF_fit_pdi_page($pdfdoc, $page, $x, $y, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Places a single line of text on the page, subject to various options. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param string $text - * @param float $x - * @param float $y - * @param string $optlist - * @throws PdfException - * - */ -function PDF_fit_textline($pdfdoc, string $text, float $x, float $y, string $optlist): void -{ - error_clear_last(); - $result = \PDF_fit_textline($pdfdoc, $text, $x, $y, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Reset all color and graphics state parameters to their defaults. - * Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_initgraphics($p): void -{ - error_clear_last(); - $result = \PDF_initgraphics($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Draws a line from the current point to another point. Returns TRUE on success. - * - * @param resource $p - * @param float $x - * @param float $y - * @throws PdfException - * - */ -function PDF_lineto($p, float $x, float $y): void -{ - error_clear_last(); - $result = \PDF_lineto($p, $x, $y); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Finds a built-in spot color name, or makes a named spot color from the - * current fill color. Returns TRUE on success. - * - * @param resource $p - * @param string $spotname - * @return int - * @throws PdfException - * - */ -function PDF_makespotcolor($p, string $spotname): int -{ - error_clear_last(); - $result = \PDF_makespotcolor($p, $spotname); - if ($result === false) { - throw PdfException::createFromPhpError(); - } - return $result; -} - - -/** - * Sets the current point for graphics output. Returns TRUE on success. - * - * @param resource $p - * @param float $x - * @param float $y - * @throws PdfException - * - */ -function PDF_moveto($p, float $x, float $y): void -{ - error_clear_last(); - $result = \PDF_moveto($p, $x, $y); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Creates a new PDF file using the supplied file name. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * PDF_begin_document instead. - * - * @param resource $p - * @param string $filename - * @throws PdfException - * - */ -function PDF_open_file($p, string $filename): void -{ - error_clear_last(); - $result = \PDF_open_file($p, $filename); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Places an image and scales it. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 5, use - * PDF_fit_image instead. - * - * @param resource $pdfdoc - * @param int $image - * @param float $x - * @param float $y - * @param float $scale - * @throws PdfException - * - */ -function PDF_place_image($pdfdoc, int $image, float $x, float $y, float $scale): void -{ - error_clear_last(); - $result = \PDF_place_image($pdfdoc, $image, $x, $y, $scale); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Places a PDF page and scales it. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 5, use - * PDF_fit_pdi_page instead. - * - * @param resource $pdfdoc - * @param int $page - * @param float $x - * @param float $y - * @param float $sx - * @param float $sy - * @throws PdfException - * - */ -function PDF_place_pdi_page($pdfdoc, int $page, float $x, float $y, float $sx, float $sy): void -{ - error_clear_last(); - $result = \PDF_place_pdi_page($pdfdoc, $page, $x, $y, $sx, $sy); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Draws a rectangle. Returns TRUE on success. - * - * @param resource $p - * @param float $x - * @param float $y - * @param float $width - * @param float $height - * @throws PdfException - * - */ -function PDF_rect($p, float $x, float $y, float $width, float $height): void -{ - error_clear_last(); - $result = \PDF_rect($p, $x, $y, $width, $height); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Restores the most recently saved graphics state. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_restore($p): void -{ - error_clear_last(); - $result = \PDF_restore($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Rotates the coordinate system. Returns TRUE on success. - * - * @param resource $p - * @param float $phi - * @throws PdfException - * - */ -function PDF_rotate($p, float $phi): void -{ - error_clear_last(); - $result = \PDF_rotate($p, $phi); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Saves the current graphics state. Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_save($p): void -{ - error_clear_last(); - $result = \PDF_save($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Scales the coordinate system. Returns TRUE on success. - * - * @param resource $p - * @param float $sx - * @param float $sy - * @throws PdfException - * - */ -function PDF_scale($p, float $sx, float $sy): void -{ - error_clear_last(); - $result = \PDF_scale($p, $sx, $sy); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the border color for all kinds of annotations. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * the option annotcolor in - * PDF_create_annotation instead. - * - * @param resource $p - * @param float $red - * @param float $green - * @param float $blue - * @throws PdfException - * - */ -function PDF_set_border_color($p, float $red, float $green, float $blue): void -{ - error_clear_last(); - $result = \PDF_set_border_color($p, $red, $green, $blue); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the border dash style for all kinds of annotations. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * the option dasharray in - * PDF_create_annotation instead. - * - * @param resource $pdfdoc - * @param float $black - * @param float $white - * @throws PdfException - * - */ -function PDF_set_border_dash($pdfdoc, float $black, float $white): void -{ - error_clear_last(); - $result = \PDF_set_border_dash($pdfdoc, $black, $white); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the border style for all kinds of annotations. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 6, use - * the options borderstyle and - * linewidth in - * PDF_create_annotation instead. - * - * @param resource $pdfdoc - * @param string $style - * @param float $width - * @throws PdfException - * - */ -function PDF_set_border_style($pdfdoc, string $style, float $width): void -{ - error_clear_last(); - $result = \PDF_set_border_style($pdfdoc, $style, $width); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Fill document information field key with - * value. Returns TRUE on success. - * - * @param resource $p - * @param string $key - * @param string $value - * @throws PdfException - * - */ -function PDF_set_info($p, string $key, string $value): void -{ - error_clear_last(); - $result = \PDF_set_info($p, $key, $value); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Defines hierarchical and group relationships among layers. Returns TRUE on success. - * - * This function requires PDF 1.5. - * - * @param resource $pdfdoc - * @param string $type - * @param string $optlist - * @throws PdfException - * - */ -function PDF_set_layer_dependency($pdfdoc, string $type, string $optlist): void -{ - error_clear_last(); - $result = \PDF_set_layer_dependency($pdfdoc, $type, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets some PDFlib parameter with string type. Returns TRUE on success. - * - * @param resource $p - * @param string $key - * @param string $value - * @throws PdfException - * - */ -function PDF_set_parameter($p, string $key, string $value): void -{ - error_clear_last(); - $result = \PDF_set_parameter($p, $key, $value); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the position for text output on the page. Returns TRUE on success. - * - * @param resource $p - * @param float $x - * @param float $y - * @throws PdfException - * - */ -function PDF_set_text_pos($p, float $x, float $y): void -{ - error_clear_last(); - $result = \PDF_set_text_pos($p, $x, $y); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the value of some PDFlib parameter with numerical type. Returns TRUE on success. - * - * @param resource $p - * @param string $key - * @param float $value - * @throws PdfException - * - */ -function PDF_set_value($p, string $key, float $value): void -{ - error_clear_last(); - $result = \PDF_set_value($p, $key, $value); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current color space and color. Returns TRUE on success. - * - * @param resource $p - * @param string $fstype - * @param string $colorspace - * @param float $c1 - * @param float $c2 - * @param float $c3 - * @param float $c4 - * @throws PdfException - * - */ -function PDF_setcolor($p, string $fstype, string $colorspace, float $c1, float $c2, float $c3, float $c4): void -{ - error_clear_last(); - $result = \PDF_setcolor($p, $fstype, $colorspace, $c1, $c2, $c3, $c4); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current dash pattern to b black - * and w white units. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param float $b - * @param float $w - * @throws PdfException - * - */ -function PDF_setdash($pdfdoc, float $b, float $w): void -{ - error_clear_last(); - $result = \PDF_setdash($pdfdoc, $b, $w); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets a dash pattern defined by an option list. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param string $optlist - * @throws PdfException - * - */ -function PDF_setdashpattern($pdfdoc, string $optlist): void -{ - error_clear_last(); - $result = \PDF_setdashpattern($pdfdoc, $optlist); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the flatness parameter. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param float $flatness - * @throws PdfException - * - */ -function PDF_setflat($pdfdoc, float $flatness): void -{ - error_clear_last(); - $result = \PDF_setflat($pdfdoc, $flatness); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current font in the specified fontsize, using a - * font handle returned by PDF_load_font. - * Returns TRUE on success. - * - * @param resource $pdfdoc - * @param int $font - * @param float $fontsize - * @throws PdfException - * - */ -function PDF_setfont($pdfdoc, int $font, float $fontsize): void -{ - error_clear_last(); - $result = \PDF_setfont($pdfdoc, $font, $fontsize); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current fill color to a gray value between 0 and 1 inclusive. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 4, use - * PDF_setcolor instead. - * - * @param resource $p - * @param float $g - * @throws PdfException - * - */ -function PDF_setgray_fill($p, float $g): void -{ - error_clear_last(); - $result = \PDF_setgray_fill($p, $g); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current stroke color to a gray value between 0 and 1 inclusive. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 4, use - * PDF_setcolor instead. - * - * @param resource $p - * @param float $g - * @throws PdfException - * - */ -function PDF_setgray_stroke($p, float $g): void -{ - error_clear_last(); - $result = \PDF_setgray_stroke($p, $g); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current fill and stroke color to a gray value between 0 and 1 inclusive. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 4, use - * PDF_setcolor instead. - * - * @param resource $p - * @param float $g - * @throws PdfException - * - */ -function PDF_setgray($p, float $g): void -{ - error_clear_last(); - $result = \PDF_setgray($p, $g); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the linejoin parameter to specify the shape - * at the corners of paths that are stroked. Returns TRUE on success. - * - * @param resource $p - * @param int $value - * @throws PdfException - * - */ -function PDF_setlinejoin($p, int $value): void -{ - error_clear_last(); - $result = \PDF_setlinejoin($p, $value); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current line width. Returns TRUE on success. - * - * @param resource $p - * @param float $width - * @throws PdfException - * - */ -function PDF_setlinewidth($p, float $width): void -{ - error_clear_last(); - $result = \PDF_setlinewidth($p, $width); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Explicitly sets the current transformation matrix. Returns TRUE on success. - * - * @param resource $p - * @param float $a - * @param float $b - * @param float $c - * @param float $d - * @param float $e - * @param float $f - * @throws PdfException - * - */ -function PDF_setmatrix($p, float $a, float $b, float $c, float $d, float $e, float $f): void -{ - error_clear_last(); - $result = \PDF_setmatrix($p, $a, $b, $c, $d, $e, $f); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the miter limit.Returns TRUE on success. - * - * @param resource $pdfdoc - * @param float $miter - * @throws PdfException - * - */ -function PDF_setmiterlimit($pdfdoc, float $miter): void -{ - error_clear_last(); - $result = \PDF_setmiterlimit($pdfdoc, $miter); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current fill color to the supplied RGB values. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 4, use - * PDF_setcolor instead. - * - * @param resource $p - * @param float $red - * @param float $green - * @param float $blue - * @throws PdfException - * - */ -function PDF_setrgbcolor_fill($p, float $red, float $green, float $blue): void -{ - error_clear_last(); - $result = \PDF_setrgbcolor_fill($p, $red, $green, $blue); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current stroke color to the supplied RGB values. Returns TRUE on success. - * - * This function is deprecated since PDFlib version 4, use - * PDF_setcolor instead. - * - * @param resource $p - * @param float $red - * @param float $green - * @param float $blue - * @throws PdfException - * - */ -function PDF_setrgbcolor_stroke($p, float $red, float $green, float $blue): void -{ - error_clear_last(); - $result = \PDF_setrgbcolor_stroke($p, $red, $green, $blue); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Sets the current fill and stroke color to the supplied RGB values. - * Returns TRUE on success. - * - * This function is deprecated since PDFlib version 4, use - * PDF_setcolor instead. - * - * @param resource $p - * @param float $red - * @param float $green - * @param float $blue - * @throws PdfException - * - */ -function PDF_setrgbcolor($p, float $red, float $green, float $blue): void -{ - error_clear_last(); - $result = \PDF_setrgbcolor($p, $red, $green, $blue); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Prints text in the current font. Returns TRUE on success. - * - * @param resource $p - * @param string $text - * @param float $x - * @param float $y - * @throws PdfException - * - */ -function PDF_show_xy($p, string $text, float $x, float $y): void -{ - error_clear_last(); - $result = \PDF_show_xy($p, $text, $x, $y); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Prints text in the current font and size at - * the current position. Returns TRUE on success. - * - * @param resource $pdfdoc - * @param string $text - * @throws PdfException - * - */ -function PDF_show($pdfdoc, string $text): void -{ - error_clear_last(); - $result = \PDF_show($pdfdoc, $text); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Skews the coordinate system in x and y direction by alpha - * and beta degrees, respectively. Returns TRUE on success. - * - * @param resource $p - * @param float $alpha - * @param float $beta - * @throws PdfException - * - */ -function PDF_skew($p, float $alpha, float $beta): void -{ - error_clear_last(); - $result = \PDF_skew($p, $alpha, $beta); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} - - -/** - * Strokes the path with the current color and line width, and clear it. - * Returns TRUE on success. - * - * @param resource $p - * @throws PdfException - * - */ -function PDF_stroke($p): void -{ - error_clear_last(); - $result = \PDF_stroke($p); - if ($result === false) { - throw PdfException::createFromPhpError(); - } -} diff --git a/vendor/thecodingmachine/safe/generated/pgsql.php b/vendor/thecodingmachine/safe/generated/pgsql.php index 007faacbb..14b5548de 100644 --- a/vendor/thecodingmachine/safe/generated/pgsql.php +++ b/vendor/thecodingmachine/safe/generated/pgsql.php @@ -10,7 +10,7 @@ use Safe\Exceptions\PgsqlException; * or pg_send_execute. You cannot cancel a query executed using * pg_query. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @throws PgsqlException * */ @@ -25,65 +25,6 @@ function pg_cancel_query($connection): void /** - * PostgreSQL supports automatic character set conversion between - * server and client for certain character sets. - * pg_client_encoding returns the client - * encoding as a string. The returned string will be one of the - * standard PostgreSQL encoding identifiers. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return string The client encoding. - * @throws PgsqlException - * - */ -function pg_client_encoding($connection = null): string -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_client_encoding($connection); - } else { - $result = \pg_client_encoding(); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * pg_close closes the non-persistent - * connection to a PostgreSQL database associated with the given - * connection resource. - * - * If there is open large object resource on the connection, do not - * close the connection before closing all large object resources. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @throws PgsqlException - * - */ -function pg_close($connection = null): void -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_close($connection); - } else { - $result = \pg_close(); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } -} - - -/** * pg_connect opens a connection to a * PostgreSQL database specified by the * connection_string. @@ -92,7 +33,7 @@ function pg_close($connection = null): void * the same connection_string as an existing connection, the * existing connection will be returned unless you pass * PGSQL_CONNECT_FORCE_NEW as - * connect_type. + * flags. * * The old syntax with multiple parameters * $conn = pg_connect("host", "port", "options", "tty", "dbname") @@ -118,7 +59,7 @@ function pg_close($connection = null): void * * The options parameter can be used to set command line parameters * to be invoked by the server. - * @param int $connect_type If PGSQL_CONNECT_FORCE_NEW is passed, then a new connection + * @param int $flags If PGSQL_CONNECT_FORCE_NEW is passed, then a new connection * is created, even if the connection_string is identical to * an existing connection. * @@ -126,18 +67,14 @@ function pg_close($connection = null): void * connection is established asynchronously. The state of the connection * can then be checked via pg_connect_poll or * pg_connection_status. - * @return resource PostgreSQL connection resource on success, FALSE on failure. + * @return resource Returns an PgSql\Connection instance on success. * @throws PgsqlException * */ -function pg_connect(string $connection_string, int $connect_type = null) +function pg_connect(string $connection_string, int $flags = 0) { error_clear_last(); - if ($connect_type !== null) { - $result = \pg_connect($connection_string, $connect_type); - } else { - $result = \pg_connect($connection_string); - } + $result = \pg_connect($connection_string, $flags); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -149,7 +86,7 @@ function pg_connect(string $connection_string, int $connect_type = null) * pg_connection_reset resets the connection. * It is useful for error recovery. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @throws PgsqlException * */ @@ -165,29 +102,29 @@ function pg_connection_reset($connection): void /** * pg_convert checks and converts the values in - * assoc_array into suitable values for use in an SQL + * values into suitable values for use in an SQL * statement. Precondition for pg_convert is the * existence of a table table_name which has at least - * as many columns as assoc_array has elements. The + * as many columns as values has elements. The * fieldnames in table_name must match the indices in - * assoc_array and the corresponding datatypes must be + * values and the corresponding datatypes must be * compatible. Returns an array with the converted values on success, FALSE * otherwise. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table against which to convert types. - * @param array $assoc_array Data to be converted. - * @param int $options Any number of PGSQL_CONV_IGNORE_DEFAULT, + * @param array $values Data to be converted. + * @param int $flags Any number of PGSQL_CONV_IGNORE_DEFAULT, * PGSQL_CONV_FORCE_NULL or * PGSQL_CONV_IGNORE_NOT_NULL, combined. * @return array An array of converted values. * @throws PgsqlException * */ -function pg_convert($connection, string $table_name, array $assoc_array, int $options = 0): array +function pg_convert($connection, string $table_name, array $values, int $flags = 0): array { error_clear_last(); - $result = \pg_convert($connection, $table_name, $assoc_array, $options); + $result = \pg_convert($connection, $table_name, $values, $flags); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -200,29 +137,23 @@ function pg_convert($connection, string $table_name, array $assoc_array, int $op * rows. It issues a COPY FROM SQL command * internally to insert records. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table into which to copy the rows. * @param array $rows An array of data to be copied into table_name. * Each value in rows becomes a row in table_name. * Each value in rows should be a delimited string of the values * to insert into each field. Values should be linefeed terminated. - * @param string $delimiter The token that separates values for each field in each element of - * rows. Default is TAB. + * @param string $separator The token that separates values for each field in each element of + * rows. Default is \t. * @param string $null_as How SQL NULL values are represented in the - * rows. Default is \N ("\\N"). + * rows. Default is \\N ("\\\\N"). * @throws PgsqlException * */ -function pg_copy_from($connection, string $table_name, array $rows, string $delimiter = null, string $null_as = null): void +function pg_copy_from($connection, string $table_name, array $rows, string $separator = "\t", string $null_as = "\\\\N"): void { error_clear_last(); - if ($null_as !== null) { - $result = \pg_copy_from($connection, $table_name, $rows, $delimiter, $null_as); - } elseif ($delimiter !== null) { - $result = \pg_copy_from($connection, $table_name, $rows, $delimiter); - } else { - $result = \pg_copy_from($connection, $table_name, $rows); - } + $result = \pg_copy_from($connection, $table_name, $rows, $separator, $null_as); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -234,56 +165,20 @@ function pg_copy_from($connection, string $table_name, array $rows, string $deli * issues COPY TO SQL command internally to * retrieve records. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table from which to copy the data into rows. - * @param string $delimiter The token that separates values for each field in each element of - * rows. Default is TAB. + * @param string $separator The token that separates values for each field in each element of + * rows. Default is \t. * @param string $null_as How SQL NULL values are represented in the - * rows. Default is \N ("\\N"). + * rows. Default is \\N ("\\\\N"). * @return array An array with one element for each line of COPY data. - * It returns FALSE on failure. * @throws PgsqlException * */ -function pg_copy_to($connection, string $table_name, string $delimiter = null, string $null_as = null): array +function pg_copy_to($connection, string $table_name, string $separator = "\t", string $null_as = "\\\\N"): array { error_clear_last(); - if ($null_as !== null) { - $result = \pg_copy_to($connection, $table_name, $delimiter, $null_as); - } elseif ($delimiter !== null) { - $result = \pg_copy_to($connection, $table_name, $delimiter); - } else { - $result = \pg_copy_to($connection, $table_name); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * pg_dbname returns the name of the database - * that the given PostgreSQL connection - * resource. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return string A string containing the name of the database the - * connection is to. - * @throws PgsqlException - * - */ -function pg_dbname($connection = null): string -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_dbname($connection); - } else { - $result = \pg_dbname(); - } + $result = \pg_copy_to($connection, $table_name, $separator, $null_as); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -293,46 +188,43 @@ function pg_dbname($connection = null): string /** * pg_delete deletes records from a table - * specified by the keys and values - * in assoc_array. If options - * is specified, pg_convert is applied - * to assoc_array with the specified options. + * specified by the keys and values in conditions. * - * If options is specified, + * If flags is specified, * pg_convert is applied to - * assoc_array with the specified flags. + * conditions with the specified flags. * - * By default pg_delete passes raw values. Values - * must be escaped or PGSQL_DML_ESCAPE option must be - * specified. PGSQL_DML_ESCAPE quotes and escapes - * parameters/identifiers. Therefore, table/column names became case - * sensitive. + * By default pg_delete passes raw values. + * Values must be escaped or the PGSQL_DML_ESCAPE flag + * must be specified in flags. + * PGSQL_DML_ESCAPE quotes and escapes parameters/identifiers. + * Therefore, table/column names become case sensitive. * * Note that neither escape nor prepared query can protect LIKE query, * JSON, Array, Regex, etc. These parameters should be handled * according to their contexts. i.e. Escape/validate values. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table from which to delete rows. - * @param array $assoc_array An array whose keys are field names in the table table_name, + * @param array $conditions An array whose keys are field names in the table table_name, * and whose values are the values of those fields that are to be deleted. - * @param int $options Any number of PGSQL_CONV_FORCE_NULL, + * @param int $flags Any number of PGSQL_CONV_FORCE_NULL, * PGSQL_DML_NO_CONV, * PGSQL_DML_ESCAPE, * PGSQL_DML_EXEC, * PGSQL_DML_ASYNC or * PGSQL_DML_STRING combined. If PGSQL_DML_STRING is part of the - * options then query string is returned. When PGSQL_DML_NO_CONV + * flags then query string is returned. When PGSQL_DML_NO_CONV * or PGSQL_DML_ESCAPE is set, it does not call pg_convert internally. * @return mixed Returns TRUE on success. Returns string if PGSQL_DML_STRING is passed - * via options. + * via flags. * @throws PgsqlException * */ -function pg_delete($connection, string $table_name, array $assoc_array, int $options = PGSQL_DML_EXEC) +function pg_delete($connection, string $table_name, array $conditions, int $flags = PGSQL_DML_EXEC) { error_clear_last(); - $result = \pg_delete($connection, $table_name, $assoc_array, $options); + $result = \pg_delete($connection, $table_name, $conditions, $flags); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -348,10 +240,11 @@ function pg_delete($connection, string $table_name, array $assoc_array, int $opt * must be issued, otherwise the PostgreSQL server may get out of * sync with the frontend and will report an error. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is NULL, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @throws PgsqlException * */ @@ -385,10 +278,11 @@ function pg_end_copy($connection = null): void * The parameters are identical to pg_query_params, except that the name of a * prepared statement is given instead of a query string. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $stmtname The name of the prepared statement to execute. if * "" is specified, then the unnamed statement is executed. The name must have * been previously prepared using pg_prepare, @@ -399,7 +293,7 @@ function pg_end_copy($connection = null): void * must match the number of placeholders. * * Elements are converted to strings by calling this function. - * @return resource A query result resource on success. + * @return resource An PgSql\Result instance on success. * @throws PgsqlException * */ @@ -423,73 +317,23 @@ function pg_execute($connection = null, string $stmtname = null, array $params = /** - * pg_field_name returns the name of the field - * occupying the given field_number in the - * given PostgreSQL result resource. Field - * numbering starts from 0. - * - * @param resource $result PostgreSQL query result resource, returned by pg_query, - * pg_query_params or pg_execute - * (among others). - * @param int $field_number Field number, starting from 0. - * @return string The field name. - * @throws PgsqlException - * - */ -function pg_field_name($result, int $field_number): string -{ - error_clear_last(); - $result = \pg_field_name($result, $field_number); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** * pg_field_table returns the name of the table that field * belongs to, or the table's oid if oid_only is TRUE. * - * @param resource $result PostgreSQL query result resource, returned by pg_query, - * pg_query_params or pg_execute - * (among others). - * @param int $field_number Field number, starting from 0. + * @param resource $result An PgSql\Result instance, returned by pg_query, + * pg_query_params or pg_execute(among others). + * @param int $field Field number, starting from 0. * @param bool $oid_only By default the tables name that field belongs to is returned but * if oid_only is set to TRUE, then the * oid will instead be returned. - * @return mixed On success either the fields table name or oid. Or, FALSE on failure. - * @throws PgsqlException - * - */ -function pg_field_table($result, int $field_number, bool $oid_only = false) -{ - error_clear_last(); - $result = \pg_field_table($result, $field_number, $oid_only); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * pg_field_type returns a string containing the - * base type name of the given field_number in the - * given PostgreSQL result resource. - * - * @param resource $result PostgreSQL query result resource, returned by pg_query, - * pg_query_params or pg_execute - * (among others). - * @param int $field_number Field number, starting from 0. - * @return string A string containing the base name of the field's type. + * @return mixed On success either the fields table name or oid. * @throws PgsqlException * */ -function pg_field_type($result, int $field_number): string +function pg_field_table($result, int $field, bool $oid_only = false) { error_clear_last(); - $result = \pg_field_type($result, $field_number); + $result = \pg_field_table($result, $field, $oid_only); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -501,7 +345,7 @@ function pg_field_type($result, int $field_number): string * pg_flush flushes any outbound query data waiting to be * sent on the connection. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @return mixed Returns TRUE if the flush was successful or no data was waiting to be * flushed, 0 if part of the pending data was flushed but * more remains. @@ -521,15 +365,14 @@ function pg_flush($connection) /** * pg_free_result frees the memory and data associated with the - * specified PostgreSQL query result resource. + * specified PgSql\Result instance. * * This function need only be called if memory * consumption during script execution is a problem. Otherwise, all result memory will * be automatically freed when the script ends. * - * @param resource $result PostgreSQL query result resource, returned by pg_query, - * pg_query_params or pg_execute - * (among others). + * @param resource $result An PgSql\Result instance, returned by pg_query, + * pg_query_params or pg_execute(among others). * @throws PgsqlException * */ @@ -545,13 +388,14 @@ function pg_free_result($result): void /** * pg_host returns the host name of the given - * PostgreSQL connection resource is + * PostgreSQL connection instance is * connected to. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is NULL, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @return string A string containing the name of the host the * connection is to. * @throws PgsqlException @@ -565,7 +409,7 @@ function pg_host($connection = null): string } else { $result = \pg_host(); } - if ($result === false) { + if ($result === '') { throw PgsqlException::createFromPhpError(); } return $result; @@ -574,124 +418,45 @@ function pg_host($connection = null): string /** * pg_insert inserts the values - * of assoc_array into the table specified - * by table_name. If options - * is specified, pg_convert is applied - * to assoc_array with the specified options. + * of values into the table specified + * by table_name. * - * If options is specified, + * If flags is specified, * pg_convert is applied to - * assoc_array with the specified flags. + * values with the specified flags. * - * By default pg_insert passes raw values. Values - * must be escaped or PGSQL_DML_ESCAPE option must be - * specified. PGSQL_DML_ESCAPE quotes and escapes - * parameters/identifiers. Therefore, table/column names became case - * sensitive. + * By default pg_insert passes raw values. + * Values must be escaped or the PGSQL_DML_ESCAPE flag + * must be specified in flags. + * PGSQL_DML_ESCAPE quotes and escapes parameters/identifiers. + * Therefore, table/column names become case sensitive. * * Note that neither escape nor prepared query can protect LIKE query, * JSON, Array, Regex, etc. These parameters should be handled * according to their contexts. i.e. Escape/validate values. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table into which to insert rows. The table table_name must at least - * have as many columns as assoc_array has elements. - * @param array $assoc_array An array whose keys are field names in the table table_name, + * have as many columns as values has elements. + * @param array $values An array whose keys are field names in the table table_name, * and whose values are the values of those fields that are to be inserted. - * @param int $options Any number of PGSQL_CONV_OPTS, + * @param int $flags Any number of PGSQL_CONV_OPTS, * PGSQL_DML_NO_CONV, * PGSQL_DML_ESCAPE, * PGSQL_DML_EXEC, * PGSQL_DML_ASYNC or * PGSQL_DML_STRING combined. If PGSQL_DML_STRING is part of the - * options then query string is returned. When PGSQL_DML_NO_CONV + * flags then query string is returned. When PGSQL_DML_NO_CONV * or PGSQL_DML_ESCAPE is set, it does not call pg_convert internally. - * @return mixed Returns the connection resource on success. Returns string if PGSQL_DML_STRING is passed - * via options. - * @throws PgsqlException - * - */ -function pg_insert($connection, string $table_name, array $assoc_array, int $options = PGSQL_DML_EXEC) -{ - error_clear_last(); - $result = \pg_insert($connection, $table_name, $assoc_array, $options); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * pg_last_error returns the last error message - * for a given connection. - * - * Error messages may be overwritten by internal PostgreSQL (libpq) - * function calls. It may not return an appropriate error message if - * multiple errors occur inside a PostgreSQL module function. - * - * Use pg_result_error, pg_result_error_field, - * pg_result_status and - * pg_connection_status for better error handling. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return string A string containing the last error message on the - * given connection. + * @return mixed Returns TRUE on success.. Or returns a string on success if PGSQL_DML_STRING is passed + * via flags. * @throws PgsqlException * */ -function pg_last_error($connection = null): string +function pg_insert($connection, string $table_name, array $values, int $flags = PGSQL_DML_EXEC) { error_clear_last(); - if ($connection !== null) { - $result = \pg_last_error($connection); - } else { - $result = \pg_last_error(); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * pg_last_notice returns the last notice - * message from the PostgreSQL server on the specified - * connection. The PostgreSQL server sends notice - * messages in several cases, for instance when creating a SERIAL - * column in a table. - * - * With pg_last_notice, you can avoid issuing useless - * queries by checking whether or not the notice is related to your transaction. - * - * Notice message tracking can be set to optional by setting 1 for - * pgsql.ignore_notice in php.ini. - * - * Notice message logging can be set to optional by setting 0 for - * pgsql.log_notice in php.ini. - * Unless pgsql.ignore_notice is set - * to 0, notice message cannot be logged. - * - * @param resource $connection PostgreSQL database connection resource. - * @param int $option One of PGSQL_NOTICE_LAST (to return last notice), - * PGSQL_NOTICE_ALL (to return all notices), - * or PGSQL_NOTICE_CLEAR (to clear notices). - * @return string A string containing the last notice on the - * given connection with - * PGSQL_NOTICE_LAST, - * an array with PGSQL_NOTICE_ALL, - * a boolean with PGSQL_NOTICE_CLEAR. - * @throws PgsqlException - * - */ -function pg_last_notice($connection, int $option = PGSQL_NOTICE_LAST): string -{ - error_clear_last(); - $result = \pg_last_notice($connection, $option); + $result = \pg_insert($connection, $table_name, $values, $flags); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -719,10 +484,9 @@ function pg_last_notice($connection, int $option = PGSQL_NOTICE_LAST): string * the value of the most recently used sequence in the session. This avoids * the need for naming the sequence, table or column altogether. * - * @param resource $result PostgreSQL query result resource, returned by pg_query, - * pg_query_params or pg_execute - * (among others). - * @return string A string containing the OID assigned to the most recently inserted + * @param resource $result An PgSql\Result instance, returned by pg_query, + * pg_query_params or pg_execute(among others). + * @return string An int or string containing the OID assigned to the most recently inserted * row in the specified connection or * no available OID. * @throws PgsqlException @@ -740,21 +504,19 @@ function pg_last_oid($result): string /** - * pg_lo_close closes a large - * object. large_object is a resource for the - * large object from pg_lo_open. + * pg_lo_close closes a large object. * * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $large_object PostgreSQL large object (LOB) resource, returned by pg_lo_open. + * @param resource $lob An PgSql\Lob instance, returned by pg_lo_open. * @throws PgsqlException * */ -function pg_lo_close($large_object): void +function pg_lo_close($lob): void { error_clear_last(); - $result = \pg_lo_close($large_object); + $result = \pg_lo_close($lob); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -769,10 +531,11 @@ function pg_lo_close($large_object): void * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param int $oid The OID of the large object in the database. * @param string $pathname The full path and file name of the file in which to write the * large object on the client filesystem. @@ -805,16 +568,17 @@ function pg_lo_export($connection = null, int $oid = null, string $pathname = nu * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $pathname The full path and file name of the file on the client * filesystem from which to read the large object data. - * @param mixed $object_id If an object_id is given the function + * @param $object_id If an object_id is given the function * will try to create a large object with this id, else a free * object id is assigned by the server. The parameter - * was added in PHP 5.3 and relies on functionality that first + * relies on functionality that first * appeared in PostgreSQL 8.1. * @return int The OID of the newly created large object. * @throws PgsqlException @@ -841,19 +605,20 @@ function pg_lo_import($connection = null, string $pathname = null, $object_id = /** * pg_lo_open opens a large object in the database - * and returns large object resource so that it can be manipulated. + * and returns an PgSql\Lob instance so that it can be manipulated. * * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param int $oid The OID of the large object in the database. * @param string $mode Can be either "r" for read-only, "w" for write only or "rw" for read and * write. - * @return resource A large object resource. + * @return resource An PgSql\Lob instance. * @throws PgsqlException * */ @@ -869,49 +634,24 @@ function pg_lo_open($connection, int $oid, string $mode) /** - * pg_lo_read_all reads a large object and passes - * it straight through to the browser after sending all pending - * headers. Mainly intended for sending binary data like images or - * sound. - * - * To use the large object interface, it is necessary to - * enclose it within a transaction block. - * - * @param resource $large_object PostgreSQL large object (LOB) resource, returned by pg_lo_open. - * @return int Number of bytes read. - * @throws PgsqlException - * - */ -function pg_lo_read_all($large_object): int -{ - error_clear_last(); - $result = \pg_lo_read_all($large_object); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** * pg_lo_read reads at most - * len bytes from a large object and + * length bytes from a large object and * returns it as a string. * * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $large_object PostgreSQL large object (LOB) resource, returned by pg_lo_open. - * @param int $len An optional maximum number of bytes to return. - * @return string A string containing len bytes from the + * @param resource $lob An PgSql\Lob instance, returned by pg_lo_open. + * @param int $length An optional maximum number of bytes to return. + * @return string A string containing length bytes from the * large object. * @throws PgsqlException * */ -function pg_lo_read($large_object, int $len = 8192): string +function pg_lo_read($lob, int $length = 8192): string { error_clear_last(); - $result = \pg_lo_read($large_object, $len); + $result = \pg_lo_read($lob, $length); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -920,13 +660,12 @@ function pg_lo_read($large_object, int $len = 8192): string /** - * pg_lo_seek seeks a position within a large object - * resource. + * pg_lo_seek seeks a position within an PgSql\Lob instance. * * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $large_object PostgreSQL large object (LOB) resource, returned by pg_lo_open. + * @param resource $lob An PgSql\Lob instance, returned by pg_lo_open. * @param int $offset The number of bytes to seek. * @param int $whence One of the constants PGSQL_SEEK_SET (seek from object start), * PGSQL_SEEK_CUR (seek from current position) @@ -934,10 +673,10 @@ function pg_lo_read($large_object, int $len = 8192): string * @throws PgsqlException * */ -function pg_lo_seek($large_object, int $offset, int $whence = PGSQL_SEEK_CUR): void +function pg_lo_seek($lob, int $offset, int $whence = SEEK_CUR): void { error_clear_last(); - $result = \pg_lo_seek($large_object, $offset, $whence); + $result = \pg_lo_seek($lob, $offset, $whence); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -945,21 +684,20 @@ function pg_lo_seek($large_object, int $offset, int $whence = PGSQL_SEEK_CUR): v /** - * pg_lo_truncate truncates a large object - * resource. + * pg_lo_truncate truncates an PgSql\Lob instance. * * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $large_object PostgreSQL large object (LOB) resource, returned by pg_lo_open. + * @param resource $lob An PgSql\Lob instance, returned by pg_lo_open. * @param int $size The number of bytes to truncate. * @throws PgsqlException * */ -function pg_lo_truncate($large_object, int $size): void +function pg_lo_truncate($lob, int $size): void { error_clear_last(); - $result = \pg_lo_truncate($large_object, $size); + $result = \pg_lo_truncate($lob, $size); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -973,10 +711,11 @@ function pg_lo_truncate($large_object, int $size): void * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param int $oid The OID of the large object in the database. * @throws PgsqlException * @@ -998,24 +737,24 @@ function pg_lo_unlink($connection, int $oid): void * To use the large object interface, it is necessary to * enclose it within a transaction block. * - * @param resource $large_object PostgreSQL large object (LOB) resource, returned by pg_lo_open. - * @param string $data The data to be written to the large object. If len is - * specified and is less than the length of data, only - * len bytes will be written. - * @param int $len An optional maximum number of bytes to write. Must be greater than zero + * @param resource $lob An PgSql\Lob instance, returned by pg_lo_open. + * @param string $data The data to be written to the large object. If length is + * an int and is less than the length of data, only + * length bytes will be written. + * @param int $length An optional maximum number of bytes to write. Must be greater than zero * and no greater than the length of data. Defaults to * the length of data. * @return int The number of bytes written to the large object. * @throws PgsqlException * */ -function pg_lo_write($large_object, string $data, int $len = null): int +function pg_lo_write($lob, string $data, int $length = null): int { error_clear_last(); - if ($len !== null) { - $result = \pg_lo_write($large_object, $data, $len); + if ($length !== null) { + $result = \pg_lo_write($lob, $data, $length); } else { - $result = \pg_lo_write($large_object, $data); + $result = \pg_lo_write($lob, $data); } if ($result === false) { throw PgsqlException::createFromPhpError(); @@ -1028,7 +767,7 @@ function pg_lo_write($large_object, string $data, int $len = null): int * pg_meta_data returns table definition for * table_name as an array. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name The name of the table. * @param bool $extended Flag for returning extended meta data. Default to FALSE. * @return array An array of the table definition. @@ -1047,35 +786,6 @@ function pg_meta_data($connection, string $table_name, bool $extended = false): /** - * pg_options will return a string containing - * the options specified on the given PostgreSQL - * connection resource. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return string A string containing the connection - * options. - * @throws PgsqlException - * - */ -function pg_options($connection = null): string -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_options($connection); - } else { - $result = \pg_options(); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** * Looks up a current parameter setting of the server. * * Certain parameter values are reported by the server automatically at @@ -1099,10 +809,11 @@ function pg_options($connection = null): string * anyway. Applications are encouraged to use pg_parameter_status rather than ad * hoc code to determine these values. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $param_name Possible param_name values include server_version, * server_encoding, client_encoding, * is_superuser, session_authorization, @@ -1132,14 +843,14 @@ function pg_parameter_status($connection = null, string $param_name = null): str /** * pg_pconnect opens a connection to a - * PostgreSQL database. It returns a connection resource that is + * PostgreSQL database. It returns an PgSql\Connection instance that is * needed by other PostgreSQL functions. * * If a second call is made to pg_pconnect with * the same connection_string as an existing connection, the * existing connection will be returned unless you pass * PGSQL_CONNECT_FORCE_NEW as - * connect_type. + * flags. * * To enable persistent connection, the pgsql.allow_persistent * php.ini directive must be set to "On" (which is the default). @@ -1167,21 +878,17 @@ function pg_parameter_status($connection = null, string $param_name = null): str * requiressl (deprecated in favor of sslmode), and * service. Which of these arguments exist depends * on your PostgreSQL version. - * @param int $connect_type If PGSQL_CONNECT_FORCE_NEW is passed, then a new connection + * @param int $flags If PGSQL_CONNECT_FORCE_NEW is passed, then a new connection * is created, even if the connection_string is identical to * an existing connection. - * @return resource PostgreSQL connection resource on success, FALSE on failure. + * @return resource Returns an PgSql\Connection instance on success. * @throws PgsqlException * */ -function pg_pconnect(string $connection_string, int $connect_type = null) +function pg_pconnect(string $connection_string, int $flags = 0) { error_clear_last(); - if ($connect_type !== null) { - $result = \pg_pconnect($connection_string, $connect_type); - } else { - $result = \pg_pconnect($connection_string); - } + $result = \pg_pconnect($connection_string, $flags); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -1193,10 +900,11 @@ function pg_pconnect(string $connection_string, int $connect_type = null) * pg_ping pings a database connection and tries to * reconnect it if it is broken. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is NULL, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @throws PgsqlException * */ @@ -1215,35 +923,6 @@ function pg_ping($connection = null): void /** - * pg_port returns the port number that the - * given PostgreSQL connection resource is - * connected to. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return int An int containing the port number of the database - * server the connection is to. - * @throws PgsqlException - * - */ -function pg_port($connection = null): int -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_port($connection); - } else { - $result = \pg_port(); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** * pg_prepare creates a prepared statement for later execution with * pg_execute or pg_send_execute. * This feature allows commands that will be used repeatedly to @@ -1264,17 +943,18 @@ function pg_port($connection = null): int * is no PHP function for deleting a prepared statement, the SQL DEALLOCATE * statement can be used for that purpose. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $stmtname The name to give the prepared statement. Must be unique per-connection. If * "" is specified, then an unnamed statement is created, overwriting any * previously defined unnamed statement. * @param string $query The parameterized SQL statement. Must contain only a single statement. * (multiple statements separated by semi-colons are not allowed.) If any parameters * are used, they are referred to as $1, $2, etc. - * @return resource A query result resource on success. + * @return resource An PgSql\Result instance on success. * @throws PgsqlException * */ @@ -1310,10 +990,11 @@ function pg_prepare($connection = null, string $stmtname = null, string $query = * is to use pg_copy_from. This is a far simpler * interface. * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $data A line of text to be sent directly to the PostgreSQL backend. A NULL * terminator is added automatically. * @throws PgsqlException @@ -1360,10 +1041,11 @@ function pg_put_line($connection = null, string $data = null): void * most one SQL command in the given string. (There can be semicolons in it, * but not more than one nonempty command.) * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $query The parameterized SQL statement. Must contain only a single statement. * (multiple statements separated by semi-colons are not allowed.) If any parameters * are used, they are referred to as $1, $2, etc. @@ -1381,7 +1063,7 @@ function pg_put_line($connection = null, string $data = null): void * Values intended for bytea fields are not supported as * parameters. Use pg_escape_bytea instead, or use the * large object functions. - * @return resource A query result resource on success. + * @return resource An PgSql\Result instance on success. * @throws PgsqlException * */ @@ -1422,10 +1104,11 @@ function pg_query_params($connection = null, string $query = null, array $params * * * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. + * @param resource $connection An PgSql\Connection instance. + * When connection is unspecified, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @param string $query The SQL statement or statements to be executed. When multiple statements are passed to the function, * they are automatically executed as one transaction, unless there are explicit BEGIN/COMMIT commands * included in the query string. However, using multiple transactions in one function call is not recommended. @@ -1439,7 +1122,7 @@ function pg_query_params($connection = null, string $query = null, array $params * * Any user-supplied data substituted directly into a query string should * be properly escaped. - * @return resource A query result resource on success. + * @return resource An PgSql\Result instance on success. * @throws PgsqlException * */ @@ -1462,9 +1145,9 @@ function pg_query($connection = null, string $query = null) /** * pg_result_error_field returns one of the detailed error message - * fields associated with result resource. It is only available + * fields associated with result instance. It is only available * against a PostgreSQL 7.4 or above server. The error field is specified by - * the fieldcode. + * the field_code. * * Because pg_query and pg_query_params return FALSE if the query fails, * you must use pg_send_query and @@ -1474,9 +1157,9 @@ function pg_query($connection = null, string $query = null) * use pg_set_error_verbosity and pg_last_error * and then parse the result. * - * @param resource $result A PostgreSQL query result resource from a previously executed - * statement. - * @param int $fieldcode Possible fieldcode values are: PGSQL_DIAG_SEVERITY, + * @param resource $result An PgSql\Result instance, returned by pg_query, + * pg_query_params or pg_execute(among others). + * @param int $field_code Possible field_code values are: PGSQL_DIAG_SEVERITY, * PGSQL_DIAG_SQLSTATE, PGSQL_DIAG_MESSAGE_PRIMARY, * PGSQL_DIAG_MESSAGE_DETAIL, * PGSQL_DIAG_MESSAGE_HINT, PGSQL_DIAG_STATEMENT_POSITION, @@ -1489,10 +1172,10 @@ function pg_query($connection = null, string $query = null) * @throws PgsqlException * */ -function pg_result_error_field($result, int $fieldcode): ?string +function pg_result_error_field($result, int $field_code): ?string { error_clear_last(); - $result = \pg_result_error_field($result, $fieldcode); + $result = \pg_result_error_field($result, $field_code); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -1502,20 +1185,19 @@ function pg_result_error_field($result, int $fieldcode): ?string /** * pg_result_seek sets the internal row offset in - * a result resource. + * the result instance. * - * @param resource $result PostgreSQL query result resource, returned by pg_query, - * pg_query_params or pg_execute - * (among others). - * @param int $offset Row to move the internal offset to in the result resource. + * @param resource $result An PgSql\Result instance, returned by pg_query, + * pg_query_params or pg_execute(among others). + * @param int $row Row to move the internal offset to in the PgSql\Result instance. * Rows are numbered starting from zero. * @throws PgsqlException * */ -function pg_result_seek($result, int $offset): void +function pg_result_seek($result, int $row): void { error_clear_last(); - $result = \pg_result_seek($result, $offset); + $result = \pg_result_seek($result, $row); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -1524,14 +1206,14 @@ function pg_result_seek($result, int $offset): void /** * pg_select selects records specified by - * assoc_array which has + * conditions which has * field=>value. For a successful query, it returns an * array containing all records and fields that match the condition - * specified by assoc_array. + * specified by conditions. * - * If options is specified, + * If flags is specified, * pg_convert is applied to - * assoc_array with the specified flags. + * conditions with the specified flags. * * By default pg_select passes raw values. Values * must be escaped or PGSQL_DML_ESCAPE option must be @@ -1543,28 +1225,28 @@ function pg_result_seek($result, int $offset): void * JSON, Array, Regex, etc. These parameters should be handled * according to their contexts. i.e. Escape/validate values. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table from which to select rows. - * @param array $assoc_array An array whose keys are field names in the table table_name, + * @param array $conditions An array whose keys are field names in the table table_name, * and whose values are the conditions that a row must meet to be retrieved. - * @param int $options Any number of PGSQL_CONV_FORCE_NULL, + * @param int $flags Any number of PGSQL_CONV_FORCE_NULL, * PGSQL_DML_NO_CONV, * PGSQL_DML_ESCAPE, * PGSQL_DML_EXEC, * PGSQL_DML_ASYNC or * PGSQL_DML_STRING combined. If PGSQL_DML_STRING is part of the - * options then query string is returned. When PGSQL_DML_NO_CONV + * flags then query string is returned. When PGSQL_DML_NO_CONV * or PGSQL_DML_ESCAPE is set, it does not call pg_convert internally. - * @param int $result_type - * @return mixed Returns TRUE on success. Returns string if PGSQL_DML_STRING is passed - * via options. + * @param int $mode + * @return mixed Returns string if PGSQL_DML_STRING is passed + * via flags, otherwise it returns an array on success. * @throws PgsqlException * */ -function pg_select($connection, string $table_name, array $assoc_array, int $options = PGSQL_DML_EXEC, int $result_type = PGSQL_ASSOC) +function pg_select($connection, string $table_name, array $conditions, int $flags = PGSQL_DML_EXEC, int $mode = PGSQL_ASSOC) { error_clear_last(); - $result = \pg_select($connection, $table_name, $assoc_array, $options, $result_type); + $result = \pg_select($connection, $table_name, $conditions, $flags, $mode); if ($result === false) { throw PgsqlException::createFromPhpError(); } @@ -1573,144 +1255,10 @@ function pg_select($connection, string $table_name, array $assoc_array, int $opt /** - * Sends a request to execute a prepared statement with given parameters, - * without waiting for the result(s). - * - * This is similar to pg_send_query_params, but the command to be executed is specified - * by naming a previously-prepared statement, instead of giving a query string. The - * function's parameters are handled identically to pg_execute. - * Like pg_execute, it will not work on pre-7.4 versions of - * PostgreSQL. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @param string $stmtname The name of the prepared statement to execute. if - * "" is specified, then the unnamed statement is executed. The name must have - * been previously prepared using pg_prepare, - * pg_send_prepare or a PREPARE SQL - * command. - * @param array $params An array of parameter values to substitute for the $1, $2, etc. placeholders - * in the original prepared query string. The number of elements in the array - * must match the number of placeholders. - * @throws PgsqlException - * - */ -function pg_send_execute($connection, string $stmtname, array $params): void -{ - error_clear_last(); - $result = \pg_send_execute($connection, $stmtname, $params); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } -} - - -/** - * Sends a request to create a prepared statement with the given parameters, - * without waiting for completion. - * - * This is an asynchronous version of pg_prepare: it returns TRUE if it was able to - * dispatch the request, and FALSE if not. After a successful call, call - * pg_get_result to determine whether the server successfully created the - * prepared statement. The function's parameters are handled identically to - * pg_prepare. Like pg_prepare, it will not work - * on pre-7.4 versions of PostgreSQL. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @param string $stmtname The name to give the prepared statement. Must be unique per-connection. If - * "" is specified, then an unnamed statement is created, overwriting any - * previously defined unnamed statement. - * @param string $query The parameterized SQL statement. Must contain only a single statement. - * (multiple statements separated by semi-colons are not allowed.) If any parameters - * are used, they are referred to as $1, $2, etc. - * @throws PgsqlException - * - */ -function pg_send_prepare($connection, string $stmtname, string $query): void -{ - error_clear_last(); - $result = \pg_send_prepare($connection, $stmtname, $query); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } -} - - -/** - * Submits a command and separate parameters to the server without - * waiting for the result(s). - * - * This is equivalent to pg_send_query except that query - * parameters can be specified separately from the - * query string. The function's parameters are - * handled identically to pg_query_params. Like - * pg_query_params, it will not work on pre-7.4 PostgreSQL - * connections, and it allows only one command in the query string. - * - * @param resource $connection PostgreSQL database connection resource. - * @param string $query The parameterized SQL statement. Must contain only a single statement. - * (multiple statements separated by semi-colons are not allowed.) If any parameters - * are used, they are referred to as $1, $2, etc. - * @param array $params An array of parameter values to substitute for the $1, $2, etc. placeholders - * in the original prepared query string. The number of elements in the array - * must match the number of placeholders. - * @throws PgsqlException - * - */ -function pg_send_query_params($connection, string $query, array $params): void -{ - error_clear_last(); - $result = \pg_send_query_params($connection, $query, $params); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } -} - - -/** - * pg_send_query sends a query or queries asynchronously to the - * connection. Unlike - * pg_query, it can send multiple queries at once to - * PostgreSQL and get the results one by one using - * pg_get_result. - * - * Script execution is not blocked while the queries are executing. Use - * pg_connection_busy to check if the connection is - * busy (i.e. the query is executing). Queries may be cancelled using - * pg_cancel_query. - * - * Although the user can send multiple queries at once, multiple queries - * cannot be sent over a busy connection. If a query is sent while - * the connection is busy, it waits until the last query is finished and - * discards all its results. - * - * @param resource $connection PostgreSQL database connection resource. - * @param string $query The SQL statement or statements to be executed. - * - * Data inside the query should be properly escaped. - * @throws PgsqlException - * - */ -function pg_send_query($connection, string $query): void -{ - error_clear_last(); - $result = \pg_send_query($connection, $query); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } -} - - -/** * pg_socket returns a read only resource * corresponding to the socket underlying the given PostgreSQL connection. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @return resource A socket resource on success. * @throws PgsqlException * @@ -1739,138 +1287,72 @@ function pg_socket($connection) * PostgreSQL server. For more information, refer to the * PostgreSQL Documentation. * - * @param string $pathname The full path and file name of the file in which to write the + * @param string $filename The full path and file name of the file in which to write the * trace log. Same as in fopen. * @param string $mode An optional file access mode, same as for fopen. - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @throws PgsqlException - * - */ -function pg_trace(string $pathname, string $mode = "w", $connection = null): void -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_trace($pathname, $mode, $connection); - } else { - $result = \pg_trace($pathname, $mode); - } - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } -} - - -/** - * pg_tty returns the TTY name that server - * side debugging output is sent to on the given PostgreSQL - * connection resource. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return string A string containing the debug TTY of - * the connection. + * @param resource $connection An PgSql\Connection instance. + * When connection is NULL, the default connection is used. + * The default connection is the last connection made by pg_connect + * or pg_pconnect. + * As of PHP 8.1.0, using the default connection is deprecated. * @throws PgsqlException * */ -function pg_tty($connection = null): string +function pg_trace(string $filename, string $mode = "w", $connection = null): void { error_clear_last(); if ($connection !== null) { - $result = \pg_tty($connection); + $result = \pg_trace($filename, $mode, $connection); } else { - $result = \pg_tty(); + $result = \pg_trace($filename, $mode); } if ($result === false) { throw PgsqlException::createFromPhpError(); } - return $result; } /** * pg_update updates records that matches - * condition with data. If - * options is specified, - * pg_convert is applied to - * data with specified options. + * conditions with values. * - * pg_update updates records specified by - * assoc_array which has - * field=>value. - * - * If options is specified, + * If flags is specified, * pg_convert is applied to - * assoc_array with the specified flags. + * values with the specified flags. * - * By default pg_update passes raw values. Values - * must be escaped or PGSQL_DML_ESCAPE option must be - * specified. PGSQL_DML_ESCAPE quotes and escapes - * parameters/identifiers. Therefore, table/column names became case - * sensitive. + * By default pg_update passes raw values. + * Values must be escaped or the PGSQL_DML_ESCAPE flag + * must be specified in flags. + * PGSQL_DML_ESCAPE quotes and escapes parameters/identifiers. + * Therefore, table/column names become case sensitive. * * Note that neither escape nor prepared query can protect LIKE query, * JSON, Array, Regex, etc. These parameters should be handled * according to their contexts. i.e. Escape/validate values. * - * @param resource $connection PostgreSQL database connection resource. + * @param resource $connection An PgSql\Connection instance. * @param string $table_name Name of the table into which to update rows. - * @param array $data An array whose keys are field names in the table table_name, + * @param array $values An array whose keys are field names in the table table_name, * and whose values are what matched rows are to be updated to. - * @param array $condition An array whose keys are field names in the table table_name, + * @param array $conditions An array whose keys are field names in the table table_name, * and whose values are the conditions that a row must meet to be updated. - * @param int $options Any number of PGSQL_CONV_FORCE_NULL, + * @param int $flags Any number of PGSQL_CONV_FORCE_NULL, * PGSQL_DML_NO_CONV, * PGSQL_DML_ESCAPE, * PGSQL_DML_EXEC, * PGSQL_DML_ASYNC or * PGSQL_DML_STRING combined. If PGSQL_DML_STRING is part of the - * options then query string is returned. When PGSQL_DML_NO_CONV + * flags then query string is returned. When PGSQL_DML_NO_CONV * or PGSQL_DML_ESCAPE is set, it does not call pg_convert internally. * @return mixed Returns TRUE on success. Returns string if PGSQL_DML_STRING is passed - * via options. + * via flags. * @throws PgsqlException * */ -function pg_update($connection, string $table_name, array $data, array $condition, int $options = PGSQL_DML_EXEC) +function pg_update($connection, string $table_name, array $values, array $conditions, int $flags = PGSQL_DML_EXEC) { error_clear_last(); - $result = \pg_update($connection, $table_name, $data, $condition, $options); - if ($result === false) { - throw PgsqlException::createFromPhpError(); - } - return $result; -} - - -/** - * pg_version returns an array with the client, protocol - * and server version. Protocol and server versions are only available if PHP - * was compiled with PostgreSQL 7.4 or later. - * - * For more detailed server information, use pg_parameter_status. - * - * @param resource $connection PostgreSQL database connection resource. When - * connection is not present, the default connection - * is used. The default connection is the last connection made by - * pg_connect or pg_pconnect. - * @return array Returns an array with client, protocol - * and server keys and values (if available) or invalid connection. - * @throws PgsqlException - * - */ -function pg_version($connection = null): array -{ - error_clear_last(); - if ($connection !== null) { - $result = \pg_version($connection); - } else { - $result = \pg_version(); - } + $result = \pg_update($connection, $table_name, $values, $conditions, $flags); if ($result === false) { throw PgsqlException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/posix.php b/vendor/thecodingmachine/safe/generated/posix.php index 6ae99d88c..26b77eaa9 100644 --- a/vendor/thecodingmachine/safe/generated/posix.php +++ b/vendor/thecodingmachine/safe/generated/posix.php @@ -7,8 +7,8 @@ use Safe\Exceptions\PosixException; /** * posix_access checks the user's permission of a file. * - * @param string $file The name of the file to be tested. - * @param int $mode A mask consisting of one or more of POSIX_F_OK, + * @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. * @@ -20,10 +20,10 @@ use Safe\Exceptions\PosixException; * @throws PosixException * */ -function posix_access(string $file, int $mode = POSIX_F_OK): void +function posix_access(string $filename, int $flags = 0): void { error_clear_last(); - $result = \posix_access($file, $mode); + $result = \posix_access($filename, $flags); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -31,6 +31,70 @@ function posix_access(string $file, int $mode = POSIX_F_OK): void /** + * Gets information about a group provided its id. + * + * @param int $group_id The group id. + * @return array 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(); + $result = \posix_getgrgid($group_id); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** * Gets information about a group provided its name. * * @param string $name The name of the group @@ -95,18 +159,260 @@ function posix_getgrnam(string $name): array /** - * Returns the process group identifier of the process - * pid. + * Gets the group set of the current process. + * + * @return array 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(); + $result = \posix_getgroups(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \posix_getlogin(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * Returns an array of information about the user + * referenced by the given user ID. + * + * @param int $user_id The user identifier. + * @return array 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. * - * @param int $pid The process id. - * @return int Returns the identifier, as an integer. + * + * + * 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_getpgid(int $pid): int +function posix_getpwuid(int $user_id): array { error_clear_last(); - $result = \posix_getpgid($pid); + $result = \posix_getpwuid($user_id); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \posix_getrlimit(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \posix_getsid($process_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -117,15 +423,15 @@ function posix_getpgid(int $pid): int /** * Calculates the group access list for the user specified in name. * - * @param string $name The user to calculate the list for. - * @param int $base_group_id Typically the group number from the password file. + * @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 $name, int $base_group_id): void +function posix_initgroups(string $username, int $group_id): void { error_clear_last(); - $result = \posix_initgroups($name, $base_group_id); + $result = \posix_initgroups($username, $group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -133,18 +439,18 @@ function posix_initgroups(string $name, int $base_group_id): void /** - * Send the signal sig to the process with - * the process identifier pid. + * Send the signal signal to the process with + * the process identifier process_id. * - * @param int $pid The process identifier. - * @param int $sig One of the PCNTL signals constants. + * @param int $process_id The process identifier. + * @param int $signal One of the PCNTL signals constants. * @throws PosixException * */ -function posix_kill(int $pid, int $sig): void +function posix_kill(int $process_id, int $signal): void { error_clear_last(); - $result = \posix_kill($pid, $sig); + $result = \posix_kill($process_id, $signal); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -156,8 +462,8 @@ function posix_kill(int $pid, int $sig): void * FIFO file which exists in the file system and acts as * a bidirectional communication endpoint for processes. * - * @param string $pathname Path to the FIFO file. - * @param int $mode The second parameter mode has to be given in + * @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 @@ -165,10 +471,10 @@ function posix_kill(int $pid, int $sig): void * @throws PosixException * */ -function posix_mkfifo(string $pathname, int $mode): void +function posix_mkfifo(string $filename, int $permissions): void { error_clear_last(); - $result = \posix_mkfifo($pathname, $mode); + $result = \posix_mkfifo($filename, $permissions); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -178,8 +484,8 @@ function posix_mkfifo(string $pathname, int $mode): void /** * Creates a special or ordinary file. * - * @param string $pathname The file to create - * @param int $mode This parameter is constructed by a bitwise OR between file type (one of + * @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 @@ -190,10 +496,10 @@ function posix_mkfifo(string $pathname, int $mode): void * @throws PosixException * */ -function posix_mknod(string $pathname, int $mode, int $major = 0, int $minor = 0): void +function posix_mknod(string $filename, int $flags, int $major = 0, int $minor = 0): void { error_clear_last(); - $result = \posix_mknod($pathname, $mode, $major, $minor); + $result = \posix_mknod($filename, $flags, $major, $minor); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -205,14 +511,14 @@ function posix_mknod(string $pathname, int $mode, int $major = 0, int $minor = 0 * privileged function and needs appropriate privileges (usually * root) on the system to be able to perform this function. * - * @param int $gid The group id. + * @param int $group_id The group id. * @throws PosixException * */ -function posix_setegid(int $gid): void +function posix_setegid(int $group_id): void { error_clear_last(); - $result = \posix_setegid($gid); + $result = \posix_setegid($group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -224,14 +530,14 @@ function posix_setegid(int $gid): void * function and needs appropriate privileges (usually root) on * the system to be able to perform this function. * - * @param int $uid The user id. + * @param int $user_id The user id. * @throws PosixException * */ -function posix_seteuid(int $uid): void +function posix_seteuid(int $user_id): void { error_clear_last(); - $result = \posix_seteuid($uid); + $result = \posix_seteuid($user_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -246,14 +552,14 @@ function posix_seteuid(int $uid): void * posix_setgid first, * posix_setuid last. * - * @param int $gid The group id. + * @param int $group_id The group id. * @throws PosixException * */ -function posix_setgid(int $gid): void +function posix_setgid(int $group_id): void { error_clear_last(); - $result = \posix_setgid($gid); + $result = \posix_setgid($group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -261,18 +567,18 @@ function posix_setgid(int $gid): void /** - * Let the process pid join the process group - * pgid. + * Let the process process_id join the process group + * process_group_id. * - * @param int $pid The process id. - * @param int $pgid The 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 $pid, int $pgid): void +function posix_setpgid(int $process_id, int $process_group_id): void { error_clear_last(); - $result = \posix_setpgid($pid, $pgid); + $result = \posix_setpgid($process_id, $process_group_id); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -293,17 +599,17 @@ function posix_setpgid(int $pid, int $pgid): void * @param int $resource The * resource limit constant * corresponding to the limit that is being set. - * @param int $softlimit The soft limit, in whatever unit the resource limit requires, or + * @param int $soft_limit The soft limit, in whatever unit the resource limit requires, or * POSIX_RLIMIT_INFINITY. - * @param int $hardlimit The hard limit, in whatever unit the resource limit requires, or + * @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 $softlimit, int $hardlimit): void +function posix_setrlimit(int $resource, int $soft_limit, int $hard_limit): void { error_clear_last(); - $result = \posix_setrlimit($resource, $softlimit, $hardlimit); + $result = \posix_setrlimit($resource, $soft_limit, $hard_limit); if ($result === false) { throw PosixException::createFromPhpError(); } @@ -315,15 +621,113 @@ function posix_setrlimit(int $resource, int $softlimit, int $hardlimit): void * function that needs appropriate privileges (usually root) on * the system to be able to perform this function. * - * @param int $uid The user id. + * @param int $user_id The user id. + * @throws PosixException + * + */ +function posix_setuid(int $user_id): void +{ + error_clear_last(); + $result = \posix_setuid($user_id); + if ($result === 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_setuid(int $uid): void +function posix_times(): array { error_clear_last(); - $result = \posix_setuid($uid); + $result = \posix_times(); if ($result === false) { throw PosixException::createFromPhpError(); } + return $result; +} + + +/** + * 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(); + $result = \posix_uname(); + if ($result === false) { + throw PosixException::createFromPhpError(); + } + return $result; } diff --git a/vendor/thecodingmachine/safe/generated/ps.php b/vendor/thecodingmachine/safe/generated/ps.php index a66667aa9..a2dca7976 100644 --- a/vendor/thecodingmachine/safe/generated/ps.php +++ b/vendor/thecodingmachine/safe/generated/ps.php @@ -558,7 +558,7 @@ function ps_delete($psdoc): void * Ends a page which was started with ps_begin_page. * Ending a page will leave the current drawing context, which e.g. requires * to reload fonts if they were loading within the page, and to set many - * other drawing parameters like the line width, or color.. + * other drawing parameters like the line width, or color. * * @param resource $psdoc Resource identifier of the postscript file * as returned by ps_new. diff --git a/vendor/thecodingmachine/safe/generated/pspell.php b/vendor/thecodingmachine/safe/generated/pspell.php index 4cf4c36a6..b1e296d6d 100644 --- a/vendor/thecodingmachine/safe/generated/pspell.php +++ b/vendor/thecodingmachine/safe/generated/pspell.php @@ -7,15 +7,15 @@ use Safe\Exceptions\PspellException; /** * * - * @param int $dictionary_link + * @param int $dictionary An PSpell\Dictionary instance. * @param string $word The added word. * @throws PspellException * */ -function pspell_add_to_personal(int $dictionary_link, string $word): void +function pspell_add_to_personal(int $dictionary, string $word): void { error_clear_last(); - $result = \pspell_add_to_personal($dictionary_link, $word); + $result = \pspell_add_to_personal($dictionary, $word); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -25,15 +25,15 @@ function pspell_add_to_personal(int $dictionary_link, string $word): void /** * * - * @param int $dictionary_link + * @param int $dictionary An PSpell\Dictionary instance. * @param string $word The added word. * @throws PspellException * */ -function pspell_add_to_session(int $dictionary_link, string $word): void +function pspell_add_to_session(int $dictionary, string $word): void { error_clear_last(); - $result = \pspell_add_to_session($dictionary_link, $word); + $result = \pspell_add_to_session($dictionary, $word); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -43,14 +43,14 @@ function pspell_add_to_session(int $dictionary_link, string $word): void /** * * - * @param int $dictionary_link + * @param int $dictionary An PSpell\Dictionary instance. * @throws PspellException * */ -function pspell_clear_session(int $dictionary_link): void +function pspell_clear_session(int $dictionary): void { error_clear_last(); - $result = \pspell_clear_session($dictionary_link); + $result = \pspell_clear_session($dictionary); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -86,22 +86,14 @@ function pspell_clear_session(int $dictionary_link): void * 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned * 32'. This parameter is largely untested, so be careful when * using. - * @return int Returns a pspell config identifier. + * @return int Returns an PSpell\Config instance on success. * @throws PspellException * */ -function pspell_config_create(string $language, string $spelling = null, string $jargon = null, string $encoding = null): int +function pspell_config_create(string $language, string $spelling = "", string $jargon = "", string $encoding = ""): int { error_clear_last(); - if ($encoding !== null) { - $result = \pspell_config_create($language, $spelling, $jargon, $encoding); - } elseif ($jargon !== null) { - $result = \pspell_config_create($language, $spelling, $jargon); - } elseif ($spelling !== null) { - $result = \pspell_config_create($language, $spelling); - } else { - $result = \pspell_config_create($language); - } + $result = \pspell_config_create($language, $spelling, $jargon, $encoding); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -114,15 +106,15 @@ function pspell_config_create(string $language, string $spelling = null, string * currently not documented; only its argument list is available. * * - * @param int $conf + * @param int $config * @param string $directory * @throws PspellException * */ -function pspell_config_data_dir(int $conf, string $directory): void +function pspell_config_data_dir(int $config, string $directory): void { error_clear_last(); - $result = \pspell_config_data_dir($conf, $directory); + $result = \pspell_config_data_dir($config, $directory); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -134,15 +126,15 @@ function pspell_config_data_dir(int $conf, string $directory): void * currently not documented; only its argument list is available. * * - * @param int $conf + * @param int $config * @param string $directory * @throws PspellException * */ -function pspell_config_dict_dir(int $conf, string $directory): void +function pspell_config_dict_dir(int $config, string $directory): void { error_clear_last(); - $result = \pspell_config_dict_dir($conf, $directory); + $result = \pspell_config_dict_dir($config, $directory); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -152,15 +144,15 @@ function pspell_config_dict_dir(int $conf, string $directory): void /** * * - * @param int $dictionary_link - * @param int $n Words less than n characters will be skipped. + * @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 $dictionary_link, int $n): void +function pspell_config_ignore(int $config, int $min_length): void { error_clear_last(); - $result = \pspell_config_ignore($dictionary_link, $n); + $result = \pspell_config_ignore($config, $min_length); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -170,7 +162,7 @@ function pspell_config_ignore(int $dictionary_link, int $n): void /** * * - * @param int $dictionary_link + * @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: * @@ -195,10 +187,10 @@ function pspell_config_ignore(int $dictionary_link, int $n): void * @throws PspellException * */ -function pspell_config_mode(int $dictionary_link, int $mode): void +function pspell_config_mode(int $config, int $mode): void { error_clear_last(); - $result = \pspell_config_mode($dictionary_link, $mode); + $result = \pspell_config_mode($config, $mode); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -214,16 +206,16 @@ function pspell_config_mode(int $dictionary_link, int $mode): void * pspell_config_personal should be used on a config * before calling pspell_new_config. * - * @param int $dictionary_link - * @param string $file The personal wordlist. If the file does not exist, it will be created. + * @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 $dictionary_link, string $file): void +function pspell_config_personal(int $config, string $filename): void { error_clear_last(); - $result = \pspell_config_personal($dictionary_link, $file); + $result = \pspell_config_personal($config, $filename); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -242,15 +234,15 @@ function pspell_config_personal(int $dictionary_link, string $file): void * pspell_config_repl should be used on a config * before calling pspell_new_config. * - * @param int $dictionary_link - * @param string $file The file should be writable by whoever PHP runs as (e.g. nobody). + * @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 $dictionary_link, string $file): void +function pspell_config_repl(int $config, string $filename): void { error_clear_last(); - $result = \pspell_config_repl($dictionary_link, $file); + $result = \pspell_config_repl($config, $filename); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -267,16 +259,16 @@ function pspell_config_repl(int $dictionary_link, string $file): void * pspell_config_runtogether should be used on a config * before calling pspell_new_config. * - * @param int $dictionary_link - * @param bool $flag TRUE if run-together words should be treated as legal compounds, + * @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 $dictionary_link, bool $flag): void +function pspell_config_runtogether(int $config, bool $allow): void { error_clear_last(); - $result = \pspell_config_runtogether($dictionary_link, $flag); + $result = \pspell_config_runtogether($config, $allow); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -295,15 +287,15 @@ function pspell_config_runtogether(int $dictionary_link, bool $flag): void * pspell_config_save_repl should be used on a config * before calling pspell_new_config. * - * @param int $dictionary_link - * @param bool $flag TRUE if replacement pairs should be saved, FALSE otherwise. + * @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 $dictionary_link, bool $flag): void +function pspell_config_save_repl(int $config, bool $save): void { error_clear_last(); - $result = \pspell_config_save_repl($dictionary_link, $flag); + $result = \pspell_config_save_repl($config, $save); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -315,7 +307,7 @@ function pspell_config_save_repl(int $dictionary_link, bool $flag): void * * @param int $config The config parameter is the one returned by * pspell_config_create when the config was created. - * @return int Returns a dictionary link identifier on success. + * @return int Returns an PSpell\Dictionary instance on success * @throws PspellException * */ @@ -331,8 +323,78 @@ function pspell_new_config(int $config): int /** + * 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(); + $result = \pspell_new_personal($filename, $language, $spelling, $jargon, $encoding, $mode); + if ($result === false) { + throw PspellException::createFromPhpError(); + } + return $result; +} + + +/** * pspell_new opens up a new dictionary and - * returns the dictionary link identifier for use in other pspell + * returns an PSpell\Dictionary instance for use in other pspell * functions. * * For more information and examples, check out inline manual pspell @@ -388,24 +450,14 @@ function pspell_new_config(int $config): int * PSPELL_NORMAL and * PSPELL_BAD_SPELLERS are mutually exclusive, so you * should select only one of them. - * @return int Returns the dictionary link identifier on success. + * @return int Returns an PSpell\Dictionary instance on success. * @throws PspellException * */ -function pspell_new(string $language, string $spelling = null, string $jargon = null, string $encoding = null, int $mode = 0): int +function pspell_new(string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int { error_clear_last(); - if ($mode !== 0) { - $result = \pspell_new($language, $spelling, $jargon, $encoding, $mode); - } elseif ($encoding !== null) { - $result = \pspell_new($language, $spelling, $jargon, $encoding); - } elseif ($jargon !== null) { - $result = \pspell_new($language, $spelling, $jargon); - } elseif ($spelling !== null) { - $result = \pspell_new($language, $spelling); - } else { - $result = \pspell_new($language); - } + $result = \pspell_new($language, $spelling, $jargon, $encoding, $mode); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -416,15 +468,14 @@ function pspell_new(string $language, string $spelling = null, string $jargon = /** * * - * @param int $dictionary_link A dictionary link identifier opened with - * pspell_new_personal. + * @param int $dictionary An PSpell\Dictionary instance. * @throws PspellException * */ -function pspell_save_wordlist(int $dictionary_link): void +function pspell_save_wordlist(int $dictionary): void { error_clear_last(); - $result = \pspell_save_wordlist($dictionary_link); + $result = \pspell_save_wordlist($dictionary); if ($result === false) { throw PspellException::createFromPhpError(); } @@ -434,17 +485,16 @@ function pspell_save_wordlist(int $dictionary_link): void /** * * - * @param int $dictionary_link A dictionary link identifier, opened with - * pspell_new_personal + * @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_link, string $misspelled, string $correct): void +function pspell_store_replacement(int $dictionary, string $misspelled, string $correct): void { error_clear_last(); - $result = \pspell_store_replacement($dictionary_link, $misspelled, $correct); + $result = \pspell_store_replacement($dictionary, $misspelled, $correct); if ($result === false) { throw PspellException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/readline.php b/vendor/thecodingmachine/safe/generated/readline.php index a1c52c755..ddbf5a354 100644 --- a/vendor/thecodingmachine/safe/generated/readline.php +++ b/vendor/thecodingmachine/safe/generated/readline.php @@ -7,14 +7,14 @@ use Safe\Exceptions\ReadlineException; /** * This function adds a line to the command line history. * - * @param string $line The line to be added in the history. + * @param string $prompt The line to be added in the history. * @throws ReadlineException * */ -function readline_add_history(string $line): void +function readline_add_history(string $prompt): void { error_clear_last(); - $result = \readline_add_history($line); + $result = \readline_add_history($prompt); if ($result === false) { throw ReadlineException::createFromPhpError(); } @@ -32,38 +32,6 @@ function readline_add_history(string $line): void * stream_select as it allows interleaving of IO and * user input, unlike readline. * - * - * Readline Callback Interface Example - * - * 10) { - * $prompting = false; - * readline_callback_handler_remove(); - * } else { - * readline_callback_handler_install("[$c] Enter something: ", 'rl_callback'); - * } - * } - * - * $c = 1; - * $prompting = true; - * - * readline_callback_handler_install("[$c] Enter something: ", 'rl_callback'); - * - * while ($prompting) { - * $w = NULL; - * $e = NULL; - * $n = stream_select($r = array(STDIN), $w, $e, null); - * if ($n && in_array(STDIN, $r)) { - * // read a character, will call the callback when a newline is entered - * readline_callback_read_char(); - * } - * } - * - * echo "Prompting disabled. All done.\n"; - * ?> - * ]]> - * - * - * * @param string $prompt The prompt message. * @param callable $callback The callback function takes one parameter; the * user input returned. @@ -100,15 +68,15 @@ function readline_clear_history(): void * 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 $function You must supply the name of an existing function which accepts a + * @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 $function): void +function readline_completion_function(callable $callback): void { error_clear_last(); - $result = \readline_completion_function($function); + $result = \readline_completion_function($callback); if ($result === false) { throw ReadlineException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/rrd.php b/vendor/thecodingmachine/safe/generated/rrd.php index 9bb3b5c52..2da227d0e 100644 --- a/vendor/thecodingmachine/safe/generated/rrd.php +++ b/vendor/thecodingmachine/safe/generated/rrd.php @@ -21,3 +21,170 @@ function rrd_create(string $filename, array $options): void 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(); + $result = \rrd_first($file, $raaindex); + if ($result === false) { + throw RrdException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \rrd_graph($filename, $options); + if ($result === false) { + throw RrdException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \rrd_info($filename); + if ($result === false) { + throw RrdException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \rrd_lastupdate($filename); + if ($result === false) { + throw RrdException::createFromPhpError(); + } + return $result; +} + + +/** + * 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) { + $result = \rrd_restore($xml_file, $rrd_file, $options); + } else { + $result = \rrd_restore($xml_file, $rrd_file); + } + if ($result === 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(); + $result = \rrd_tune($filename, $options); + if ($result === 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(); + $result = \rrd_update($filename, $options); + if ($result === 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(); + $result = \rrd_xport($options); + if ($result === false) { + throw RrdException::createFromPhpError(); + } + return $result; +} diff --git a/vendor/thecodingmachine/safe/generated/sem.php b/vendor/thecodingmachine/safe/generated/sem.php index 739e8b389..020212151 100644 --- a/vendor/thecodingmachine/safe/generated/sem.php +++ b/vendor/thecodingmachine/safe/generated/sem.php @@ -5,6 +5,34 @@ 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 resource 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) +{ + error_clear_last(); + $result = \msg_get_queue($key, $permissions); + if ($result === false) { + throw SemException::createFromPhpError(); + } + return $result; +} + + +/** * Checks whether the message queue key exists. * * @param int $key Queue key. @@ -24,23 +52,23 @@ function msg_queue_exists(int $key): void /** * msg_receive will receive the first message from the * specified queue of the type specified by - * desiredmsgtype. + * desired_message_type. * - * @param resource $queue Message queue resource handle - * @param int $desiredmsgtype If desiredmsgtype is 0, the message from the front - * of the queue is returned. If desiredmsgtype is + * @param resource $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 desiredmsgtype is less than 0, the first + * 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 desiredmsgtype will be read. + * 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 $msgtype The type of the message that was received will be stored in this + * @param int|null $received_message_type The type of the message that was received will be stored in this * parameter. - * @param int $maxsize The maximum size of message to be accepted is specified by the - * maxsize; if the message in the queue is larger + * @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, @@ -64,7 +92,7 @@ function msg_queue_exists(int $key): void * * MSG_IPC_NOWAIT * If there are no messages of the - * desiredmsgtype, return immediately and do not + * desired_message_type, return immediately and do not * wait. The function will fail and return an integer value * corresponding to MSG_ENOMSG. * @@ -72,30 +100,30 @@ function msg_queue_exists(int $key): void * * MSG_EXCEPT * Using this flag in combination with a - * desiredmsgtype greater than 0 will cause the + * desired_message_type greater than 0 will cause the * function to receive the first message that is not equal to - * desiredmsgtype. + * desired_message_type. * * * MSG_NOERROR * - * If the message is longer than maxsize, + * If the message is longer than max_message_size, * setting this flag will truncate the message to - * maxsize and will not signal an error. + * max_message_size and will not signal an error. * * * * * - * @param int|null $errorcode If the function fails, the optional errorcode + * @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($queue, int $desiredmsgtype, ?int &$msgtype, int $maxsize, &$message, bool $unserialize = true, int $flags = 0, ?int &$errorcode = null): void +function msg_receive($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(); - $result = \msg_receive($queue, $desiredmsgtype, $msgtype, $maxsize, $message, $unserialize, $flags, $errorcode); + $result = \msg_receive($queue, $desired_message_type, $received_message_type, $max_message_size, $message, $unserialize, $flags, $error_code); if ($result === false) { throw SemException::createFromPhpError(); } @@ -108,7 +136,7 @@ function msg_receive($queue, int $desiredmsgtype, ?int &$msgtype, int $maxsize, * processes have finished working with the message queue and you need to * release the system resources held by it. * - * @param resource $queue Message queue resource handle + * @param resource $queue The message queue. * @throws SemException * */ @@ -124,15 +152,15 @@ function msg_remove_queue($queue): void /** * msg_send sends a message of type - * msgtype (which MUST be greater than 0) to + * message_type (which MUST be greater than 0) to * the message queue specified by queue. * - * @param resource $queue Message queue resource handle - * @param int $msgtype The type of the message (MUST be greater than 0) + * @param resource $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, integer, float + * 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 @@ -148,17 +176,17 @@ function msg_remove_queue($queue): void * 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 - * errorcode to MSG_EAGAIN, + * error_code to MSG_EAGAIN, * indicating that you should try to send your message again a little * later on. - * @param int|null $errorcode If the function fails, the optional errorcode will be set to the value of the system errno variable. + * @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($queue, int $msgtype, $message, bool $serialize = true, bool $blocking = true, ?int &$errorcode = null): void +function msg_send($queue, int $message_type, $message, bool $serialize = true, bool $blocking = true, ?int &$error_code = null): void { error_clear_last(); - $result = \msg_send($queue, $msgtype, $message, $serialize, $blocking, $errorcode); + $result = \msg_send($queue, $message_type, $message, $serialize, $blocking, $error_code); if ($result === false) { throw SemException::createFromPhpError(); } @@ -176,7 +204,7 @@ function msg_send($queue, int $msgtype, $message, bool $serialize = true, bool $ * root privileges are required to raise the msg_qbytes values above the * system defined limit. * - * @param resource $queue Message queue resource handle + * @param resource $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 @@ -193,6 +221,100 @@ function msg_set_queue($queue, array $data): void /** + * 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 resource $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($queue): array +{ + error_clear_last(); + $result = \msg_stat_queue($queue); + if ($result === false) { + throw SemException::createFromPhpError(); + } + return $result; +} + + +/** * 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 @@ -202,19 +324,19 @@ function msg_set_queue($queue, array $data): void * explicitly released will be released automatically and a warning will be * generated. * - * @param resource $sem_identifier sem_identifier is a semaphore resource, + * @param resource $semaphore semaphore is a semaphore * obtained from sem_get. - * @param bool $nowait Specifies if the process shouldn't wait for the semaphore to be acquired. + * @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($sem_identifier, bool $nowait = false): void +function sem_acquire($semaphore, bool $non_blocking = false): void { error_clear_last(); - $result = \sem_acquire($sem_identifier, $nowait); + $result = \sem_acquire($semaphore, $non_blocking); if ($result === false) { throw SemException::createFromPhpError(); } @@ -235,19 +357,19 @@ function sem_acquire($sem_identifier, bool $nowait = false): void * @param int $key * @param int $max_acquire The number of processes that can acquire the semaphore simultaneously * is set to max_acquire. - * @param int $perm The semaphore permissions. Actually this value is + * @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 int $auto_release Specifies if the semaphore should be automatically released on request + * @param bool $auto_release Specifies if the semaphore should be automatically released on request * shutdown. * @return resource Returns a positive semaphore identifier on success. * @throws SemException * */ -function sem_get(int $key, int $max_acquire = 1, int $perm = 0666, int $auto_release = 1) +function sem_get(int $key, int $max_acquire = 1, int $permissions = 0666, bool $auto_release = true) { error_clear_last(); - $result = \sem_get($key, $max_acquire, $perm, $auto_release); + $result = \sem_get($key, $max_acquire, $permissions, $auto_release); if ($result === false) { throw SemException::createFromPhpError(); } @@ -263,15 +385,15 @@ function sem_get(int $key, int $max_acquire = 1, int $perm = 0666, int $auto_rel * After releasing the semaphore, sem_acquire * may be called to re-acquire it. * - * @param resource $sem_identifier A Semaphore resource handle as returned by + * @param resource $semaphore A Semaphore as returned by * sem_get. * @throws SemException * */ -function sem_release($sem_identifier): void +function sem_release($semaphore): void { error_clear_last(); - $result = \sem_release($sem_identifier); + $result = \sem_release($semaphore); if ($result === false) { throw SemException::createFromPhpError(); } @@ -283,15 +405,74 @@ function sem_release($sem_identifier): void * * After removing the semaphore, it is no longer accessible. * - * @param resource $sem_identifier A semaphore resource identifier as returned + * @param resource $semaphore A semaphore as returned * by sem_get. * @throws SemException * */ -function sem_remove($sem_identifier): void +function sem_remove($semaphore): void +{ + error_clear_last(); + $result = \sem_remove($semaphore); + if ($result === 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 $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 resource Returns a SysvSharedMemory instance on success. + * @throws SemException + * + */ +function shm_attach(int $key, int $size = null, int $permissions = 0666) +{ + error_clear_last(); + if ($permissions !== 0666) { + $result = \shm_attach($key, $size, $permissions); + } elseif ($size !== null) { + $result = \shm_attach($key, $size); + } else { + $result = \shm_attach($key); + } + if ($result === false) { + throw SemException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 resource $shm A shared memory segment obtained from shm_attach. + * @throws SemException + * + */ +function shm_detach($shm): void { error_clear_last(); - $result = \sem_remove($sem_identifier); + $result = \shm_detach($shm); if ($result === false) { throw SemException::createFromPhpError(); } @@ -300,28 +481,27 @@ function sem_remove($sem_identifier): void /** * shm_put_var inserts or updates the - * variable with the given - * variable_key. + * value with the given + * key. * * Warnings (E_WARNING level) will be issued if - * shm_identifier is not a valid SysV shared memory + * shm is not a valid SysV shared memory * index or if there was not enough shared memory remaining to complete your * request. * - * @param resource $shm_identifier A shared memory resource handle as returned by - * shm_attach - * @param int $variable_key The variable key. - * @param mixed $variable The variable. All variable types + * @param resource $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($shm_identifier, int $variable_key, $variable): void +function shm_put_var($shm, int $key, $value): void { error_clear_last(); - $result = \shm_put_var($shm_identifier, $variable_key, $variable); + $result = \shm_put_var($shm, $key, $value); if ($result === false) { throw SemException::createFromPhpError(); } @@ -329,19 +509,18 @@ function shm_put_var($shm_identifier, int $variable_key, $variable): void /** - * Removes a variable with a given variable_key + * Removes a variable with a given key * and frees the occupied memory. * - * @param resource $shm_identifier The shared memory identifier as returned by - * shm_attach - * @param int $variable_key The variable key. + * @param resource $shm A shared memory segment obtained from shm_attach. + * @param int $key The variable key. * @throws SemException * */ -function shm_remove_var($shm_identifier, int $variable_key): void +function shm_remove_var($shm, int $key): void { error_clear_last(); - $result = \shm_remove_var($shm_identifier, $variable_key); + $result = \shm_remove_var($shm, $key); if ($result === false) { throw SemException::createFromPhpError(); } @@ -350,17 +529,16 @@ function shm_remove_var($shm_identifier, int $variable_key): void /** * shm_remove removes the shared memory - * shm_identifier. All data will be destroyed. + * shm. All data will be destroyed. * - * @param resource $shm_identifier The shared memory identifier as returned by - * shm_attach + * @param resource $shm A shared memory segment obtained from shm_attach. * @throws SemException * */ -function shm_remove($shm_identifier): void +function shm_remove($shm): void { error_clear_last(); - $result = \shm_remove($shm_identifier); + $result = \shm_remove($shm); if ($result === false) { throw SemException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/session.php b/vendor/thecodingmachine/safe/generated/session.php index 7b8c9478d..212cf850e 100644 --- a/vendor/thecodingmachine/safe/generated/session.php +++ b/vendor/thecodingmachine/safe/generated/session.php @@ -22,6 +22,42 @@ function session_abort(): void /** + * 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(); + $result = \session_create_id($prefix); + if ($result === false) { + throw SessionException::createFromPhpError(); + } + return $result; +} + + +/** * session_decode decodes the serialized session data provided in * $data, and populates the $_SESSION superglobal * with the result. @@ -70,6 +106,151 @@ function session_destroy(): void /** + * 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(); + $result = \session_encode(); + if ($result === false) { + throw SessionException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 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) { + $result = \session_id($id); + } else { + $result = \session_id(); + } + if ($result === false) { + throw SessionException::createFromPhpError(); + } + return $result; +} + + +/** + * session_module_name gets the name of the current + * session module, which is also known as + * session.save_handler. + * + * @param 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) { + $result = \session_module_name($module); + } else { + $result = \session_module_name(); + } + if ($result === false) { + throw SessionException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 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 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) { + $result = \session_name($name); + } else { + $result = \session_name(); + } + if ($result === false) { + throw SessionException::createFromPhpError(); + } + return $result; +} + + +/** * session_regenerate_id will replace the current * session id with a new one, and keep the current session information. * @@ -113,6 +294,44 @@ function session_reset(): void /** + * session_save_path returns the path of the current + * directory used to save session data. + * + * @param 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) { + $result = \session_save_path($path); + } else { + $result = \session_save_path(); + } + if ($result === false) { + throw SessionException::createFromPhpError(); + } + return $result; +} + + +/** * The session_unset function frees all session variables * currently registered. * diff --git a/vendor/thecodingmachine/safe/generated/shmop.php b/vendor/thecodingmachine/safe/generated/shmop.php index 04ba57cb5..aa5d8f49c 100644 --- a/vendor/thecodingmachine/safe/generated/shmop.php +++ b/vendor/thecodingmachine/safe/generated/shmop.php @@ -7,15 +7,15 @@ use Safe\Exceptions\ShmopException; /** * shmop_delete is used to delete a shared memory block. * - * @param resource $shmid The shared memory block resource created by + * @param resource $shmop The shared memory block resource created by * shmop_open * @throws ShmopException * */ -function shmop_delete($shmid): void +function shmop_delete($shmop): void { error_clear_last(); - $result = \shmop_delete($shmid); + $result = \shmop_delete($shmop); if ($result === false) { throw ShmopException::createFromPhpError(); } @@ -25,42 +25,19 @@ function shmop_delete($shmid): void /** * shmop_read will read a string from shared memory block. * - * @param resource $shmid The shared memory block identifier created by + * @param resource $shmop The shared memory block identifier created by * shmop_open - * @param int $start Offset from which to start reading - * @param int $count The number of bytes to read. + * @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($shmid, int $start, int $count): string +function shmop_read($shmop, int $offset, int $size): string { error_clear_last(); - $result = \shmop_read($shmid, $start, $count); - if ($result === false) { - throw ShmopException::createFromPhpError(); - } - return $result; -} - - -/** - * shmop_write will write a string into shared memory block. - * - * @param resource $shmid The shared memory block identifier created by - * shmop_open - * @param string $data A string to write into shared memory block - * @param int $offset Specifies where to start writing data inside the shared memory - * segment. - * @return int The size of the written data. - * @throws ShmopException - * - */ -function shmop_write($shmid, string $data, int $offset): int -{ - error_clear_last(); - $result = \shmop_write($shmid, $data, $offset); + $result = \shmop_read($shmop, $offset, $size); if ($result === false) { throw ShmopException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/simplexml.php b/vendor/thecodingmachine/safe/generated/simplexml.php deleted file mode 100644 index 118de4432..000000000 --- a/vendor/thecodingmachine/safe/generated/simplexml.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -namespace Safe; - -use Safe\Exceptions\SimplexmlException; - -/** - * This function takes a node of a DOM - * document and makes it into a SimpleXML node. This new object can - * then be used as a native SimpleXML element. - * - * @param \DOMNode $node A DOM Element node - * @param string $class_name You may use this optional parameter so that - * simplexml_import_dom will return an object of - * the specified class. That class should extend the - * SimpleXMLElement class. - * @return \SimpleXMLElement Returns a SimpleXMLElement. - * @throws SimplexmlException - * - */ -function simplexml_import_dom(\DOMNode $node, string $class_name = "SimpleXMLElement"): \SimpleXMLElement -{ - error_clear_last(); - $result = \simplexml_import_dom($node, $class_name); - if ($result === false) { - throw SimplexmlException::createFromPhpError(); - } - return $result; -} - - -/** - * Convert the well-formed XML document in the given file to an object. - * - * @param string $filename Path to the XML file - * - * Libxml 2 unescapes the URI, so if you want to pass e.g. - * b&c as the URI parameter a, - * you have to call - * simplexml_load_file(rawurlencode('http://example.com/?a=' . - * urlencode('b&c'))). Since PHP 5.1.0 you don't need to do - * this because PHP will do it for you. - * @param string $class_name You may use this optional parameter so that - * simplexml_load_file will return an object of - * the specified class. That class should extend the - * SimpleXMLElement class. - * @param int $options Since PHP 5.1.0 and Libxml 2.6.0, you may also use the - * options parameter to specify additional Libxml parameters. - * @param string $ns Namespace prefix or URI. - * @param bool $is_prefix TRUE if ns is a prefix, FALSE if it's a URI; - * defaults to FALSE. - * @return \SimpleXMLElement Returns an object of class SimpleXMLElement with - * properties containing the data held within the XML document. - * @throws SimplexmlException - * - */ -function simplexml_load_file(string $filename, string $class_name = "SimpleXMLElement", int $options = 0, string $ns = "", bool $is_prefix = false): \SimpleXMLElement -{ - error_clear_last(); - $result = \simplexml_load_file($filename, $class_name, $options, $ns, $is_prefix); - if ($result === false) { - throw SimplexmlException::createFromPhpError(); - } - return $result; -} - - -/** - * Takes a well-formed XML string and returns it as an object. - * - * @param string $data A well-formed XML string - * @param string $class_name You may use this optional parameter so that - * simplexml_load_string will return an object of - * the specified class. That class should extend the - * SimpleXMLElement class. - * @param int $options Since PHP 5.1.0 and Libxml 2.6.0, you may also use the - * options parameter to specify additional Libxml parameters. - * @param string $ns Namespace prefix or URI. - * @param bool $is_prefix TRUE if ns is a prefix, FALSE if it's a URI; - * defaults to FALSE. - * @return \SimpleXMLElement Returns an object of class SimpleXMLElement with - * properties containing the data held within the xml document. - * @throws SimplexmlException - * - */ -function simplexml_load_string(string $data, string $class_name = "SimpleXMLElement", int $options = 0, string $ns = "", bool $is_prefix = false): \SimpleXMLElement -{ - error_clear_last(); - $result = \simplexml_load_string($data, $class_name, $options, $ns, $is_prefix); - if ($result === false) { - throw SimplexmlException::createFromPhpError(); - } - return $result; -} diff --git a/vendor/thecodingmachine/safe/generated/sockets.php b/vendor/thecodingmachine/safe/generated/sockets.php index d6cc892b4..bfcd9bac4 100644 --- a/vendor/thecodingmachine/safe/generated/sockets.php +++ b/vendor/thecodingmachine/safe/generated/sockets.php @@ -10,23 +10,23 @@ use Safe\Exceptions\SocketsException; * 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 resource 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 + * 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 resource returned by + * 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 resource $socket A valid socket resource created with socket_create. - * @return resource Returns a new socket resource on success. The actual + * @param resource $socket A Socket instance created with socket_create. + * @return resource 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 @@ -46,19 +46,19 @@ function socket_accept($socket) /** - * Create a Socket resource, and bind it to the provided AddrInfo resource. The return + * Create a Socket instance, and bind it to the provided AddressInfo. The return * value of this function may be used with socket_listen. * - * @param resource $addr Resource created from socket_addrinfo_lookup. - * @return resource Returns a Socket resource on success. + * @param resource $address AddressInfo instance created from socket_addrinfo_lookup. + * @return resource|null Returns a Socket instance on success. * @throws SocketsException * */ -function socket_addrinfo_bind($addr) +function socket_addrinfo_bind($address) { error_clear_last(); - $result = \socket_addrinfo_bind($addr); - if ($result === null) { + $result = \socket_addrinfo_bind($address); + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -66,19 +66,50 @@ function socket_addrinfo_bind($addr) /** - * Create a Socket resource, and connect it to the provided AddrInfo resource. The return + * 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 resource $addr Resource created from socket_addrinfo_lookup - * @return resource Returns a Socket resource on success. + * @param resource $address AddressInfo instance created from socket_addrinfo_lookup + * @return resource|null Returns a Socket instance on success. + * @throws SocketsException + * + */ +function socket_addrinfo_connect($address) +{ + error_clear_last(); + $result = \socket_addrinfo_connect($address); + if ($result === false) { + throw SocketsException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 name, it is translated to the corresponding + * port number. + * @param array $hints Hints provide criteria for selecting addresses returned. You may specify the + * hints as defined by getadrinfo. + * @return resource[] 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_connect($addr) +function socket_addrinfo_lookup(string $host, $service = null, array $hints = []): iterable { error_clear_last(); - $result = \socket_addrinfo_connect($addr); - if ($result === null) { + if ($hints !== []) { + $result = \socket_addrinfo_lookup($host, $service, $hints); + } elseif ($service !== null) { + $result = \socket_addrinfo_lookup($host, $service); + } else { + $result = \socket_addrinfo_lookup($host); + } + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -91,7 +122,7 @@ function socket_addrinfo_connect($addr) * a connection is be established using socket_connect * or socket_listen. * - * @param resource $socket A valid socket resource created with socket_create. + * @param resource $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). @@ -116,11 +147,12 @@ function socket_bind($socket, string $address, int $port = 0): void /** - * Initiate a connection to address using the socket resource - * socket, which must be a valid socket - * resource created with socket_create. + * Initiate a connection to address using the Socket instance + * socket, which must be Socket + * instance created with socket_create. * - * @param resource $socket + * @param resource $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 @@ -135,10 +167,14 @@ function socket_bind($socket, string $address, int $port = 0): void * @throws SocketsException * */ -function socket_connect($socket, string $address, int $port = 0): void +function socket_connect($socket, string $address, int $port = null): void { error_clear_last(); - $result = \socket_connect($socket, $address, $port); + if ($port !== null) { + $result = \socket_connect($socket, $address, $port); + } else { + $result = \socket_connect($socket, $address); + } if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -146,7 +182,7 @@ function socket_connect($socket, string $address, int $port = 0): void /** - * socket_create_listen creates a new socket resource of + * 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. * @@ -159,7 +195,7 @@ function socket_connect($socket, string $address, int $port = 0): void * SOMAXCONN may be passed as * backlog parameter, see * socket_listen for more information. - * @return resource socket_create_listen returns a new socket resource + * @return resource 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 @@ -180,7 +216,7 @@ function socket_create_listen(int $port, int $backlog = 128) /** * socket_create_pair creates two connected and - * indistinguishable sockets, and stores them in fd. + * 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 @@ -199,14 +235,14 @@ function socket_create_listen(int $port, int $backlog = 128) * * See socket_create for the full list of supported * protocols. - * @param resource[]|null $fd Reference to an array in which the two socket resources will be inserted. + * @param resource[]|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, ?iterable &$fd): void +function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$pair): void { error_clear_last(); - $result = \socket_create_pair($domain, $type, $protocol, $fd); + $result = \socket_create_pair($domain, $type, $protocol, $pair); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -214,7 +250,7 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$f /** - * Creates and returns a socket resource, also referred to as an endpoint + * 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. * @@ -229,7 +265,7 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$f * the desired protocol is TCP, or UDP the corresponding constants * SOL_TCP, and SOL_UDP * can also be used. - * @return resource socket_create returns a socket resource on success. The actual error code can be retrieved by calling + * @return resource 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. @@ -268,10 +304,10 @@ function socket_export_stream($socket) /** * The socket_get_option function retrieves the value for - * the option specified by the optname parameter for the + * the option specified by the option parameter for the * specified socket. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $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 @@ -280,7 +316,7 @@ function socket_export_stream($socket) * TCP, can be used by * specifying the protocol number of that level. Protocol numbers can be * found by using the getprotobyname function. - * @param int $optname Reports whether the socket lingers on + * @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, @@ -298,14 +334,14 @@ function socket_export_stream($socket) * 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 options. + * @return mixed Returns the value of the given option. * @throws SocketsException * */ -function socket_get_option($socket, int $level, int $optname) +function socket_get_option($socket, int $level, int $option) { error_clear_last(); - $result = \socket_get_option($socket, $level, $optname); + $result = \socket_get_option($socket, $level, $option); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -317,9 +353,9 @@ function socket_get_option($socket, int $level, int $optname) * 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 resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string $address If the given socket is of type AF_INET or + * @param string|null $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 @@ -336,7 +372,7 @@ function socket_get_option($socket, int $level, int $optname) * @throws SocketsException * */ -function socket_getpeername($socket, string &$address, ?int &$port = null): void +function socket_getpeername($socket, ?string &$address, ?int &$port = null): void { error_clear_last(); $result = \socket_getpeername($socket, $address, $port); @@ -349,9 +385,9 @@ function socket_getpeername($socket, string &$address, ?int &$port = null): void /** * * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string|null $addr If the given socket is of type AF_INET + * @param string|null $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 @@ -366,10 +402,10 @@ function socket_getpeername($socket, string &$address, ?int &$port = null): void * @throws SocketsException * */ -function socket_getsockname($socket, ?string &$addr, ?int &$port = null): void +function socket_getsockname($socket, ?string &$address, ?int &$port = null): void { error_clear_last(); - $result = \socket_getsockname($socket, $addr, $port); + $result = \socket_getsockname($socket, $address, $port); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -380,7 +416,7 @@ function socket_getsockname($socket, ?string &$addr, ?int &$port = null): void * Imports a stream that encapsulates a socket into a socket extension resource. * * @param resource $stream The stream resource to import. - * @return resource|false Returns FALSE. + * @return resource Returns FALSE on failure. * @throws SocketsException * */ @@ -388,7 +424,7 @@ function socket_import_stream($stream) { error_clear_last(); $result = \socket_import_stream($stream); - if ($result === null) { + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -405,7 +441,7 @@ function socket_import_stream($stream) * type SOCK_STREAM or * SOCK_SEQPACKET. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $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 @@ -434,19 +470,19 @@ function socket_listen($socket, int $backlog = 0): void /** - * The function socket_read reads from the socket - * resource socket created by the + * The function socket_read reads from the Socket instance + * socket created by the * socket_create or * socket_accept functions. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $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 type + * or \0 to end reading (depending on the mode * parameter, see below). - * @param int $type Optional type parameter is a named constant: + * @param int $mode Optional mode parameter is a named constant: * * * @@ -469,10 +505,10 @@ function socket_listen($socket, int $backlog = 0): void * @throws SocketsException * */ -function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string +function socket_read($socket, int $length, int $mode = PHP_BINARY_READ): string { error_clear_last(); - $result = \socket_read($socket, $length, $type); + $result = \socket_read($socket, $length, $mode); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -482,14 +518,14 @@ function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string /** * The function socket_send sends - * len bytes to the socket - * socket from buf. + * length bytes to the socket + * socket from data. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string $buf A buffer containing the data that will be sent to the remote host. - * @param int $len The number of bytes that will be sent to the remote host from - * buf. + * @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. @@ -530,10 +566,10 @@ function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string * @throws SocketsException * */ -function socket_send($socket, string $buf, int $len, int $flags): int +function socket_send($socket, string $data, int $length, int $flags): int { error_clear_last(); - $result = \socket_send($socket, $buf, $len, $flags); + $result = \socket_send($socket, $data, $length, $flags); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -564,13 +600,13 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int /** * The function socket_sendto sends - * len bytes from buf + * length bytes from data * through the socket socket to the - * port at the address addr. + * port at the address address. * - * @param resource $socket A valid socket resource created using socket_create. - * @param string $buf The sent data will be taken from buffer buf. - * @param int $len len bytes from buf will be + * @param resource $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 (|) @@ -608,7 +644,7 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int * * * - * @param string $addr IP address of the remote host. + * @param string $address IP address of the remote host. * @param int $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 @@ -616,10 +652,14 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int * @throws SocketsException * */ -function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, int $port = 0): int +function socket_sendto($socket, string $data, int $length, int $flags, string $address, int $port = null): int { error_clear_last(); - $result = \socket_sendto($socket, $buf, $len, $flags, $addr, $port); + if ($port !== null) { + $result = \socket_sendto($socket, $data, $length, $flags, $address, $port); + } else { + $result = \socket_sendto($socket, $data, $length, $flags, $address); + } if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -636,7 +676,7 @@ function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, * a blocking socket, the script will pause its execution until it receives * a signal or it can perform the operation. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @throws SocketsException * @@ -661,7 +701,7 @@ function socket_set_block($socket): void * signal or it can perform the operation. Rather, if the operation would result * in a block, the called function will fail. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @throws SocketsException * @@ -678,12 +718,12 @@ function socket_set_nonblock($socket): void /** * The socket_set_option function sets the option - * specified by the optname parameter, at the + * specified by the option parameter, at the * specified protocol level, to the value pointed to - * by the optval parameter for the + * by the value parameter for the * socket. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $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 @@ -692,16 +732,16 @@ function socket_set_nonblock($socket): void * TCP, can be used by specifying the protocol number of that level. * Protocol numbers can be found by using the * getprotobyname function. - * @param int $optname The available socket options are the same as those for the + * @param int $option The available socket options are the same as those for the * socket_get_option function. - * @param int|string|array $optval The option value. + * @param int|string|array $value The option value. * @throws SocketsException * */ -function socket_set_option($socket, int $level, int $optname, $optval): void +function socket_set_option($socket, int $level, int $option, $value): void { error_clear_last(); - $result = \socket_set_option($socket, $level, $optname, $optval); + $result = \socket_set_option($socket, $level, $option, $value); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -713,10 +753,10 @@ function socket_set_option($socket, int $level, int $optname, $optval): void * incoming, outgoing or all data (the default) from being sent through the * socket * - * @param resource $socket A valid socket resource created with socket_create. - * @param int $how The value of how can be one of the following: + * @param resource $socket A Socket instance created with socket_create. + * @param int $mode The value of mode can be one of the following: * - * possible values for how + * possible values for mode * * * @@ -743,10 +783,10 @@ function socket_set_option($socket, int $level, int $optname, $optval): void * @throws SocketsException * */ -function socket_shutdown($socket, int $how = 2): void +function socket_shutdown($socket, int $mode = 2): void { error_clear_last(); - $result = \socket_shutdown($socket, $how); + $result = \socket_shutdown($socket, $mode); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -756,18 +796,18 @@ function socket_shutdown($socket, int $how = 2): void /** * 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 target_pid. + * exported ID is only valid for the given process_id. * - * @param resource $socket A valid socket resource. - * @param int $target_pid The ID of the process which will import the socket. + * @param resource $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, int $target_pid): string +function socket_wsaprotocol_info_export($socket, int $process_id): string { error_clear_last(); - $result = \socket_wsaprotocol_info_export($socket, $target_pid); + $result = \socket_wsaprotocol_info_export($socket, $process_id); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -780,7 +820,7 @@ function socket_wsaprotocol_info_export($socket, int $target_pid): string * * @param string $info_id The ID which has been returned by a former call to * socket_wsaprotocol_info_export. - * @return resource Returns the socket resource + * @return resource Returns a Socket instance on success * @throws SocketsException * */ diff --git a/vendor/thecodingmachine/safe/generated/sodium.php b/vendor/thecodingmachine/safe/generated/sodium.php index 6cb378adb..d13da0da9 100644 --- a/vendor/thecodingmachine/safe/generated/sodium.php +++ b/vendor/thecodingmachine/safe/generated/sodium.php @@ -5,24 +5,240 @@ namespace Safe; use Safe\Exceptions\SodiumException; /** - * Uses a CPU- and memory-hard hash algorithm along with a randomly-generated salt, and memory and CPU limits to generate an ASCII-encoded hash suitable for password storage. + * Verify then decrypt with AES-256-GCM. + * Only available if sodium_crypto_aead_aes256gcm_is_available returns TRUE. * - * @param string $password string; The password to generate a hash for. - * @param int $opslimit Represents a maximum amount of computations to perform. Raising this number will make the function require more CPU cycles to compute a key. There are constants available to set the operations limit to appropriate values depending on intended use, in order of strength: SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE and SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE. - * @param int $memlimit The maximum amount of RAM that the function will use, in bytes. There are constants to help you choose an appropriate value, in order of size: SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE, and SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE. Typically these should be paired with the matching opslimit values. - * @return string Returns the hashed password. + * @param string $ciphertext Must be in the format provided by sodium_crypto_aead_aes256gcm_encrypt + * (ciphertext and tag, concatenated). + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 12 bytes long. + * @param string $key Encryption key (256-bit). + * @return string Returns the plaintext on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_aes256gcm_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Verify then decrypt with ChaCha20-Poly1305. + * + * @param string $ciphertext Must be in the format provided by sodium_crypto_aead_chacha20poly1305_encrypt + * (ciphertext and tag, concatenated). + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 8 bytes long. + * @param string $key Encryption key (256-bit). + * @return string Returns the plaintext on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_chacha20poly1305_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_chacha20poly1305_decrypt($ciphertext, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Encrypt then authenticate with ChaCha20-Poly1305. + * + * @param string $message The plaintext message to encrypt. + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 8 bytes long. + * @param string $key Encryption key (256-bit). + * @return string Returns the ciphertext and tag on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_chacha20poly1305_encrypt(string $message, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_chacha20poly1305_encrypt($message, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Verify then decrypt with ChaCha20-Poly1305 (IETF variant). + * + * The IETF variant uses 96-bit nonces and 32-bit internal counters, instead of 64-bit for both. + * + * @param string $ciphertext Must be in the format provided by sodium_crypto_aead_chacha20poly1305_ietf_encrypt + * (ciphertext and tag, concatenated). + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 12 bytes long. + * @param string $key Encryption key (256-bit). + * @return string Returns the plaintext on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_chacha20poly1305_ietf_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_chacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Encrypt then authenticate with ChaCha20-Poly1305 (IETF variant). + * + * The IETF variant uses 96-bit nonces and 32-bit internal counters, instead of 64-bit for both. + * + * @param string $message The plaintext message to encrypt. + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 12 bytes long. + * @param string $key Encryption key (256-bit). + * @return string Returns the ciphertext and tag on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_chacha20poly1305_ietf_encrypt(string $message, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Verify then decrypt with ChaCha20-Poly1305 (eXtended-nonce variant). + * + * Generally, XChaCha20-Poly1305 is the best of the provided AEAD modes to use. + * + * @param string $ciphertext Must be in the format provided by sodium_crypto_aead_chacha20poly1305_ietf_encrypt + * (ciphertext and tag, concatenated). + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 24 bytes long. + * This is a large enough bound to generate randomly (i.e. random_bytes). + * @param string $key Encryption key (256-bit). + * @return string Returns the plaintext on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Encrypt then authenticate with XChaCha20-Poly1305 (eXtended-nonce variant). + * + * Generally, XChaCha20-Poly1305 is the best of the provided AEAD modes to use. + * + * @param string $message The plaintext message to encrypt. + * @param string $additional_data Additional, authenticated data. This is used in the verification of the authentication tag + * appended to the ciphertext, but it is not encrypted or stored in the ciphertext. + * @param string $nonce A number that must be only used once, per message. 24 bytes long. + * This is a large enough bound to generate randomly (i.e. random_bytes). + * @param string $key Encryption key (256-bit). + * @return string Returns the ciphertext and tag on success. + * @throws SodiumException + * + */ +function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(string $message, string $additional_data, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Verify the authentication tag is valid for a given message and key. + * + * Unlike with digital signatures (e.g. sodium_crypto_sign_verify_detached), + * any party capable of verifying a message is also capable of authenticating + * their own messages. (Hence, symmetric authentication.) + * + * @param string $mac Authentication tag produced by sodium_crypto_auth + * @param string $message Message + * @param string $key Authentication key + * @throws SodiumException + * + */ +function sodium_crypto_auth_verify(string $mac, string $message, string $key): void +{ + error_clear_last(); + $result = \sodium_crypto_auth_verify($mac, $message, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } +} + + +/** + * Decrypt a message using asymmetric (public key) cryptography. + * + * @param string $ciphertext The encrypted message to attempt to decrypt. + * @param string $nonce A number that must be only used once, per message. 24 bytes long. + * This is a large enough bound to generate randomly (i.e. random_bytes). + * @param string $key_pair See sodium_crypto_box_keypair_from_secretkey_and_publickey. + * This should include the sender's public key and the recipient's secret key. + * @return string Returns the plaintext message on success. + * @throws SodiumException + * + */ +function sodium_crypto_box_open(string $ciphertext, string $nonce, string $key_pair): string +{ + error_clear_last(); + $result = \sodium_crypto_box_open($ciphertext, $nonce, $key_pair); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Decrypt a message that was encrypted with sodium_crypto_box_seal * - * In order to produce the same password hash from the same password, the same values for opslimit and memlimit must be used. These are embedded within the generated hash, so - * everything that's needed to verify the hash is included. This allows - * the sodium_crypto_pwhash_str_verify function to verify the hash without - * needing separate storage for the other parameters. + * @param string $ciphertext The encrypted message + * @param string $key_pair The keypair of the recipient. Must include the secret key. + * @return string The plaintext on success. * @throws SodiumException * */ -function sodium_crypto_pwhash_str(string $password, int $opslimit, int $memlimit): string +function sodium_crypto_box_seal_open(string $ciphertext, string $key_pair): string { error_clear_last(); - $result = \sodium_crypto_pwhash_str($password, $opslimit, $memlimit); + $result = \sodium_crypto_box_seal_open($ciphertext, $key_pair); if ($result === false) { throw SodiumException::createFromPhpError(); } @@ -31,28 +247,80 @@ function sodium_crypto_pwhash_str(string $password, int $opslimit, int $memlimit /** - * This function provides low-level access to libsodium's crypto_pwhash key derivation function. Unless you have specific reason to use this function, you should use sodium_crypto_pwhash_str or password_hash functions instead. + * Appends a message to the internal hash state. * - * @param int $length integer; The length of the password hash to generate, in bytes. - * @param string $password string; The password to generate a hash for. - * @param string $salt string A salt to add to the password before hashing. The salt should be unpredictable, ideally generated from a good random mumber source such as random_bytes, and have a length of at least SODIUM_CRYPTO_PWHASH_SALTBYTES bytes. - * @param int $opslimit Represents a maximum amount of computations to perform. Raising this number will make the function require more CPU cycles to compute a key. There are some constants available to set the operations limit to appropriate values depending on intended use, in order of strength: SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE and SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE. - * @param int $memlimit The maximum amount of RAM that the function will use, in bytes. There are constants to help you choose an appropriate value, in order of size: SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE, and SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE. Typically these should be paired with the matching opslimit values. - * @param int $alg integer A number indicating the hash algorithm to use. By default SODIUM_CRYPTO_PWHASH_ALG_DEFAULT (the currently recommended algorithm, which can change from one version of libsodium to another), or explicitly using SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13, representing the Argon2id algorithm version 1.3. - * @return string Returns the derived key. The return value is a binary string of the hash, not an ASCII-encoded representation, and does not contain additional information about the parameters used to create the hash, so you will need to keep that information if you are ever going to verify the password in future. Use sodium_crypto_pwhash_str to avoid needing to do all that. + * @param string $state The return value of sodium_crypto_generichash_init. + * @param string $message Data to append to the hashing state. * @throws SodiumException * */ -function sodium_crypto_pwhash(int $length, string $password, string $salt, int $opslimit, int $memlimit, int $alg = null): string +function sodium_crypto_generichash_update(string &$state, string $message): void { error_clear_last(); - if ($alg !== null) { - $result = \sodium_crypto_pwhash($length, $password, $salt, $opslimit, $memlimit, $alg); - } else { - $result = \sodium_crypto_pwhash($length, $password, $salt, $opslimit, $memlimit); + $result = \sodium_crypto_generichash_update($state, $message); + if ($result === false) { + throw SodiumException::createFromPhpError(); } +} + + +/** + * Decrypt an encrypted message with a symmetric (shared) key. + * + * @param string $ciphertext Must be in the format provided by sodium_crypto_secretbox + * (ciphertext and tag, concatenated). + * @param string $nonce A number that must be only used once, per message. 24 bytes long. + * This is a large enough bound to generate randomly (i.e. random_bytes). + * @param string $key Encryption key (256-bit). + * @return string The decrypted string on success. + * @throws SodiumException + * + */ +function sodium_crypto_secretbox_open(string $ciphertext, string $nonce, string $key): string +{ + error_clear_last(); + $result = \sodium_crypto_secretbox_open($ciphertext, $nonce, $key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } + return $result; +} + + +/** + * Verify the signature attached to a message and return the message + * + * @param string $signed_message A message signed with sodium_crypto_sign + * @param string $public_key An Ed25519 public key + * @return string Returns the original signed message on success. + * @throws SodiumException + * + */ +function sodium_crypto_sign_open(string $signed_message, string $public_key): string +{ + error_clear_last(); + $result = \sodium_crypto_sign_open($signed_message, $public_key); if ($result === false) { throw SodiumException::createFromPhpError(); } return $result; } + + +/** + * Verify signature for the message + * + * @param string $signature The cryptographic signature obtained from sodium_crypto_sign_detached + * @param string $message The message being verified + * @param string $public_key Ed25519 public key + * @throws SodiumException + * + */ +function sodium_crypto_sign_verify_detached(string $signature, string $message, string $public_key): void +{ + error_clear_last(); + $result = \sodium_crypto_sign_verify_detached($signature, $message, $public_key); + if ($result === false) { + throw SodiumException::createFromPhpError(); + } +} diff --git a/vendor/thecodingmachine/safe/generated/spl.php b/vendor/thecodingmachine/safe/generated/spl.php index 679e68991..08c679dc2 100644 --- a/vendor/thecodingmachine/safe/generated/spl.php +++ b/vendor/thecodingmachine/safe/generated/spl.php @@ -6,19 +6,18 @@ use Safe\Exceptions\SplException; /** * This function returns an array with the names of the interfaces that the - * given class and its parents implement. + * given object_or_class and its parents implement. * - * @param mixed $class An object (class instance) or a string (class or interface name). - * @param bool $autoload Whether to allow this function to load the class automatically through - * the __autoload magic method. - * @return array An array on success. + * @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($class, bool $autoload = true): array +function class_implements($object_or_class, bool $autoload = true): array { error_clear_last(); - $result = \class_implements($class, $autoload); + $result = \class_implements($object_or_class, $autoload); if ($result === false) { throw SplException::createFromPhpError(); } @@ -28,19 +27,18 @@ function class_implements($class, bool $autoload = true): array /** * This function returns an array with the name of the parent classes of - * the given class. + * the given object_or_class. * - * @param mixed $class An object (class instance) or a string (class name). - * @param bool $autoload Whether to allow this function to load the class automatically through - * the __autoload magic method. - * @return array An array on success. + * @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($class, bool $autoload = true): array +function class_parents($object_or_class, bool $autoload = true): array { error_clear_last(); - $result = \class_parents($class, $autoload); + $result = \class_parents($object_or_class, $autoload); if ($result === false) { throw SplException::createFromPhpError(); } @@ -50,20 +48,19 @@ function class_parents($class, bool $autoload = true): array /** * This function returns an array with the names of the traits that the - * given class uses. This does however not include + * given object_or_class uses. This does however not include * any traits used by a parent class. * - * @param mixed $class An object (class instance) or a string (class name). - * @param bool $autoload Whether to allow this function to load the class automatically through - * the __autoload magic method. - * @return array An array on success. + * @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($class, bool $autoload = true): array +function class_uses($object_or_class, bool $autoload = true): array { error_clear_last(); - $result = \class_uses($class, $autoload); + $result = \class_uses($object_or_class, $autoload); if ($result === false) { throw SplException::createFromPhpError(); } @@ -87,27 +84,27 @@ function class_uses($class, bool $autoload = true): array * runs through each of them in the order they are defined. By contrast, * __autoload may only be defined once. * - * @param callable(string):void $autoload_function The autoload function being registered. - * If no parameter is provided, then the default implementation of + * @param callable(string):void $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 autoload_function + * 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 $autoload_function = null, bool $throw = true, bool $prepend = false): void +function spl_autoload_register(callable $callback = null, bool $throw = true, bool $prepend = false): void { error_clear_last(); if ($prepend !== false) { - $result = \spl_autoload_register($autoload_function, $throw, $prepend); + $result = \spl_autoload_register($callback, $throw, $prepend); } elseif ($throw !== true) { - $result = \spl_autoload_register($autoload_function, $throw); - } elseif ($autoload_function !== null) { - $result = \spl_autoload_register($autoload_function); + $result = \spl_autoload_register($callback, $throw); + } elseif ($callback !== null) { + $result = \spl_autoload_register($callback); } else { $result = \spl_autoload_register(); } @@ -125,14 +122,14 @@ function spl_autoload_register(callable $autoload_function = null, bool $throw = * When this function results in the queue being deactivated, any * __autoload function that previously existed will not be reactivated. * - * @param mixed $autoload_function The autoload function being unregistered. + * @param mixed $callback The autoload function being unregistered. * @throws SplException * */ -function spl_autoload_unregister($autoload_function): void +function spl_autoload_unregister($callback): void { error_clear_last(); - $result = \spl_autoload_unregister($autoload_function); + $result = \spl_autoload_unregister($callback); if ($result === false) { throw SplException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/ssh2.php b/vendor/thecodingmachine/safe/generated/ssh2.php index 96af9df32..fff3ceb6f 100644 --- a/vendor/thecodingmachine/safe/generated/ssh2.php +++ b/vendor/thecodingmachine/safe/generated/ssh2.php @@ -381,6 +381,53 @@ function ssh2_exec($session, string $command, string $pty = null, array $env = n /** + * Accepts a connection created by a listener. + * + * @param resource $listener An SSH2 Listener resource, obtained from a call to ssh2_forward_listen. + * @return Returns a stream resource. + * @throws Ssh2Exception + * + */ +function ssh2_forward_accept($listener) +{ + error_clear_last(); + $result = \ssh2_forward_accept($listener); + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } + return $result; +} + + +/** + * Binds a port on the remote server and listen for connections. + * + * @param resource $session An SSH Session resource, obtained from a call to ssh2_connect. + * @param int $port The port of the remote server. + * @param string $host + * @param int $max_connections + * @return Returns an SSH2 Listener. + * @throws Ssh2Exception + * + */ +function ssh2_forward_listen($session, int $port, string $host = null, int $max_connections = 16) +{ + error_clear_last(); + if ($max_connections !== 16) { + $result = \ssh2_forward_listen($session, $port, $host, $max_connections); + } elseif ($host !== null) { + $result = \ssh2_forward_listen($session, $port, $host); + } else { + $result = \ssh2_forward_listen($session, $port); + } + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } + return $result; +} + + +/** * * * @param resource $pkey Publickey Subsystem resource created by ssh2_publickey_init. @@ -497,6 +544,27 @@ function ssh2_scp_send($session, string $local_file, string $remote_file, int $c /** + * Sends an EOF to the stream; this is typically used to close standard input, + * while keeping output and error alive. For example, one can send a remote + * process some data over standard input, close it to start processing, and + * still be able to read out the results without creating additional files. + * + * @param resource $channel An SSH stream; can be acquired through functions like ssh2_fetch_stream + * or ssh2_connect. + * @throws Ssh2Exception + * + */ +function ssh2_send_eof($channel): void +{ + error_clear_last(); + $result = \ssh2_send_eof($channel); + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } +} + + +/** * Attempts to change the mode of the specified file to that given in * mode. * @@ -526,6 +594,7 @@ function ssh2_sftp_chmod($sftp, string $filename, int $mode): void * @param resource $sftp An SSH2 SFTP resource opened by ssh2_sftp. * @param string $dirname Path of the new directory. * @param int $mode Permissions on the new directory. + * The actual mode is affected by the current umask. * @param bool $recursive If recursive is TRUE any parent directories * required for dirname will be automatically created as well. * @throws Ssh2Exception @@ -639,3 +708,42 @@ function ssh2_sftp($session) } return $result; } + + +/** + * Open a shell at the remote end and allocate a stream for it. + * + * @param resource $session An SSH connection link identifier, obtained from a call to + * ssh2_connect. + * @param string $term_type term_type should correspond to one of the + * entries in the target system's /etc/termcap file. + * @param array $env env may be passed as an associative array of + * name/value pairs to set in the target environment. + * @param int $width Width of the virtual terminal. + * @param int $height Height of the virtual terminal. + * @param int $width_height_type width_height_type should be one of + * SSH2_TERM_UNIT_CHARS or + * SSH2_TERM_UNIT_PIXELS. + * @return resource Returns a stream resource on success. + * @throws Ssh2Exception + * + */ +function ssh2_shell($session, string $term_type = "vanilla", array $env = null, int $width = 80, int $height = 25, int $width_height_type = SSH2_TERM_UNIT_CHARS) +{ + error_clear_last(); + if ($width_height_type !== SSH2_TERM_UNIT_CHARS) { + $result = \ssh2_shell($session, $term_type, $env, $width, $height, $width_height_type); + } elseif ($height !== 25) { + $result = \ssh2_shell($session, $term_type, $env, $width, $height); + } elseif ($width !== 80) { + $result = \ssh2_shell($session, $term_type, $env, $width); + } elseif ($env !== null) { + $result = \ssh2_shell($session, $term_type, $env); + } else { + $result = \ssh2_shell($session, $term_type); + } + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } + return $result; +} diff --git a/vendor/thecodingmachine/safe/generated/stream.php b/vendor/thecodingmachine/safe/generated/stream.php index 573d0295a..3d086e149 100644 --- a/vendor/thecodingmachine/safe/generated/stream.php +++ b/vendor/thecodingmachine/safe/generated/stream.php @@ -7,18 +7,16 @@ use Safe\Exceptions\StreamException; /** * Sets parameters on the specified context. * - * @param resource $stream_or_context The stream or context to apply the parameters too. - * @param array $params An array of parameters to set. - * - * params should be an associative array of the structure: + * @param resource $context The stream or context to apply the parameters too. + * @param array $params An associative array of parameters to be set in the following format: * $params['paramname'] = "paramvalue";. * @throws StreamException * */ -function stream_context_set_params($stream_or_context, array $params): void +function stream_context_set_params($context, array $params): void { error_clear_last(); - $result = \stream_context_set_params($stream_or_context, $params); + $result = \stream_context_set_params($context, $params); if ($result === false) { throw StreamException::createFromPhpError(); } @@ -26,25 +24,31 @@ function stream_context_set_params($stream_or_context, array $params): void /** - * Makes a copy of up to maxlength bytes + * Makes a copy of up to length bytes * of data from the current position (or from the * offset position, if specified) in - * source to dest. If - * maxlength is not specified, all remaining content in - * source will be copied. + * from to to. If + * length is NULL, all remaining content in + * from will be copied. * - * @param resource $source The source stream - * @param resource $dest The destination stream - * @param int $maxlength Maximum bytes to copy + * @param resource $from The source stream + * @param resource $to The destination stream + * @param int $length Maximum bytes to copy. By default all bytes left are copied. * @param int $offset The offset where to start to copy data * @return int Returns the total count of bytes copied. * @throws StreamException * */ -function stream_copy_to_stream($source, $dest, int $maxlength = -1, int $offset = 0): int +function stream_copy_to_stream($from, $to, int $length = null, int $offset = 0): int { error_clear_last(); - $result = \stream_copy_to_stream($source, $dest, $maxlength, $offset); + if ($offset !== 0) { + $result = \stream_copy_to_stream($from, $to, $length, $offset); + } elseif ($length !== null) { + $result = \stream_copy_to_stream($from, $to, $length); + } else { + $result = \stream_copy_to_stream($from, $to); + } if ($result === false) { throw StreamException::createFromPhpError(); } @@ -69,7 +73,7 @@ function stream_copy_to_stream($source, $dest, int $maxlength = -1, int $offset * STREAM_FILTER_WRITE, and/or * STREAM_FILTER_ALL can also be passed to the * read_write parameter to override this behavior. - * @param mixed $params This filter will be added with the specified + * @param array $params This filter will be added with the specified * params to the end of * the list and will therefore be called last during stream operations. * To add a filter to the beginning of the list, use @@ -83,7 +87,7 @@ function stream_copy_to_stream($source, $dest, int $maxlength = -1, int $offset * @throws StreamException * */ -function stream_filter_append($stream, string $filtername, int $read_write = null, $params = null) +function stream_filter_append($stream, string $filtername, int $read_write = null, array $params = null) { error_clear_last(); if ($params !== null) { @@ -119,7 +123,7 @@ function stream_filter_append($stream, string $filtername, int $read_write = nul * read_write parameter to override this behavior. * See stream_filter_append for an example of * using this parameter. - * @param mixed $params This filter will be added with the specified params + * @param array $params This filter will be added with the specified params * to the beginning of the list and will therefore be * called first during stream operations. To add a filter to the end of the * list, use stream_filter_append. @@ -132,7 +136,7 @@ function stream_filter_append($stream, string $filtername, int $read_write = nul * @throws StreamException * */ -function stream_filter_prepend($stream, string $filtername, int $read_write = null, $params = null) +function stream_filter_prepend($stream, string $filtername, int $read_write = null, array $params = null) { error_clear_last(); if ($params !== null) { @@ -155,8 +159,8 @@ function stream_filter_prepend($stream, string $filtername, int $read_write = nu * filesystem functions (such as fopen, * fread etc.). * - * @param string $filtername The filter name to be registered. - * @param string $classname To implement a filter, you need to define a class as an extension of + * @param string $filter_name The filter name to be registered. + * @param string $class To implement a filter, you need to define a class as an extension of * php_user_filter with a number of member * functions. When performing read/write operations on the stream * to which your filter is attached, PHP will pass the data through your @@ -167,10 +171,10 @@ function stream_filter_prepend($stream, string $filtername, int $read_write = nu * @throws StreamException * */ -function stream_filter_register(string $filtername, string $classname): void +function stream_filter_register(string $filter_name, string $class): void { error_clear_last(); - $result = \stream_filter_register($filtername, $classname); + $result = \stream_filter_register($filter_name, $class); if ($result === false) { throw StreamException::createFromPhpError(); } @@ -202,11 +206,11 @@ function stream_filter_remove($stream_filter): void * Identical to file_get_contents, except that * stream_get_contents operates on an already open * stream resource and returns the remaining contents in a string, up to - * maxlength bytes and starting at the specified + * length bytes and starting at the specified * offset. * - * @param resource $handle A stream resource (e.g. returned from fopen) - * @param int $maxlength The maximum bytes to read. Defaults to -1 (read all the remaining + * @param resource $stream A stream resource (e.g. returned from fopen) + * @param int $length The maximum bytes to read. Defaults to NULL (read all the remaining * buffer). * @param int $offset Seek to the specified offset before reading. If this number is negative, * no seeking will occur and reading will start from the current position. @@ -214,10 +218,50 @@ function stream_filter_remove($stream_filter): void * @throws StreamException * */ -function stream_get_contents($handle, int $maxlength = -1, int $offset = -1): string +function stream_get_contents($stream, int $length = null, int $offset = -1): string +{ + error_clear_last(); + if ($offset !== -1) { + $result = \stream_get_contents($stream, $length, $offset); + } elseif ($length !== null) { + $result = \stream_get_contents($stream, $length); + } else { + $result = \stream_get_contents($stream); + } + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets a line from the given handle. + * + * Reading ends when length bytes have been read, when + * the non-empty string specified by ending is found (which is + * not included in the return value), or on EOF + * (whichever comes first). + * + * This function is nearly identical to fgets except in + * that it allows end of line delimiters other than the standard \n, \r, and + * \r\n, and does not return the delimiter itself. + * + * @param resource $stream A valid file handle. + * @param int $length The maximum number of bytes to read from the handle. + * Negative values are not supported. + * Zero (0) means the default socket chunk size, + * i.e. 8192 bytes. + * @param string $ending An optional string delimiter. + * @return string Returns a string of up to length bytes read from the file + * pointed to by stream. + * @throws StreamException + * + */ +function stream_get_line($stream, int $length, string $ending = ""): string { error_clear_last(); - $result = \stream_get_contents($handle, $maxlength, $offset); + $result = \stream_get_line($stream, $length, $ending); if ($result === false) { throw StreamException::createFromPhpError(); } @@ -269,7 +313,7 @@ function stream_resolve_include_path(string $filename): string * (currently, regular files and socket streams). * * @param resource $stream The stream. - * @param bool $mode If mode is FALSE, the given stream + * @param bool $enable If enable is FALSE, the given stream * will be switched to non-blocking mode, and if TRUE, it * will be switched to blocking mode. This affects calls like * fgets and fread @@ -280,10 +324,10 @@ function stream_resolve_include_path(string $filename): string * @throws StreamException * */ -function stream_set_blocking($stream, bool $mode): void +function stream_set_blocking($stream, bool $enable): void { error_clear_last(); - $result = \stream_set_blocking($stream, $mode); + $result = \stream_set_blocking($stream, $enable); if ($result === false) { throw StreamException::createFromPhpError(); } @@ -319,10 +363,11 @@ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void * Accept a connection on a socket previously created by * stream_socket_server. * - * @param resource $server_socket The server socket to accept a connection from. + * @param resource $socket The server socket to accept a connection from. * @param float $timeout Override the default socket accept timeout. Time should be given in - * seconds. - * @param string|null $peername Will be set to the name (address) of the client which connected, if + * seconds. By default, default_socket_timeout + * is used. + * @param string|null $peer_name Will be set to the name (address) of the client which connected, if * included and available from the selected transport. * * Can also be determined later using @@ -331,15 +376,15 @@ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void * @throws StreamException * */ -function stream_socket_accept($server_socket, float $timeout = null, ?string &$peername = null) +function stream_socket_accept($socket, float $timeout = null, ?string &$peer_name = null) { error_clear_last(); - if ($peername !== null) { - $result = \stream_socket_accept($server_socket, $timeout, $peername); + if ($peer_name !== null) { + $result = \stream_socket_accept($socket, $timeout, $peer_name); } elseif ($timeout !== null) { - $result = \stream_socket_accept($server_socket, $timeout); + $result = \stream_socket_accept($socket, $timeout); } else { - $result = \stream_socket_accept($server_socket); + $result = \stream_socket_accept($socket); } if ($result === false) { throw StreamException::createFromPhpError(); @@ -350,20 +395,21 @@ function stream_socket_accept($server_socket, float $timeout = null, ?string &$p /** * Initiates a stream or datagram connection to the destination specified - * by remote_socket. The type of socket created + * by address. The type of socket created * is determined by the transport specified using standard URL formatting: * transport://target. For Internet Domain sockets * (AF_INET) such as TCP and UDP, the target portion - * of the remote_socket parameter should consist of + * of the address parameter should consist of * a hostname or IP address followed by a colon and a port number. For Unix * domain sockets, the target portion should point * to the socket file on the filesystem. * - * @param string $remote_socket Address to the socket to connect to. - * @param int $errno Will be set to the system level error number if connection fails. - * @param string $errstr Will be set to the system level error message if the connection fails. + * @param string $address Address to the socket to connect to. + * @param int|null $error_code Will be set to the system level error number if connection fails. + * @param string|null $error_message Will be set to the system level error message if the connection fails. * @param float $timeout Number of seconds until the connect() system call - * should timeout. + * should timeout. By default, default_socket_timeout + * is used. * * * This parameter only applies when not making asynchronous @@ -397,17 +443,17 @@ function stream_socket_accept($server_socket, float $timeout = null, ?string &$p * @throws StreamException * */ -function stream_socket_client(string $remote_socket, int &$errno = null, string &$errstr = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null) +function stream_socket_client(string $address, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null) { error_clear_last(); if ($context !== null) { - $result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout, $flags, $context); + $result = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags, $context); } elseif ($flags !== STREAM_CLIENT_CONNECT) { - $result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout, $flags); + $result = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags); } elseif ($timeout !== null) { - $result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout); + $result = \stream_socket_client($address, $error_code, $error_message, $timeout); } else { - $result = \stream_socket_client($remote_socket, $errno, $errstr); + $result = \stream_socket_client($address, $error_code, $error_message); } if ($result === false) { throw StreamException::createFromPhpError(); @@ -417,6 +463,27 @@ function stream_socket_client(string $remote_socket, int &$errno = null, string /** + * Returns the local or remote name of a given socket connection. + * + * @param resource $socket The socket to get the name of. + * @param bool $remote If set to TRUE the remote socket name will be returned, if set + * to FALSE the local socket name will be returned. + * @return string The name of the socket. + * @throws StreamException + * + */ +function stream_socket_get_name($socket, bool $remote): string +{ + error_clear_last(); + $result = \stream_socket_get_name($socket, $remote); + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + +/** * stream_socket_pair creates a pair of connected, * indistinguishable socket streams. This function is commonly used in IPC * (Inter-Process Communication). @@ -451,13 +518,100 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable /** + * stream_socket_recvfrom accepts + * data from a remote socket up to length bytes. + * + * @param resource $socket The remote socket. + * @param int $length The number of bytes to receive from the socket. + * @param int $flags The value of flags can be any combination + * of the following: + * + * Possible values for flags + * + * + * + * STREAM_OOB + * + * Process OOB (out-of-band) data. + * + * + * + * STREAM_PEEK + * + * Retrieve data from the socket, but do not consume the buffer. + * Subsequent calls to fread or + * stream_socket_recvfrom will see + * the same data. + * + * + * + * + * + * @param string|null $address If address is provided it will be populated with + * the address of the remote socket. + * @return string Returns the read data, as a string. + * @throws StreamException + * + */ +function stream_socket_recvfrom($socket, int $length, int $flags = 0, ?string &$address = null): string +{ + error_clear_last(); + $result = \stream_socket_recvfrom($socket, $length, $flags, $address); + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + +/** + * Sends the specified data through the + * socket. + * + * @param resource $socket The socket to send data to. + * @param string $data The data to be sent. + * @param int $flags The value of flags can be any combination + * of the following: + * + * possible values for flags + * + * + * + * STREAM_OOB + * + * Process OOB (out-of-band) data. + * + * + * + * + * + * @param string $address The address specified when the socket stream was created will be used + * unless an alternate address is specified in address. + * + * If specified, it must be in dotted quad (or [ipv6]) format. + * @return int Returns a result code, as an integer. + * @throws StreamException + * + */ +function stream_socket_sendto($socket, string $data, int $flags = 0, string $address = ""): int +{ + error_clear_last(); + $result = \stream_socket_sendto($socket, $data, $flags, $address); + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + +/** * Creates a stream or datagram socket on the specified - * local_socket. + * address. * * This function only creates a socket, to begin accepting connections * use stream_socket_accept. * - * @param string $local_socket The type of socket created is determined by the transport specified + * @param string $address The type of socket created is determined by the transport specified * using standard URL formatting: transport://target. * * For Internet Domain sockets (AF_INET) such as TCP and UDP, the @@ -471,17 +625,17 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable * A list of available transports can be retrieved using * stream_get_transports. See * for a list of bulitin transports. - * @param int $errno If the optional errno and errstr + * @param int|null $error_code If the optional error_code and error_message * arguments are present they will be set to indicate the actual system * level error that occurred in the system-level socket(), * bind(), and listen() calls. If - * the value returned in errno is + * the value returned in error_code is * 0 and the function returned FALSE, it is an * indication that the error occurred before the bind() * call. This is most likely due to a problem initializing the socket. - * Note that the errno and - * errstr arguments will always be passed by reference. - * @param string $errstr See errno description. + * Note that the error_code and + * error_message arguments will always be passed by reference. + * @param string|null $error_message See error_code description. * @param int $flags A bitmask field which may be set to any combination of socket creation * flags. * @@ -492,13 +646,13 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable * @throws StreamException * */ -function stream_socket_server(string $local_socket, int &$errno = null, string &$errstr = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context = null) +function stream_socket_server(string $address, ?int &$error_code = null, ?string &$error_message = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context = null) { error_clear_last(); if ($context !== null) { - $result = \stream_socket_server($local_socket, $errno, $errstr, $flags, $context); + $result = \stream_socket_server($address, $error_code, $error_message, $flags, $context); } else { - $result = \stream_socket_server($local_socket, $errno, $errstr, $flags); + $result = \stream_socket_server($address, $error_code, $error_message, $flags); } if ($result === false) { throw StreamException::createFromPhpError(); @@ -512,7 +666,7 @@ function stream_socket_server(string $local_socket, int &$errno = null, string & * * @param resource $stream An open stream (opened with stream_socket_client, * for example) - * @param int $how One of the following constants: STREAM_SHUT_RD + * @param int $mode One of the following constants: STREAM_SHUT_RD * (disable further receptions), STREAM_SHUT_WR * (disable further transmissions) or * STREAM_SHUT_RDWR (disable further receptions and @@ -520,10 +674,10 @@ function stream_socket_server(string $local_socket, int &$errno = null, string & * @throws StreamException * */ -function stream_socket_shutdown($stream, int $how): void +function stream_socket_shutdown($stream, int $mode): void { error_clear_last(); - $result = \stream_socket_shutdown($stream, $how); + $result = \stream_socket_shutdown($stream, $mode); if ($result === false) { throw StreamException::createFromPhpError(); } @@ -554,17 +708,18 @@ function stream_supports_lock($stream): void * fread etc.). * * @param string $protocol The wrapper name to be registered. - * @param string $classname The classname which implements the protocol. + * Valid protocol names must contain alphanumerics, dots (.), plusses (+), or hyphens (-) only. + * @param string $class The classname which implements the protocol. * @param int $flags Should be set to STREAM_IS_URL if * protocol is a URL protocol. Default is 0, local * stream. * @throws StreamException * */ -function stream_wrapper_register(string $protocol, string $classname, int $flags = 0): void +function stream_wrapper_register(string $protocol, string $class, int $flags = 0): void { error_clear_last(); - $result = \stream_wrapper_register($protocol, $classname, $flags); + $result = \stream_wrapper_register($protocol, $class, $flags); if ($result === false) { throw StreamException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/strings.php b/vendor/thecodingmachine/safe/generated/strings.php index 9bc728415..2aa72339c 100644 --- a/vendor/thecodingmachine/safe/generated/strings.php +++ b/vendor/thecodingmachine/safe/generated/strings.php @@ -7,39 +7,15 @@ use Safe\Exceptions\StringsException; /** * convert_uudecode decodes a uuencoded string. * - * @param string $data The uuencoded data. + * @param string $string The uuencoded data. * @return string Returns the decoded data as a string. * @throws StringsException * */ -function convert_uudecode(string $data): string +function convert_uudecode(string $string): string { error_clear_last(); - $result = \convert_uudecode($data); - if ($result === false) { - throw StringsException::createFromPhpError(); - } - return $result; -} - - -/** - * convert_uuencode encodes a string using the uuencode - * algorithm. - * - * Uuencode translates all strings (including binary data) into printable - * characters, making them safe for network transmissions. Uuencoded data is - * about 35% larger than the original. - * - * @param string $data The data to be encoded. - * @return string Returns the uuencoded data. - * @throws StringsException - * - */ -function convert_uuencode(string $data): string -{ - error_clear_last(); - $result = \convert_uuencode($data); + $result = \convert_uudecode($string); if ($result === false) { throw StringsException::createFromPhpError(); } @@ -50,15 +26,15 @@ function convert_uuencode(string $data): string /** * Decodes a hexadecimally encoded binary string. * - * @param string $data Hexadecimal representation of data. + * @param string $string Hexadecimal representation of data. * @return string Returns the binary representation of the given data. * @throws StringsException * */ -function hex2bin(string $data): string +function hex2bin(string $string): string { error_clear_last(); - $result = \hex2bin($data); + $result = \hex2bin($string); if ($result === false) { throw StringsException::createFromPhpError(); } @@ -74,48 +50,16 @@ function hex2bin(string $data): string * The hash is a 32-character hexadecimal number. * * @param string $filename The filename - * @param bool $raw_output When TRUE, returns the digest in raw binary format with a length of + * @param bool $binary When TRUE, returns the digest in raw binary format with a length of * 16. * @return string Returns a string on success, FALSE otherwise. * @throws StringsException * */ -function md5_file(string $filename, bool $raw_output = false): string -{ - error_clear_last(); - $result = \md5_file($filename, $raw_output); - if ($result === false) { - throw StringsException::createFromPhpError(); - } - return $result; -} - - -/** - * Calculates the metaphone key of str. - * - * Similar to soundex metaphone creates the same key for - * similar sounding words. It's more accurate than - * soundex as it knows the basic rules of English - * pronunciation. The metaphone generated keys are of variable length. - * - * Metaphone was developed by Lawrence Philips - * <lphilips at verity dot com>. It is described in ["Practical - * Algorithms for Programmers", Binstock & Rex, Addison Wesley, - * 1995]. - * - * @param string $str The input string. - * @param int $phonemes This parameter restricts the returned metaphone key to - * phonemes characters in length. - * The default value of 0 means no restriction. - * @return string Returns the metaphone key as a string. - * @throws StringsException - * - */ -function metaphone(string $str, int $phonemes = 0): string +function md5_file(string $filename, bool $binary = false): string { error_clear_last(); - $result = \metaphone($str, $phonemes); + $result = \md5_file($filename, $binary); if ($result === false) { throw StringsException::createFromPhpError(); } @@ -127,718 +71,16 @@ function metaphone(string $str, int $phonemes = 0): string * * * @param string $filename The filename of the file to hash. - * @param bool $raw_output When TRUE, returns the digest in raw binary format with a length of + * @param bool $binary When TRUE, returns the digest in raw binary format with a length of * 20. * @return string Returns a string on success, FALSE otherwise. * @throws StringsException * */ -function sha1_file(string $filename, bool $raw_output = false): string -{ - error_clear_last(); - $result = \sha1_file($filename, $raw_output); - if ($result === false) { - throw StringsException::createFromPhpError(); - } - return $result; -} - - -/** - * Calculates the soundex key of str. - * - * Soundex keys have the property that words pronounced similarly - * produce the same soundex key, and can thus be used to simplify - * searches in databases where you know the pronunciation but not - * the spelling. This soundex function returns a string 4 characters - * long, starting with a letter. - * - * This particular soundex function is one described by Donald Knuth - * in "The Art Of Computer Programming, vol. 3: Sorting And - * Searching", Addison-Wesley (1973), pp. 391-392. - * - * @param string $str The input string. - * @return string Returns the soundex key as a string. - * @throws StringsException - * - */ -function soundex(string $str): string -{ - error_clear_last(); - $result = \soundex($str); - if ($result === false) { - throw StringsException::createFromPhpError(); - } - return $result; -} - - -/** - * Returns a string produced according to the formatting string - * format. - * - * @param string $format The format string is composed of zero or more directives: - * ordinary characters (excluding %) that are - * copied directly to the result and conversion - * specifications, each of which results in fetching its - * own parameter. - * - * A conversion specification follows this prototype: - * %[argnum$][flags][width][.precision]specifier. - * - * An integer followed by a dollar sign $, - * to specify which number argument to treat in the conversion. - * - * - * Flags - * - * - * - * Flag - * Description - * - * - * - * - * - - * - * Left-justify within the given field width; - * Right justification is the default - * - * - * - * + - * - * Prefix positive numbers with a plus sign - * +; Default only negative - * are prefixed with a negative sign. - * - * - * - * (space) - * - * Pads the result with spaces. - * This is the default. - * - * - * - * 0 - * - * Only left-pads numbers with zeros. - * With s specifiers this can - * also right-pad with zeros. - * - * - * - * '(char) - * - * Pads the result with the character (char). - * - * - * - * - * - * - * An integer that says how many characters (minimum) - * this conversion should result in. - * - * A period . followed by an integer - * who's meaning depends on the specifier: - * - * - * - * For e, E, - * f and F - * specifiers: this is the number of digits to be printed - * after the decimal point (by default, this is 6). - * - * - * - * - * For g and G - * specifiers: this is the maximum number of significant - * digits to be printed. - * - * - * - * - * For s specifier: it acts as a cutoff point, - * setting a maximum character limit to the string. - * - * - * - * - * - * If the period is specified without an explicit value for precision, - * 0 is assumed. - * - * - * - * - * Specifiers - * - * - * - * Specifier - * Description - * - * - * - * - * % - * - * A literal percent character. No argument is required. - * - * - * - * b - * - * The argument is treated as an integer and presented - * as a binary number. - * - * - * - * c - * - * The argument is treated as an integer and presented - * as the character with that ASCII. - * - * - * - * d - * - * The argument is treated as an integer and presented - * as a (signed) decimal number. - * - * - * - * e - * - * The argument is treated as scientific notation (e.g. 1.2e+2). - * The precision specifier stands for the number of digits after the - * decimal point since PHP 5.2.1. In earlier versions, it was taken as - * number of significant digits (one less). - * - * - * - * E - * - * Like the e specifier but uses - * uppercase letter (e.g. 1.2E+2). - * - * - * - * f - * - * The argument is treated as a float and presented - * as a floating-point number (locale aware). - * - * - * - * F - * - * The argument is treated as a float and presented - * as a floating-point number (non-locale aware). - * Available as of PHP 5.0.3. - * - * - * - * g - * - * - * General format. - * - * - * Let P equal the precision if nonzero, 6 if the precision is omitted, - * or 1 if the precision is zero. - * Then, if a conversion with style E would have an exponent of X: - * - * - * If P > X ≥ −4, the conversion is with style f and precision P − (X + 1). - * Otherwise, the conversion is with style e and precision P − 1. - * - * - * - * - * G - * - * Like the g specifier but uses - * E and f. - * - * - * - * o - * - * The argument is treated as an integer and presented - * as an octal number. - * - * - * - * s - * - * The argument is treated and presented as a string. - * - * - * - * u - * - * The argument is treated as an integer and presented - * as an unsigned decimal number. - * - * - * - * x - * - * The argument is treated as an integer and presented - * as a hexadecimal number (with lowercase letters). - * - * - * - * X - * - * The argument is treated as an integer and presented - * as a hexadecimal number (with uppercase letters). - * - * - * - * - * - * - * General format. - * - * Let P equal the precision if nonzero, 6 if the precision is omitted, - * or 1 if the precision is zero. - * Then, if a conversion with style E would have an exponent of X: - * - * If P > X ≥ −4, the conversion is with style f and precision P − (X + 1). - * Otherwise, the conversion is with style e and precision P − 1. - * - * The c type specifier ignores padding and width - * - * Attempting to use a combination of the string and width specifiers with character sets that require more than one byte per character may result in unexpected results - * - * Variables will be co-erced to a suitable type for the specifier: - * - * Type Handling - * - * - * - * Type - * Specifiers - * - * - * - * - * string - * s - * - * - * integer - * - * d, - * u, - * c, - * o, - * x, - * X, - * b - * - * - * - * double - * - * g, - * G, - * e, - * E, - * f, - * F - * - * - * - * - * - * @param mixed $params - * @return string Returns a string produced according to the formatting string - * format. - * @throws StringsException - * - */ -function sprintf(string $format, ...$params): string -{ - error_clear_last(); - if ($params !== []) { - $result = \sprintf($format, ...$params); - } else { - $result = \sprintf($format); - } - if ($result === false) { - throw StringsException::createFromPhpError(); - } - return $result; -} - - -/** - * Returns the portion of string specified by the - * start and length parameters. - * - * @param string $string The input string. - * @param int $start If start is non-negative, the returned string - * will start at the start'th position in - * string, counting from zero. For instance, - * in the string 'abcdef', the character at - * position 0 is 'a', the - * character at position 2 is - * 'c', and so forth. - * - * If start is negative, the returned string - * will start at the start'th character - * from the end of string. - * - * If string is less than - * start characters long, FALSE will be returned. - * - * - * Using a negative start - * - * - * ]]> - * - * - * @param int $length If length is given and is positive, the string - * returned will contain at most length characters - * beginning from start (depending on the length of - * string). - * - * If length is given and is negative, then that many - * characters will be omitted from the end of string - * (after the start position has been calculated when a - * start is negative). If - * start denotes the position of this truncation or - * beyond, FALSE will be returned. - * - * If length is given and is 0, - * FALSE or NULL, an empty string will be returned. - * - * If length is omitted, the substring starting from - * start until the end of the string will be - * returned. - * @return string Returns the extracted part of string;, or - * an empty string. - * @throws StringsException - * - */ -function substr(string $string, int $start, int $length = null): string -{ - error_clear_last(); - if ($length !== null) { - $result = \substr($string, $start, $length); - } else { - $result = \substr($string, $start); - } - if ($result === false) { - throw StringsException::createFromPhpError(); - } - return $result; -} - - -/** - * Operates as sprintf but accepts an array of - * arguments, rather than a variable number of arguments. - * - * @param string $format The format string is composed of zero or more directives: - * ordinary characters (excluding %) that are - * copied directly to the result and conversion - * specifications, each of which results in fetching its - * own parameter. - * - * A conversion specification follows this prototype: - * %[argnum$][flags][width][.precision]specifier. - * - * An integer followed by a dollar sign $, - * to specify which number argument to treat in the conversion. - * - * - * Flags - * - * - * - * Flag - * Description - * - * - * - * - * - - * - * Left-justify within the given field width; - * Right justification is the default - * - * - * - * + - * - * Prefix positive numbers with a plus sign - * +; Default only negative - * are prefixed with a negative sign. - * - * - * - * (space) - * - * Pads the result with spaces. - * This is the default. - * - * - * - * 0 - * - * Only left-pads numbers with zeros. - * With s specifiers this can - * also right-pad with zeros. - * - * - * - * '(char) - * - * Pads the result with the character (char). - * - * - * - * - * - * - * An integer that says how many characters (minimum) - * this conversion should result in. - * - * A period . followed by an integer - * who's meaning depends on the specifier: - * - * - * - * For e, E, - * f and F - * specifiers: this is the number of digits to be printed - * after the decimal point (by default, this is 6). - * - * - * - * - * For g and G - * specifiers: this is the maximum number of significant - * digits to be printed. - * - * - * - * - * For s specifier: it acts as a cutoff point, - * setting a maximum character limit to the string. - * - * - * - * - * - * If the period is specified without an explicit value for precision, - * 0 is assumed. - * - * - * - * - * Specifiers - * - * - * - * Specifier - * Description - * - * - * - * - * % - * - * A literal percent character. No argument is required. - * - * - * - * b - * - * The argument is treated as an integer and presented - * as a binary number. - * - * - * - * c - * - * The argument is treated as an integer and presented - * as the character with that ASCII. - * - * - * - * d - * - * The argument is treated as an integer and presented - * as a (signed) decimal number. - * - * - * - * e - * - * The argument is treated as scientific notation (e.g. 1.2e+2). - * The precision specifier stands for the number of digits after the - * decimal point since PHP 5.2.1. In earlier versions, it was taken as - * number of significant digits (one less). - * - * - * - * E - * - * Like the e specifier but uses - * uppercase letter (e.g. 1.2E+2). - * - * - * - * f - * - * The argument is treated as a float and presented - * as a floating-point number (locale aware). - * - * - * - * F - * - * The argument is treated as a float and presented - * as a floating-point number (non-locale aware). - * Available as of PHP 5.0.3. - * - * - * - * g - * - * - * General format. - * - * - * Let P equal the precision if nonzero, 6 if the precision is omitted, - * or 1 if the precision is zero. - * Then, if a conversion with style E would have an exponent of X: - * - * - * If P > X ≥ −4, the conversion is with style f and precision P − (X + 1). - * Otherwise, the conversion is with style e and precision P − 1. - * - * - * - * - * G - * - * Like the g specifier but uses - * E and f. - * - * - * - * o - * - * The argument is treated as an integer and presented - * as an octal number. - * - * - * - * s - * - * The argument is treated and presented as a string. - * - * - * - * u - * - * The argument is treated as an integer and presented - * as an unsigned decimal number. - * - * - * - * x - * - * The argument is treated as an integer and presented - * as a hexadecimal number (with lowercase letters). - * - * - * - * X - * - * The argument is treated as an integer and presented - * as a hexadecimal number (with uppercase letters). - * - * - * - * - * - * - * General format. - * - * Let P equal the precision if nonzero, 6 if the precision is omitted, - * or 1 if the precision is zero. - * Then, if a conversion with style E would have an exponent of X: - * - * If P > X ≥ −4, the conversion is with style f and precision P − (X + 1). - * Otherwise, the conversion is with style e and precision P − 1. - * - * The c type specifier ignores padding and width - * - * Attempting to use a combination of the string and width specifiers with character sets that require more than one byte per character may result in unexpected results - * - * Variables will be co-erced to a suitable type for the specifier: - * - * Type Handling - * - * - * - * Type - * Specifiers - * - * - * - * - * string - * s - * - * - * integer - * - * d, - * u, - * c, - * o, - * x, - * X, - * b - * - * - * - * double - * - * g, - * G, - * e, - * E, - * f, - * F - * - * - * - * - * - * @param array $args - * @return string Return array values as a formatted string according to - * format. - * @throws StringsException - * - */ -function vsprintf(string $format, array $args): string +function sha1_file(string $filename, bool $binary = false): string { error_clear_last(); - $result = \vsprintf($format, $args); + $result = \sha1_file($filename, $binary); if ($result === false) { throw StringsException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/swoole.php b/vendor/thecodingmachine/safe/generated/swoole.php index 334d96bd9..a9c3ff3e6 100644 --- a/vendor/thecodingmachine/safe/generated/swoole.php +++ b/vendor/thecodingmachine/safe/generated/swoole.php @@ -7,6 +7,46 @@ 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(); + $result = \swoole_async_dns_lookup($hostname, $callback); + if ($result === 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(); + $result = \swoole_async_readfile($filename, $callback); + if ($result === 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. diff --git a/vendor/thecodingmachine/safe/generated/uodbc.php b/vendor/thecodingmachine/safe/generated/uodbc.php index 89775c825..6ac914bdf 100644 --- a/vendor/thecodingmachine/safe/generated/uodbc.php +++ b/vendor/thecodingmachine/safe/generated/uodbc.php @@ -10,24 +10,24 @@ use Safe\Exceptions\UodbcException; * By default, auto-commit is on for a connection. Disabling * auto-commit is equivalent with starting a transaction. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. - * @param bool $OnOff If OnOff is TRUE, auto-commit is enabled, if + * @param bool $enable If enable is TRUE, auto-commit is enabled, if * it is FALSE auto-commit is disabled. - * @return mixed Without the OnOff parameter, this function returns - * auto-commit status for connection_id. Non-zero is + * @return mixed Without the enable parameter, this function returns + * auto-commit status for odbc. Non-zero is * returned if auto-commit is on, 0 if it is off, or FALSE if an error * occurs. * - * If OnOff is set, this function returns TRUE on + * If enable is set, this function returns TRUE on * success. * @throws UodbcException * */ -function odbc_autocommit($connection_id, bool $OnOff = false) +function odbc_autocommit($odbc, bool $enable = false) { error_clear_last(); - $result = \odbc_autocommit($connection_id, $OnOff); + $result = \odbc_autocommit($odbc, $enable); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -103,9 +103,9 @@ function odbc_autocommit($connection_id, bool $OnOff = false) * If odbc_result is used, passthru means that the data are * sent directly to the client (i.e. printed). * - * @param int $result_id The result identifier. + * @param int $statement The result identifier. * - * If result_id is 0, the + * If statement is 0, the * settings apply as default for new results. * @param int $mode Possible values for mode are: * @@ -134,10 +134,10 @@ function odbc_autocommit($connection_id, bool $OnOff = false) * @throws UodbcException * */ -function odbc_binmode(int $result_id, int $mode): void +function odbc_binmode(int $statement, int $mode): void { error_clear_last(); - $result = \odbc_binmode($result_id, $mode); + $result = \odbc_binmode($statement, $mode); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -147,18 +147,18 @@ function odbc_binmode(int $result_id, int $mode): void /** * Lists columns and associated privileges for the given table. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). * @param string $schema The schema ('owner' in ODBC 2 parlance). * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. - * @param string $table_name The table name. + * @param string $table The table name. * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. - * @param string $column_name The column name. + * @param string $column The column name. * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. @@ -181,10 +181,10 @@ function odbc_binmode(int $result_id, int $mode): void * @throws UodbcException * */ -function odbc_columnprivileges($connection_id, string $catalog, string $schema, string $table_name, string $column_name) +function odbc_columnprivileges($odbc, string $catalog, string $schema, string $table, string $column) { error_clear_last(); - $result = \odbc_columnprivileges($connection_id, $catalog, $schema, $table_name, $column_name); + $result = \odbc_columnprivileges($odbc, $catalog, $schema, $table, $column); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -195,18 +195,18 @@ function odbc_columnprivileges($connection_id, string $catalog, string $schema, /** * Lists all columns in the requested range. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). * @param string $schema The schema ('owner' in ODBC 2 parlance). * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. - * @param string $table_name The table name. + * @param string $table The table name. * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. - * @param string $column_name The column name. + * @param string $column The column name. * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. @@ -237,19 +237,19 @@ function odbc_columnprivileges($connection_id, string $catalog, string $schema, * @throws UodbcException * */ -function odbc_columns($connection_id, string $catalog = null, string $schema = null, string $table_name = null, string $column_name = null) +function odbc_columns($odbc, string $catalog = null, string $schema = null, string $table = null, string $column = null) { error_clear_last(); - if ($column_name !== null) { - $result = \odbc_columns($connection_id, $catalog, $schema, $table_name, $column_name); - } elseif ($table_name !== null) { - $result = \odbc_columns($connection_id, $catalog, $schema, $table_name); + if ($column !== null) { + $result = \odbc_columns($odbc, $catalog, $schema, $table, $column); + } elseif ($table !== null) { + $result = \odbc_columns($odbc, $catalog, $schema, $table); } elseif ($schema !== null) { - $result = \odbc_columns($connection_id, $catalog, $schema); + $result = \odbc_columns($odbc, $catalog, $schema); } elseif ($catalog !== null) { - $result = \odbc_columns($connection_id, $catalog); + $result = \odbc_columns($odbc, $catalog); } else { - $result = \odbc_columns($connection_id); + $result = \odbc_columns($odbc); } if ($result === false) { throw UodbcException::createFromPhpError(); @@ -261,15 +261,15 @@ function odbc_columns($connection_id, string $catalog = null, string $schema = n /** * Commits all pending transactions on the connection. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @throws UodbcException * */ -function odbc_commit($connection_id): void +function odbc_commit($odbc): void { error_clear_last(); - $result = \odbc_commit($connection_id); + $result = \odbc_commit($odbc); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -277,10 +277,72 @@ function odbc_commit($connection_id): void /** + * + * + * @param string $dsn The database source name for the connection. Alternatively, a + * DSN-less connection string can be used. + * @param string $user The username. + * @param string $password The password. + * @param int $cursor_option This sets the type of cursor to be used + * for this connection. This parameter is not normally needed, but + * can be useful for working around problems with some ODBC drivers. + * + * + * + * + * SQL_CUR_USE_IF_NEEDED + * + * + * + * + * SQL_CUR_USE_ODBC + * + * + * + * + * SQL_CUR_USE_DRIVER + * + * + * + * @return resource Returns an ODBC connection. + * @throws UodbcException + * + */ +function odbc_connect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) +{ + error_clear_last(); + $result = \odbc_connect($dsn, $user, $password, $cursor_option); + if ($result === false) { + throw UodbcException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets the cursorname for the given result_id. + * + * @param resource $statement The result identifier. + * @return string Returns the cursor name, as a string. + * @throws UodbcException + * + */ +function odbc_cursor($statement): string +{ + error_clear_last(); + $result = \odbc_cursor($statement); + if ($result === false) { + throw UodbcException::createFromPhpError(); + } + return $result; +} + + +/** * This function will return the list of available DSN (after calling it * several times). * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param int $fetch_type The fetch_type can be one of two constant types: * SQL_FETCH_FIRST, SQL_FETCH_NEXT. @@ -291,10 +353,10 @@ function odbc_commit($connection_id): void * @throws UodbcException * */ -function odbc_data_source($connection_id, int $fetch_type): array +function odbc_data_source($odbc, int $fetch_type): array { error_clear_last(); - $result = \odbc_data_source($connection_id, $fetch_type); + $result = \odbc_data_source($odbc, $fetch_type); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -305,23 +367,18 @@ function odbc_data_source($connection_id, int $fetch_type): array /** * Sends an SQL statement to the database server. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. - * @param string $query_string The SQL statement. - * @param int $flags This parameter is currently not used. + * @param string $query The SQL statement. * @return resource Returns an ODBC result identifier if the SQL command was executed * successfully. * @throws UodbcException * */ -function odbc_exec($connection_id, string $query_string, int $flags = null) +function odbc_exec($odbc, string $query) { error_clear_last(); - if ($flags !== null) { - $result = \odbc_exec($connection_id, $query_string, $flags); - } else { - $result = \odbc_exec($connection_id, $query_string); - } + $result = \odbc_exec($odbc, $query); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -332,27 +389,23 @@ function odbc_exec($connection_id, string $query_string, int $flags = null) /** * Executes a statement prepared with odbc_prepare. * - * @param resource $result_id The result id resource, from odbc_prepare. - * @param array $parameters_array Parameters in parameter_array will be + * @param resource $statement The result id resource, from odbc_prepare. + * @param array $params Parameters in params will be * substituted for placeholders in the prepared statement in order. * Elements of this array will be converted to strings by calling this * function. * - * Any parameters in parameter_array which + * Any parameters in params which * start and end with single quotes will be taken as the name of a * file to read and send to the database server as the data for the * appropriate placeholder. * @throws UodbcException * */ -function odbc_execute($result_id, array $parameters_array = null): void +function odbc_execute($statement, array $params = []): void { error_clear_last(); - if ($parameters_array !== null) { - $result = \odbc_execute($result_id, $parameters_array); - } else { - $result = \odbc_execute($result_id); - } + $result = \odbc_execute($statement, $params); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -362,25 +415,21 @@ function odbc_execute($result_id, array $parameters_array = null): void /** * Fetch one result row into array. * - * @param resource $result_id The result resource. - * @param array|null $result_array The result array + * @param resource $statement The result resource. + * @param array|null $array The result array * that can be of any type since it will be converted to type * array. The array will contain the column values starting at array * index 0. - * @param int $rownumber The row number. + * @param int $row The row number. * @return int Returns the number of columns in the result; * FALSE on error. * @throws UodbcException * */ -function odbc_fetch_into($result_id, ?array &$result_array, int $rownumber = null): int +function odbc_fetch_into($statement, ?array &$array, int $row = 0): int { error_clear_last(); - if ($rownumber !== null) { - $result = \odbc_fetch_into($result_id, $result_array, $rownumber); - } else { - $result = \odbc_fetch_into($result_id, $result_array); - } + $result = \odbc_fetch_into($statement, $array, $row); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -392,16 +441,16 @@ function odbc_fetch_into($result_id, ?array &$result_array, int $rownumber = nul * Gets the length of the field referenced by number in the given result * identifier. * - * @param resource $result_id The result identifier. - * @param int $field_number The field number. Field numbering starts at 1. + * @param resource $statement The result identifier. + * @param int $field The field number. Field numbering starts at 1. * @return int Returns the field length. * @throws UodbcException * */ -function odbc_field_len($result_id, int $field_number): int +function odbc_field_len($statement, int $field): int { error_clear_last(); - $result = \odbc_field_len($result_id, $field_number); + $result = \odbc_field_len($statement, $field); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -413,16 +462,16 @@ function odbc_field_len($result_id, int $field_number): int * Gets the name of the field occupying the given column number in the given * result identifier. * - * @param resource $result_id The result identifier. - * @param int $field_number The field number. Field numbering starts at 1. + * @param resource $statement The result identifier. + * @param int $field The field number. Field numbering starts at 1. * @return string Returns the field name as a string. * @throws UodbcException * */ -function odbc_field_name($result_id, int $field_number): string +function odbc_field_name($statement, int $field): string { error_clear_last(); - $result = \odbc_field_name($result_id, $field_number); + $result = \odbc_field_name($statement, $field); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -434,17 +483,17 @@ function odbc_field_name($result_id, int $field_number): string * Gets the number of the column slot that corresponds to the named field in * the given result identifier. * - * @param resource $result_id The result identifier. - * @param string $field_name The field name. + * @param resource $statement The result identifier. + * @param string $field The field name. * @return int Returns the field number as a integer. * Field numbering starts at 1. * @throws UodbcException * */ -function odbc_field_num($result_id, string $field_name): int +function odbc_field_num($statement, string $field): int { error_clear_last(); - $result = \odbc_field_num($result_id, $field_name); + $result = \odbc_field_num($statement, $field); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -456,16 +505,16 @@ function odbc_field_num($result_id, string $field_name): int * Gets the scale of the field referenced by number in the given result * identifier. * - * @param resource $result_id The result identifier. - * @param int $field_number The field number. Field numbering starts at 1. + * @param resource $statement The result identifier. + * @param int $field The field number. Field numbering starts at 1. * @return int Returns the field scale as a integer. * @throws UodbcException * */ -function odbc_field_scale($result_id, int $field_number): int +function odbc_field_scale($statement, int $field): int { error_clear_last(); - $result = \odbc_field_scale($result_id, $field_number); + $result = \odbc_field_scale($statement, $field); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -477,16 +526,16 @@ function odbc_field_scale($result_id, int $field_number): int * Gets the SQL type of the field referenced by number in the given result * identifier. * - * @param resource $result_id The result identifier. - * @param int $field_number The field number. Field numbering starts at 1. + * @param resource $statement The result identifier. + * @param int $field The field number. Field numbering starts at 1. * @return string Returns the field type as a string. * @throws UodbcException * */ -function odbc_field_type($result_id, int $field_number): string +function odbc_field_type($statement, int $field): string { error_clear_last(); - $result = \odbc_field_type($result_id, $field_number); + $result = \odbc_field_type($statement, $field); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -499,7 +548,7 @@ function odbc_field_type($result_id, int $field_number): string * foreign keys in other tables that refer to the primary key in the * specified table * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $pk_catalog The catalog ('qualifier' in ODBC 2 parlance) of the primary key table. * @param string $pk_schema The schema ('owner' in ODBC 2 parlance) of the primary key table. @@ -530,10 +579,10 @@ function odbc_field_type($result_id, int $field_number): string * @throws UodbcException * */ -function odbc_foreignkeys($connection_id, string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table) +function odbc_foreignkeys($odbc, string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table) { error_clear_last(); - $result = \odbc_foreignkeys($connection_id, $pk_catalog, $pk_schema, $pk_table, $fk_catalog, $fk_schema, $fk_table); + $result = \odbc_foreignkeys($odbc, $pk_catalog, $pk_schema, $pk_table, $fk_catalog, $fk_schema, $fk_table); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -544,7 +593,7 @@ function odbc_foreignkeys($connection_id, string $pk_catalog, string $pk_schema, /** * Retrieves information about data types supported by the data source. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param int $data_type The data type, which can be used to restrict the information to a * single data type. @@ -573,14 +622,10 @@ function odbc_foreignkeys($connection_id, string $pk_catalog, string $pk_schema, * @throws UodbcException * */ -function odbc_gettypeinfo($connection_id, int $data_type = null) +function odbc_gettypeinfo($odbc, int $data_type = 0) { error_clear_last(); - if ($data_type !== null) { - $result = \odbc_gettypeinfo($connection_id, $data_type); - } else { - $result = \odbc_gettypeinfo($connection_id); - } + $result = \odbc_gettypeinfo($odbc, $data_type); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -593,17 +638,17 @@ function odbc_gettypeinfo($connection_id, int $data_type = null) * The default length can be set using the * uodbc.defaultlrl php.ini directive. * - * @param resource $result_id The result identifier. + * @param resource $statement The result identifier. * @param int $length The number of bytes returned to PHP is controlled by the parameter * length. If it is set to 0, long column data is passed through to the * client (i.e. printed) when retrieved with odbc_result. * @throws UodbcException * */ -function odbc_longreadlen($result_id, int $length): void +function odbc_longreadlen($statement, int $length): void { error_clear_last(); - $result = \odbc_longreadlen($result_id, $length); + $result = \odbc_longreadlen($statement, $length); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -611,6 +656,38 @@ function odbc_longreadlen($result_id, int $length): void /** + * Opens a persistent database connection. + * + * This function is much like + * odbc_connect, except that the connection is + * not really closed when the script has finished. Future requests + * for a connection with the same dsn, + * user, password + * combination (via odbc_connect and + * odbc_pconnect) can reuse the persistent + * connection. + * + * @param string $dsn + * @param string $user + * @param string $password + * @param int $cursor_option + * @return resource Returns an ODBC connection. + * error. + * @throws UodbcException + * + */ +function odbc_pconnect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) +{ + error_clear_last(); + $result = \odbc_pconnect($dsn, $user, $password, $cursor_option); + if ($result === false) { + throw UodbcException::createFromPhpError(); + } + return $result; +} + + +/** * Prepares a statement for execution. The result identifier can be used * later to execute the statement with odbc_execute. * @@ -619,18 +696,18 @@ function odbc_longreadlen($result_id, int $length): void * defined by the ODBC specification. However, the Unified ODBC driver * currently only supports parameters of type IN to stored procedures. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. - * @param string $query_string The query string statement being prepared. + * @param string $query The query string statement being prepared. * @return resource Returns an ODBC result identifier if the SQL command was prepared * successfully. * @throws UodbcException * */ -function odbc_prepare($connection_id, string $query_string) +function odbc_prepare($odbc, string $query) { error_clear_last(); - $result = \odbc_prepare($connection_id, $query_string); + $result = \odbc_prepare($odbc, $query); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -642,7 +719,7 @@ function odbc_prepare($connection_id, string $query_string) * Returns a result identifier that can be used to fetch the column names * that comprise the primary key for a table. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). * @param string $schema The schema ('owner' in ODBC 2 parlance). @@ -662,10 +739,130 @@ function odbc_prepare($connection_id, string $query_string) * @throws UodbcException * */ -function odbc_primarykeys($connection_id, string $catalog, string $schema, string $table) +function odbc_primarykeys($odbc, string $catalog, string $schema, string $table) +{ + error_clear_last(); + $result = \odbc_primarykeys($odbc, $catalog, $schema, $table); + if ($result === false) { + throw UodbcException::createFromPhpError(); + } + return $result; +} + + +/** + * Retrieve information about parameters to procedures. + * + * @param $odbc The ODBC connection identifier, + * see odbc_connect for details. + * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). + * @param string $schema The schema ('owner' in ODBC 2 parlance). + * This parameter accepts the following search patterns: + * % to match zero or more characters, + * and _ to match a single character. + * @param string $procedure The proc. + * This parameter accepts the following search patterns: + * % to match zero or more characters, + * and _ to match a single character. + * @param string $column The column. + * This parameter accepts the following search patterns: + * % to match zero or more characters, + * and _ to match a single character. + * @return resource Returns the list of input and output parameters, as well as the + * columns that make up the result set for the specified procedures. + * Returns an ODBC result identifier. + * + * The result set has the following columns: + * + * PROCEDURE_CAT + * PROCEDURE_SCHEM + * PROCEDURE_NAME + * COLUMN_NAME + * COLUMN_TYPE + * DATA_TYPE + * TYPE_NAME + * COLUMN_SIZE + * BUFFER_LENGTH + * DECIMAL_DIGITS + * NUM_PREC_RADIX + * NULLABLE + * REMARKS + * COLUMN_DEF + * SQL_DATA_TYPE + * SQL_DATETIME_SUB + * CHAR_OCTET_LENGTH + * ORDINAL_POSITION + * IS_NULLABLE + * + * Drivers can report additional columns. + * @throws UodbcException + * + */ +function odbc_procedurecolumns($odbc, string $catalog = null, string $schema = null, string $procedure = null, string $column = null) { error_clear_last(); - $result = \odbc_primarykeys($connection_id, $catalog, $schema, $table); + if ($column !== null) { + $result = \odbc_procedurecolumns($odbc, $catalog, $schema, $procedure, $column); + } elseif ($procedure !== null) { + $result = \odbc_procedurecolumns($odbc, $catalog, $schema, $procedure); + } elseif ($schema !== null) { + $result = \odbc_procedurecolumns($odbc, $catalog, $schema); + } elseif ($catalog !== null) { + $result = \odbc_procedurecolumns($odbc, $catalog); + } else { + $result = \odbc_procedurecolumns($odbc); + } + if ($result === false) { + throw UodbcException::createFromPhpError(); + } + return $result; +} + + +/** + * Lists all procedures in the requested range. + * + * @param $odbc The ODBC connection identifier, + * see odbc_connect for details. + * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). + * @param string $schema The schema ('owner' in ODBC 2 parlance). + * This parameter accepts the following search patterns: + * % to match zero or more characters, + * and _ to match a single character. + * @param string $procedure The name. + * This parameter accepts the following search patterns: + * % to match zero or more characters, + * and _ to match a single character. + * @return resource Returns an ODBC + * result identifier containing the information. + * + * The result set has the following columns: + * + * PROCEDURE_CAT + * PROCEDURE_SCHEM + * PROCEDURE_NAME + * NUM_INPUT_PARAMS + * NUM_OUTPUT_PARAMS + * NUM_RESULT_SETS + * REMARKS + * PROCEDURE_TYPE + * + * Drivers can report additional columns. + * @throws UodbcException + * + */ +function odbc_procedures($odbc, string $catalog = null, string $schema = null, string $procedure = null) +{ + error_clear_last(); + if ($procedure !== null) { + $result = \odbc_procedures($odbc, $catalog, $schema, $procedure); + } elseif ($schema !== null) { + $result = \odbc_procedures($odbc, $catalog, $schema); + } elseif ($catalog !== null) { + $result = \odbc_procedures($odbc, $catalog); + } else { + $result = \odbc_procedures($odbc); + } if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -681,20 +878,16 @@ function odbc_primarykeys($connection_id, string $catalog, string $schema, strin * This function is not supposed to be used in production environments; it is * merely meant for development purposes, to get a result set quickly rendered. * - * @param resource $result_id The result identifier. + * @param resource $statement The result identifier. * @param string $format Additional overall table formatting. * @return int Returns the number of rows in the result. * @throws UodbcException * */ -function odbc_result_all($result_id, string $format = null): int +function odbc_result_all($statement, string $format = ""): int { error_clear_last(); - if ($format !== null) { - $result = \odbc_result_all($result_id, $format); - } else { - $result = \odbc_result_all($result_id); - } + $result = \odbc_result_all($statement, $format); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -705,7 +898,7 @@ function odbc_result_all($result_id, string $format = null): int /** * Get result data * - * @param resource $result_id The ODBC resource. + * @param resource $statement The ODBC resource. * @param mixed $field The field name being retrieved. It can either be an integer containing * the column number of the field you want; or it can be a string * containing the name of the field. @@ -714,10 +907,10 @@ function odbc_result_all($result_id, string $format = null): int * @throws UodbcException * */ -function odbc_result($result_id, $field) +function odbc_result($statement, $field) { error_clear_last(); - $result = \odbc_result($result_id, $field); + $result = \odbc_result($statement, $field); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -728,15 +921,15 @@ function odbc_result($result_id, $field) /** * Rolls back all pending statements on the connection. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @throws UodbcException * */ -function odbc_rollback($connection_id): void +function odbc_rollback($odbc): void { error_clear_last(); - $result = \odbc_rollback($connection_id); + $result = \odbc_rollback($odbc); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -762,21 +955,21 @@ function odbc_rollback($connection_id): void * to use a commercial product, that's all that really * matters. * - * @param resource $id Is a connection id or result id on which to change the settings. + * @param resource $odbc Is a connection id or result id on which to change the settings. * For SQLSetConnectOption(), this is a connection id. * For SQLSetStmtOption(), this is a result id. - * @param int $function Is the ODBC function to use. The value should be + * @param int $which Is the ODBC function to use. The value should be * 1 for SQLSetConnectOption() and * 2 for SQLSetStmtOption(). * @param int $option The option to set. - * @param int $param The value for the given option. + * @param int $value The value for the given option. * @throws UodbcException * */ -function odbc_setoption($id, int $function, int $option, int $param): void +function odbc_setoption($odbc, int $which, int $option, int $value): void { error_clear_last(); - $result = \odbc_setoption($id, $function, $option, $param); + $result = \odbc_setoption($odbc, $which, $option, $value); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -788,7 +981,7 @@ function odbc_setoption($id, int $function, int $option, int $param): void * row in the table, or columns that are automatically updated when any * value in the row is updated by a transaction. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param int $type * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). @@ -816,10 +1009,10 @@ function odbc_setoption($id, int $function, int $option, int $param): void * @throws UodbcException * */ -function odbc_specialcolumns($connection_id, int $type, string $catalog, string $schema, string $table, int $scope, int $nullable) +function odbc_specialcolumns($odbc, int $type, string $catalog, string $schema, string $table, int $scope, int $nullable) { error_clear_last(); - $result = \odbc_specialcolumns($connection_id, $type, $catalog, $schema, $table, $scope, $nullable); + $result = \odbc_specialcolumns($odbc, $type, $catalog, $schema, $table, $scope, $nullable); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -830,11 +1023,11 @@ function odbc_specialcolumns($connection_id, int $type, string $catalog, string /** * Get statistics about a table and its indexes. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). * @param string $schema The schema ('owner' in ODBC 2 parlance). - * @param string $table_name The table name. + * @param string $table The table name. * @param int $unique The type of the index. * One of SQL_INDEX_UNIQUE or SQL_INDEX_ALL. * @param int $accuracy One of SQL_ENSURE or SQL_QUICK. @@ -862,10 +1055,10 @@ function odbc_specialcolumns($connection_id, int $type, string $catalog, string * @throws UodbcException * */ -function odbc_statistics($connection_id, string $catalog, string $schema, string $table_name, int $unique, int $accuracy) +function odbc_statistics($odbc, string $catalog, string $schema, string $table, int $unique, int $accuracy) { error_clear_last(); - $result = \odbc_statistics($connection_id, $catalog, $schema, $table_name, $unique, $accuracy); + $result = \odbc_statistics($odbc, $catalog, $schema, $table, $unique, $accuracy); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -877,14 +1070,14 @@ function odbc_statistics($connection_id, string $catalog, string $schema, string * Lists tables in the requested range and the privileges associated * with each table. * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). * @param string $schema The schema ('owner' in ODBC 2 parlance). * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. - * @param string $name The name. + * @param string $table The name. * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. @@ -904,10 +1097,10 @@ function odbc_statistics($connection_id, string $catalog, string $schema, string * @throws UodbcException * */ -function odbc_tableprivileges($connection_id, string $catalog, string $schema, string $name) +function odbc_tableprivileges($odbc, string $catalog, string $schema, string $table) { error_clear_last(); - $result = \odbc_tableprivileges($connection_id, $catalog, $schema, $name); + $result = \odbc_tableprivileges($odbc, $catalog, $schema, $table); if ($result === false) { throw UodbcException::createFromPhpError(); } @@ -921,14 +1114,14 @@ function odbc_tableprivileges($connection_id, string $catalog, string $schema, s * To support enumeration of qualifiers, owners, and table types, * the following special semantics for the * catalog, schema, - * name, and + * table, and * table_type are available: * * * * If catalog is a single percent * character (%) and schema and - * name are empty strings, then the result + * table are empty strings, then the result * set contains a list of valid qualifiers for the data * source. (All columns except the TABLE_QUALIFIER column contain * NULLs.) @@ -938,7 +1131,7 @@ function odbc_tableprivileges($connection_id, string $catalog, string $schema, s * * If schema is a single percent character * (%) and catalog and - * name are empty strings, then the result + * table are empty strings, then the result * set contains a list of valid owners for the data source. (All * columns except the TABLE_OWNER column contain * NULLs.) @@ -948,7 +1141,7 @@ function odbc_tableprivileges($connection_id, string $catalog, string $schema, s * * If table_type is a single percent * character (%) and catalog, - * schema and name + * schema and table * are empty strings, then the result set contains a list of * valid table types for the data source. (All columns except the * TABLE_TYPE column contain NULLs.) @@ -956,14 +1149,14 @@ function odbc_tableprivileges($connection_id, string $catalog, string $schema, s * * * - * @param resource $connection_id The ODBC connection identifier, + * @param resource $odbc The ODBC connection identifier, * see odbc_connect for details. * @param string $catalog The catalog ('qualifier' in ODBC 2 parlance). * @param string $schema The schema ('owner' in ODBC 2 parlance). * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. - * @param string $name The name. + * @param string $table The name. * This parameter accepts the following search patterns: * % to match zero or more characters, * and _ to match a single character. @@ -988,19 +1181,19 @@ function odbc_tableprivileges($connection_id, string $catalog, string $schema, s * @throws UodbcException * */ -function odbc_tables($connection_id, string $catalog = null, string $schema = null, string $name = null, string $types = null) +function odbc_tables($odbc, string $catalog = null, string $schema = null, string $table = null, string $types = null) { error_clear_last(); if ($types !== null) { - $result = \odbc_tables($connection_id, $catalog, $schema, $name, $types); - } elseif ($name !== null) { - $result = \odbc_tables($connection_id, $catalog, $schema, $name); + $result = \odbc_tables($odbc, $catalog, $schema, $table, $types); + } elseif ($table !== null) { + $result = \odbc_tables($odbc, $catalog, $schema, $table); } elseif ($schema !== null) { - $result = \odbc_tables($connection_id, $catalog, $schema); + $result = \odbc_tables($odbc, $catalog, $schema); } elseif ($catalog !== null) { - $result = \odbc_tables($connection_id, $catalog); + $result = \odbc_tables($odbc, $catalog); } else { - $result = \odbc_tables($connection_id); + $result = \odbc_tables($odbc); } if ($result === false) { throw UodbcException::createFromPhpError(); diff --git a/vendor/thecodingmachine/safe/generated/url.php b/vendor/thecodingmachine/safe/generated/url.php index 56c08b551..5871e6dc6 100644 --- a/vendor/thecodingmachine/safe/generated/url.php +++ b/vendor/thecodingmachine/safe/generated/url.php @@ -5,9 +5,9 @@ namespace Safe; use Safe\Exceptions\UrlException; /** - * Decodes a base64 encoded data. + * Decodes a base64 encoded string. * - * @param string $data The encoded data. + * @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 @@ -17,10 +17,10 @@ use Safe\Exceptions\UrlException; * @throws UrlException * */ -function base64_decode(string $data, bool $strict = false): string +function base64_decode(string $string, bool $strict = false): string { error_clear_last(); - $result = \base64_decode($data, $strict); + $result = \base64_decode($string, $strict); if ($result === false) { throw UrlException::createFromPhpError(); } @@ -33,22 +33,23 @@ function base64_decode(string $data, bool $strict = false): string * by the server in response to a HTTP request. * * @param string $url The target URL. - * @param int $format If the optional format parameter is set to non-zero, + * @param bool $associative If the optional associative parameter is set to true, * get_headers parses the response and sets the * array's keys. * @param resource $context A valid context resource created with - * stream_context_create. + * 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, int $format = 0, $context = null): array +function get_headers(string $url, bool $associative = false, $context = null): array { error_clear_last(); if ($context !== null) { - $result = \get_headers($url, $format, $context); + $result = \get_headers($url, $associative, $context); } else { - $result = \get_headers($url, $format); + $result = \get_headers($url, $associative); } if ($result === false) { throw UrlException::createFromPhpError(); @@ -58,17 +59,63 @@ function get_headers(string $url, int $format = 0, $context = null): array /** + * Opens filename and parses it line by line for + * <meta> tags in the file. The parsing stops at + * </head>. + * + * @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(); + $result = \get_meta_tags($filename, $use_include_path); + if ($result === false) { + throw UrlException::createFromPhpError(); + } + return $result; +} + + +/** * 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 above listed parts. Partial + * 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. Invalid characters are replaced by - * _. + * @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, @@ -76,8 +123,8 @@ function get_headers(string $url, int $format = 0, $context = null): array * 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 integer). - * @return mixed On seriously malformed URLs, parse_url. + * value will be an int). + * @return array|int|string|null On seriously malformed URLs, parse_url. * * If the component parameter is omitted, an * associative array is returned. At least one element will be @@ -127,9 +174,22 @@ function get_headers(string $url, int $format = 0, $context = null): array * * If the component parameter is specified, * parse_url returns a string (or an - * integer, in the case of PHP_URL_PORT) + * 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 * */ diff --git a/vendor/thecodingmachine/safe/generated/xml.php b/vendor/thecodingmachine/safe/generated/xml.php index 4f9f6606c..6f2679dd6 100644 --- a/vendor/thecodingmachine/safe/generated/xml.php +++ b/vendor/thecodingmachine/safe/generated/xml.php @@ -5,72 +5,449 @@ namespace Safe; use Safe\Exceptions\XmlException; /** - * xml_parser_create_ns creates a new XML parser - * with XML namespace support and returns a resource handle referencing - * it to be used by the other XML functions. - * - * @param string $encoding The input encoding is automatically detected, so that the - * encoding parameter specifies only the output - * encoding. In PHP 5.0.0 and 5.0.1, the default output charset is - * ISO-8859-1, while in PHP 5.0.2 and upper is UTF-8. The supported - * encodings are ISO-8859-1, UTF-8 and - * US-ASCII. - * @param string $separator With a namespace aware parser tag parameters passed to the various - * handler functions will consist of namespace and tag name separated by - * the string specified in separator. - * @return resource Returns a resource handle for the new XML parser. + * Frees the given XML parser. + * + * @param resource $parser * @throws XmlException * */ -function xml_parser_create_ns(string $encoding = null, string $separator = ":") +function xml_parser_free($parser): void { error_clear_last(); - if ($separator !== ":") { - $result = \xml_parser_create_ns($encoding, $separator); - } elseif ($encoding !== null) { - $result = \xml_parser_create_ns($encoding); - } else { - $result = \xml_parser_create_ns(); + $result = \xml_parser_free($parser); + if ($result === false) { + throw XmlException::createFromPhpError(); } +} + + +/** + * Sets the character data handler function for the XML parser + * parser. + * + * @param resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_character_data_handler($parser, $handler); if ($result === false) { throw XmlException::createFromPhpError(); } - return $result; } /** - * xml_parser_create creates a new XML parser - * and returns a resource handle referencing it to be used by the - * other XML functions. - * - * @param string $encoding The optional encoding specifies the character - * encoding for the input/output in PHP 4. Starting from PHP 5, the input - * encoding is automatically detected, so that the - * encoding parameter specifies only the output - * encoding. In PHP 4, the default output encoding is the same as the - * input charset. If empty string is passed, the parser attempts to identify - * which encoding the document is encoded in by looking at the heading 3 or - * 4 bytes. In PHP 5.0.0 and 5.0.1, the default output charset is - * ISO-8859-1, while in PHP 5.0.2 and upper is UTF-8. The supported - * encodings are ISO-8859-1, UTF-8 and - * US-ASCII. - * @return resource Returns a resource handle for the new XML parser. + * Sets the default handler function for the XML parser + * parser. + * + * @param resource $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_parser_create(string $encoding = null) +function xml_set_default_handler($parser, callable $handler): void { error_clear_last(); - if ($encoding !== null) { - $result = \xml_parser_create($encoding); - } else { - $result = \xml_parser_create(); + $result = \xml_set_default_handler($parser, $handler); + if ($result === 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 resource $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($parser, callable $start_handler, callable $end_handler): void +{ + error_clear_last(); + $result = \xml_set_element_handler($parser, $start_handler, $end_handler); + if ($result === 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 resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_end_namespace_decl_handler($parser, $handler); + if ($result === false) { + throw XmlException::createFromPhpError(); + } +} + + +/** + * Sets the external entity reference handler function for the XML parser + * parser. + * + * @param resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_external_entity_ref_handler($parser, $handler); + if ($result === 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 resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_notation_decl_handler($parser, $handler); if ($result === false) { throw XmlException::createFromPhpError(); } - return $result; } @@ -85,7 +462,7 @@ function xml_parser_create(string $encoding = null) * @throws XmlException * */ -function xml_set_object($parser, object &$object): void +function xml_set_object($parser, object $object): void { error_clear_last(); $result = \xml_set_object($parser, $object); @@ -93,3 +470,247 @@ function xml_set_object($parser, object &$object): void throw XmlException::createFromPhpError(); } } + + +/** + * Sets the processing instruction (PI) handler function for the XML parser + * parser. + * + * A processing instruction has the following format: + * + * <?target + * data?> + * + * + * You can put PHP code into such a tag, but be aware of one limitation: in + * an XML PI, the PI end tag (?>) 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 resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_processing_instruction_handler($parser, $handler); + if ($result === 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 resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_start_namespace_decl_handler($parser, $handler); + if ($result === 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 resource $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($parser, callable $handler): void +{ + error_clear_last(); + $result = \xml_set_unparsed_entity_decl_handler($parser, $handler); + if ($result === false) { + throw XmlException::createFromPhpError(); + } +} diff --git a/vendor/thecodingmachine/safe/generated/yaml.php b/vendor/thecodingmachine/safe/generated/yaml.php index 38daaf759..fd297aad5 100644 --- a/vendor/thecodingmachine/safe/generated/yaml.php +++ b/vendor/thecodingmachine/safe/generated/yaml.php @@ -26,7 +26,11 @@ use Safe\Exceptions\YamlException; function yaml_parse_file(string $filename, int $pos = 0, ?int &$ndocs = null, array $callbacks = null) { error_clear_last(); - $result = \yaml_parse_file($filename, $pos, $ndocs, $callbacks); + if ($callbacks !== null) { + $result = \yaml_parse_file($filename, $pos, $ndocs, $callbacks); + } else { + $result = \yaml_parse_file($filename, $pos, $ndocs); + } if ($result === false) { throw YamlException::createFromPhpError(); } @@ -59,7 +63,11 @@ function yaml_parse_file(string $filename, int $pos = 0, ?int &$ndocs = null, ar function yaml_parse_url(string $url, int $pos = 0, ?int &$ndocs = null, array $callbacks = null) { error_clear_last(); - $result = \yaml_parse_url($url, $pos, $ndocs, $callbacks); + if ($callbacks !== null) { + $result = \yaml_parse_url($url, $pos, $ndocs, $callbacks); + } else { + $result = \yaml_parse_url($url, $pos, $ndocs); + } if ($result === false) { throw YamlException::createFromPhpError(); } @@ -89,7 +97,11 @@ function yaml_parse_url(string $url, int $pos = 0, ?int &$ndocs = null, array $c function yaml_parse(string $input, int $pos = 0, ?int &$ndocs = null, array $callbacks = null) { error_clear_last(); - $result = \yaml_parse($input, $pos, $ndocs, $callbacks); + if ($callbacks !== null) { + $result = \yaml_parse($input, $pos, $ndocs, $callbacks); + } else { + $result = \yaml_parse($input, $pos, $ndocs); + } if ($result === false) { throw YamlException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/zip.php b/vendor/thecodingmachine/safe/generated/zip.php index 8fd22bb9a..d4097eb16 100644 --- a/vendor/thecodingmachine/safe/generated/zip.php +++ b/vendor/thecodingmachine/safe/generated/zip.php @@ -22,9 +22,86 @@ function zip_entry_close($zip_entry): void /** + * 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(); + $result = \zip_entry_compressedsize($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \zip_entry_compressionmethod($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \zip_entry_filesize($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \zip_entry_name($zip_entry); + if ($result === false) { + throw ZipException::createFromPhpError(); + } + return $result; +} + + +/** * Opens a directory entry in a zip file for reading. * - * @param resource $zip A valid resource handle returned by zip_open. + * @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. @@ -35,14 +112,10 @@ function zip_entry_close($zip_entry): void * @throws ZipException * */ -function zip_entry_open($zip, $zip_entry, string $mode = null): void +function zip_entry_open($zip_dp, $zip_entry, string $mode = "rb"): void { error_clear_last(); - if ($mode !== null) { - $result = \zip_entry_open($zip, $zip_entry, $mode); - } else { - $result = \zip_entry_open($zip, $zip_entry); - } + $result = \zip_entry_open($zip_dp, $zip_entry, $mode); if ($result === false) { throw ZipException::createFromPhpError(); } @@ -53,17 +126,17 @@ function zip_entry_open($zip, $zip_entry, string $mode = null): void * Reads from an open directory entry. * * @param resource $zip_entry A directory entry returned by zip_read. - * @param int $length The number of bytes to return. + * @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 $length = 1024): string +function zip_entry_read($zip_entry, int $len = 1024): string { error_clear_last(); - $result = \zip_entry_read($zip_entry, $length); + $result = \zip_entry_read($zip_entry, $len); if ($result === false) { throw ZipException::createFromPhpError(); } diff --git a/vendor/thecodingmachine/safe/generated/zlib.php b/vendor/thecodingmachine/safe/generated/zlib.php index 4dc3ca94f..c365525e8 100644 --- a/vendor/thecodingmachine/safe/generated/zlib.php +++ b/vendor/thecodingmachine/safe/generated/zlib.php @@ -71,7 +71,11 @@ function deflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): * window * * - * The zlib window size (logarithmic) in range 8..15; defaults to 15. + * 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. * * * @@ -101,7 +105,11 @@ function deflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): * * The compression memory level in range 1..9; defaults to 8. * - * The zlib window size (logarithmic) in range 8..15; defaults to 15. + * 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, @@ -115,7 +123,7 @@ function deflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): * @throws ZlibException * */ -function deflate_init(int $encoding, array $options = null) +function deflate_init(int $encoding, array $options = []) { error_clear_last(); $result = \deflate_init($encoding, $options); @@ -129,15 +137,15 @@ function deflate_init(int $encoding, array $options = null) /** * Closes the given gz-file pointer. * - * @param resource $zp The gz-file pointer. It must be valid, and must point to a file + * @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($zp): void +function gzclose($stream): void { error_clear_last(); - $result = \gzclose($zp); + $result = \gzclose($stream); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -178,19 +186,15 @@ function gzcompress(string $data, int $level = -1, int $encoding = ZLIB_ENCODING * data. * * @param string $data The data to decode, encoded by gzencode. - * @param int $length The maximum length of data to decode. - * @return string The decoded string. + * @param int $max_length The maximum length of data to decode. + * @return string The decoded string, or. * @throws ZlibException * */ -function gzdecode(string $data, int $length = null): string +function gzdecode(string $data, int $max_length = 0): string { error_clear_last(); - if ($length !== null) { - $result = \gzdecode($data, $length); - } else { - $result = \gzdecode($data); - } + $result = \gzdecode($data, $max_length); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -239,24 +243,42 @@ function gzdeflate(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_ * @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_mode The encoding mode. Can be FORCE_GZIP (the default) + * @param int $encoding The encoding mode. Can be FORCE_GZIP (the default) * or FORCE_DEFLATE. * - * Prior to PHP 5.4.0, using FORCE_DEFLATE results in - * a standard zlib deflated string (inclusive zlib headers) after a gzip - * file header but without the trailing crc32 checksum. - * - * In PHP 5.4.0 and later, FORCE_DEFLATE generates + * 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_mode = FORCE_GZIP): string +function gzencode(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_GZIP): string { error_clear_last(); - $result = \gzencode($data, $level, $encoding_mode); + $result = \gzencode($data, $level, $encoding); + if ($result === false) { + throw ZlibException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 array 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(); + $result = \gzfile($filename, $use_include_path); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -269,20 +291,20 @@ function gzencode(string $data, int $level = -1, int $encoding_mode = FORCE_GZIP * file pointer. Reading ends when length - 1 bytes have been read, on a * newline, or on EOF (whichever comes first). * - * @param resource $zp The gz-file pointer. It must be valid, and must point to a file + * @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 length of data to get. * @return string The uncompressed string. * @throws ZlibException * */ -function gzgets($zp, int $length = null): string +function gzgets($stream, int $length = null): string { error_clear_last(); if ($length !== null) { - $result = \gzgets($zp, $length); + $result = \gzgets($stream, $length); } else { - $result = \gzgets($zp); + $result = \gzgets($stream); } if ($result === false) { throw ZlibException::createFromPhpError(); @@ -324,19 +346,56 @@ function gzgetss($zp, int $length, string $allowable_tags = null): string * This function inflates a deflated string. * * @param string $data The data compressed by gzdeflate. - * @param int $length The maximum length of data to decode. + * @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 more than the optional parameter length. + * or, unless max_length is 0, more than the optional parameter max_length. * @throws ZlibException * */ -function gzinflate(string $data, int $length = 0): string +function gzinflate(string $data, int $max_length = 0): string { error_clear_last(); - $result = \gzinflate($data, $length); + $result = \gzinflate($data, $max_length); + if ($result === false) { + throw ZlibException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \gzopen($filename, $mode, $use_include_path); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -348,17 +407,41 @@ function gzinflate(string $data, int $length = 0): string * Reads to EOF on the given gz-file pointer from the current position and * writes the (uncompressed) results to standard output. * - * @param resource $zp The gz-file pointer. It must be valid, and must point to a file + * @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($zp): int +function gzpassthru($stream): int { error_clear_last(); - $result = \gzpassthru($zp); + $result = \gzpassthru($stream); + if ($result === false) { + throw ZlibException::createFromPhpError(); + } + return $result; +} + + +/** + * 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(); + $result = \gzread($stream, $length); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -370,15 +453,15 @@ function gzpassthru($zp): int * Sets the file position indicator of the given gz-file pointer to the * beginning of the file stream. * - * @param resource $zp The gz-file pointer. It must be valid, and must point to a file + * @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($zp): void +function gzrewind($stream): void { error_clear_last(); - $result = \gzrewind($zp); + $result = \gzrewind($stream); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -389,19 +472,50 @@ function gzrewind($zp): void * This function uncompress a compressed string. * * @param string $data The data compressed by gzcompress. - * @param int $length The maximum length of data to decode. + * @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 length. + * or more than the optional parameter max_length. + * @throws ZlibException + * + */ +function gzuncompress(string $data, int $max_length = 0): string +{ + error_clear_last(); + $result = \gzuncompress($data, $max_length); + if ($result === false) { + throw ZlibException::createFromPhpError(); + } + return $result; +} + + +/** + * 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 $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 gzuncompress(string $data, int $length = 0): string +function gzwrite($stream, string $data, int $length = null): int { error_clear_last(); - $result = \gzuncompress($data, $length); + if ($length !== null) { + $result = \gzwrite($stream, $data, $length); + } else { + $result = \gzwrite($stream, $data); + } if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -412,15 +526,15 @@ function gzuncompress(string $data, int $length = 0): string /** * * - * @param resource $resource + * @param resource $context * @return int Returns number of bytes read so far. * @throws ZlibException * */ -function inflate_get_read_len($resource): int +function inflate_get_read_len($context): int { error_clear_last(); - $result = \inflate_get_read_len($resource); + $result = \inflate_get_read_len($context); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -431,15 +545,15 @@ function inflate_get_read_len($resource): int /** * Usually returns either ZLIB_OK or ZLIB_STREAM_END. * - * @param resource $resource + * @param resource $context * @return int Returns decompression status. * @throws ZlibException * */ -function inflate_get_status($resource): int +function inflate_get_status($context): int { error_clear_last(); - $result = \inflate_get_status($resource); + $result = \inflate_get_status($context); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -454,7 +568,7 @@ function inflate_get_status($resource): int * available. * * @param resource $context A context created with inflate_init. - * @param string $encoded_data A chunk of compressed data. + * @param string $data A chunk of compressed data. * @param int $flush_mode One of ZLIB_BLOCK, * ZLIB_NO_FLUSH, * ZLIB_PARTIAL_FLUSH, @@ -468,10 +582,10 @@ function inflate_get_status($resource): int * @throws ZlibException * */ -function inflate_add($context, string $encoded_data, int $flush_mode = ZLIB_SYNC_FLUSH): string +function inflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string { error_clear_last(); - $result = \inflate_add($context, $encoded_data, $flush_mode); + $result = \inflate_add($context, $data, $flush_mode); if ($result === false) { throw ZlibException::createFromPhpError(); } @@ -550,7 +664,7 @@ function inflate_add($context, string $encoded_data, int $flush_mode = ZLIB_SYNC * @throws ZlibException * */ -function inflate_init(int $encoding, array $options = null) +function inflate_init(int $encoding, array $options = []) { error_clear_last(); $result = \inflate_init($encoding, $options); @@ -591,19 +705,15 @@ function readgzfile(string $filename, int $use_include_path = 0): int * Uncompress any raw/gzip/zlib encoded data. * * @param string $data - * @param int $max_decoded_len + * @param int $max_length * @return string Returns the uncompressed data. * @throws ZlibException * */ -function zlib_decode(string $data, int $max_decoded_len = null): string +function zlib_decode(string $data, int $max_length = 0): string { error_clear_last(); - if ($max_decoded_len !== null) { - $result = \zlib_decode($data, $max_decoded_len); - } else { - $result = \zlib_decode($data); - } + $result = \zlib_decode($data, $max_length); if ($result === false) { throw ZlibException::createFromPhpError(); } |