summaryrefslogtreecommitdiff
path: root/vendor/thecodingmachine/safe/deprecated
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-07-12 22:26:21 +0300
committerAndrew Dolgov <[email protected]>2022-07-12 22:26:21 +0300
commit80d3db1dcf8fe9ca66d4e3f2e2116d3bc39ae2b4 (patch)
tree04b33bfb9c9368c4a31e287153abec690b9014e0 /vendor/thecodingmachine/safe/deprecated
parent4b6161892000cb2b8392dce92a9cf2cabdf2d20e (diff)
upgrade idiorm to php8.1-patched version (aaronpk/idiorm)
Diffstat (limited to 'vendor/thecodingmachine/safe/deprecated')
-rw-r--r--vendor/thecodingmachine/safe/deprecated/Exceptions/MysqliException.php11
-rw-r--r--vendor/thecodingmachine/safe/deprecated/Exceptions/PasswordException.php15
-rw-r--r--vendor/thecodingmachine/safe/deprecated/array.php228
-rw-r--r--vendor/thecodingmachine/safe/deprecated/datetime.php36
-rw-r--r--vendor/thecodingmachine/safe/deprecated/functionsList.php13
-rw-r--r--vendor/thecodingmachine/safe/deprecated/mysqli.php22
-rw-r--r--vendor/thecodingmachine/safe/deprecated/password.php127
-rw-r--r--vendor/thecodingmachine/safe/deprecated/strings.php677
8 files changed, 1129 insertions, 0 deletions
diff --git a/vendor/thecodingmachine/safe/deprecated/Exceptions/MysqliException.php b/vendor/thecodingmachine/safe/deprecated/Exceptions/MysqliException.php
new file mode 100644
index 000000000..4cadf6ca1
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/Exceptions/MysqliException.php
@@ -0,0 +1,11 @@
+<?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/deprecated/Exceptions/PasswordException.php b/vendor/thecodingmachine/safe/deprecated/Exceptions/PasswordException.php
new file mode 100644
index 000000000..9c183b8e4
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/Exceptions/PasswordException.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace Safe\Exceptions;
+
+/**
+ * @deprecated This exception is deprecated
+ */
+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/deprecated/array.php b/vendor/thecodingmachine/safe/deprecated/array.php
new file mode 100644
index 000000000..f0b3a20b7
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/array.php
@@ -0,0 +1,228 @@
+<?php
+
+namespace Safe;
+
+use Safe\Exceptions\ArrayException;
+
+/**
+ * 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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+function array_flip(array $array): array
+{
+ error_clear_last();
+ $result = \array_flip($array);
+ if ($result === null) {
+ throw ArrayException::createFromPhpError();
+ }
+ return $result;
+}
+
+/**
+ * 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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ */
+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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+function ksort(array &$array, int $sort_flags = SORT_REGULAR): void
+{
+ error_clear_last();
+ $result = \ksort($array, $sort_flags);
+ if ($result === false) {
+ 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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ */
+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 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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+function usort(array &$array, callable $value_compare_func): void
+{
+ error_clear_last();
+ $result = \usort($array, $value_compare_func);
+ if ($result === false) {
+ throw ArrayException::createFromPhpError();
+ }
+}
+
+/**
+ * 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
+ * @deprecated
+ *
+ */
+function array_combine(array $keys, array $values): array
+{
+ error_clear_last();
+ $result = \array_combine($keys, $values);
+ if ($result === false) {
+ throw ArrayException::createFromPhpError();
+ }
+ return $result;
+}
diff --git a/vendor/thecodingmachine/safe/deprecated/datetime.php b/vendor/thecodingmachine/safe/deprecated/datetime.php
new file mode 100644
index 000000000..1bcb32275
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/datetime.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Safe;
+
+use Safe\Exceptions\DatetimeException;
+
+/**
+ * Identical to the date function except that
+ * the time returned is Greenwich Mean Time (GMT).
+ *
+ * @param string $format The format of the outputted date string. See the formatting
+ * options for the date function.
+ * @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
+ * 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.
+ * @throws DatetimeException
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+function gmdate(string $format, int $timestamp = null): string
+{
+ error_clear_last();
+ if ($timestamp !== null) {
+ $result = \gmdate($format, $timestamp);
+ } else {
+ $result = \gmdate($format);
+ }
+ if ($result === false) {
+ throw DatetimeException::createFromPhpError();
+ }
+ return $result;
+}
diff --git a/vendor/thecodingmachine/safe/deprecated/functionsList.php b/vendor/thecodingmachine/safe/deprecated/functionsList.php
index e430cd3b9..6b39199c8 100644
--- a/vendor/thecodingmachine/safe/deprecated/functionsList.php
+++ b/vendor/thecodingmachine/safe/deprecated/functionsList.php
@@ -11,6 +11,10 @@ return [
'apc_inc',
'apc_load_constants',
'apc_sma_info',
+ 'arsort',
+ 'array_combine',
+ 'array_flip',
+ 'asort',
'event_add',
'event_base_loopbreak',
'event_base_loopexit',
@@ -30,10 +34,13 @@ return [
'event_priority_set',
'event_set',
'event_timer_set',
+ 'gmdate',
'imagepsencodefont',
'imagepsextendfont',
'imagepsfreefont',
'imagepsslantfont',
+ 'krsort',
+ 'ksort',
'mssql_bind',
'mssql_close',
'mssql_connect',
@@ -48,9 +55,15 @@ return [
'mssql_pconnect',
'mssql_query',
'mssql_select_db',
+ 'mysqli_get_client_stats',
+ 'password_hash',
+ 'sort',
'stats_covariance',
'stats_standard_deviation',
'stats_stat_correlation',
'stats_stat_innerproduct',
'stats_variance',
+ 'substr',
+ 'usort',
+ 'vsprintf',
];
diff --git a/vendor/thecodingmachine/safe/deprecated/mysqli.php b/vendor/thecodingmachine/safe/deprecated/mysqli.php
new file mode 100644
index 000000000..13839c6c7
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/mysqli.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Safe;
+
+use Safe\Exceptions\MysqliException;
+
+/**
+ * Returns client per-process statistics.
+ *
+ * @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/deprecated/password.php b/vendor/thecodingmachine/safe/deprecated/password.php
new file mode 100644
index 000000000..87d85a7b7
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/password.php
@@ -0,0 +1,127 @@
+<?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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+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/deprecated/strings.php b/vendor/thecodingmachine/safe/deprecated/strings.php
new file mode 100644
index 000000000..de0c2e606
--- /dev/null
+++ b/vendor/thecodingmachine/safe/deprecated/strings.php
@@ -0,0 +1,677 @@
+<?php
+
+namespace Safe;
+
+use Safe\Exceptions\StringsException;
+
+/**
+ * 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 &gt; 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 &gt; 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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ *
+ */
+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 &gt; 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 &gt; 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
+ * @deprecated The Safe version of this function is no longer needed in PHP 8.0+
+ */
+function vsprintf(string $format, array $args): string
+{
+ error_clear_last();
+ $result = \vsprintf($format, $args);
+ if ($result === false) {
+ throw StringsException::createFromPhpError();
+ }
+ return $result;
+}