From fc301dfaff19808019fcf704ef82eba747568ab4 Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Thu, 12 Dec 2019 10:04:13 +0100 Subject: [PATCH 1/2] widen the type of in password_hash to string|int --- generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php b/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php index ca0f1019..272377eb 100644 --- a/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php +++ b/generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php @@ -12,4 +12,5 @@ 'gmp_random_seed' => ['void', 'seed'=>'GMP|string|int'], //gmp_random_seed doesn't return 'imageconvolution' => ['bool', 'src_im'=>'resource', 'matrix3x3'=>'array', 'div'=>'float', 'offset'=>'float'], //imageconvolution return a bool 'iptcembed' => ['string|bool', 'iptcdata'=>'string', 'jpeg_file_name'=>'string', 'spool='=>'int'], //iptcembed return either a string, true or false + 'password_hash' => ['string|false', 'password'=>'string', 'algo'=>'int|string|null', 'options='=>'array'], ]; From a148f63d367ce1257db778a26a607db1177869f1 Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Thu, 12 Dec 2019 17:24:53 +0100 Subject: [PATCH 2/2] regenerated --- generated/filesystem.php | 2 +- generated/functionsList.php | 3 +- generated/info.php | 72 ------------------------------------- generated/mbstring.php | 21 +++++++++++ generated/password.php | 4 +-- generated/strings.php | 31 +++++++++++++++- rector-migrate.yml | 3 +- 7 files changed, 58 insertions(+), 78 deletions(-) diff --git a/generated/filesystem.php b/generated/filesystem.php index 68d92514..3d85608f 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -953,7 +953,7 @@ function fwrite($handle, string $string, int $length = null): int * * * - * * - Matches zero of more characters. + * * - Matches zero or more characters. * * * diff --git a/generated/functionsList.php b/generated/functionsList.php index f653c2de..3d57e9f9 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -370,7 +370,6 @@ 'imap_undelete', 'imap_unsubscribe', 'imap_utf8_to_mutf7', - 'assert_options', 'cli_set_process_title', 'dl', 'getlastmod', @@ -486,6 +485,7 @@ 'mb_parse_str', 'mb_regex_encoding', 'mb_send_mail', + 'mb_split', 'define', 'highlight_file', 'highlight_string', @@ -1017,6 +1017,7 @@ 'md5_file', 'metaphone', 'sha1_file', + 'soundex', 'sprintf', 'substr', 'vsprintf', diff --git a/generated/info.php b/generated/info.php index 38d549ea..49e4d289 100644 --- a/generated/info.php +++ b/generated/info.php @@ -4,78 +4,6 @@ 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. - * @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 diff --git a/generated/mbstring.php b/generated/mbstring.php index d7410f71..2f0405e5 100644 --- a/generated/mbstring.php +++ b/generated/mbstring.php @@ -472,3 +472,24 @@ function mb_send_mail(string $to, string $subject, string $message, string $addi throw MbstringException::createFromPhpError(); } } + + +/** + * + * + * @param string $pattern The regular expression pattern. + * @param string $string The string being split. + * @param int $limit + * @return array The result as an array. + * @throws MbstringException + * + */ +function mb_split(string $pattern, string $string, int $limit = -1): array +{ + error_clear_last(); + $result = \mb_split($pattern, $string, $limit); + if ($result === false) { + throw MbstringException::createFromPhpError(); + } + return $result; +} diff --git a/generated/password.php b/generated/password.php index 5850b649..3808e02b 100644 --- a/generated/password.php +++ b/generated/password.php @@ -97,7 +97,7 @@ * algorithm, will result * in the password parameter being truncated to a * maximum length of 72 characters. - * @param int $algo A password algorithm constant denoting the algorithm to use when hashing the password. + * @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 @@ -111,7 +111,7 @@ * @throws PasswordException * */ -function password_hash(string $password, int $algo, array $options = null): string +function password_hash(string $password, $algo, array $options = null): string { error_clear_last(); if ($options !== null) { diff --git a/generated/strings.php b/generated/strings.php index 4e9f346a..f82766a0 100644 --- a/generated/strings.php +++ b/generated/strings.php @@ -144,6 +144,35 @@ function sha1_file(string $filename, bool $raw_output = false): string } +/** + * 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. @@ -451,7 +480,7 @@ function sprintf(string $format, ...$params): string * Returns the portion of string specified by the * start and length parameters. * - * @param string $string The input string. Must be one character or longer. + * @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, diff --git a/rector-migrate.yml b/rector-migrate.yml index 7661546e..df0d072d 100644 --- a/rector-migrate.yml +++ b/rector-migrate.yml @@ -372,7 +372,6 @@ services: imap_undelete: 'Safe\imap_undelete' imap_unsubscribe: 'Safe\imap_unsubscribe' imap_utf8_to_mutf7: 'Safe\imap_utf8_to_mutf7' - assert_options: 'Safe\assert_options' cli_set_process_title: 'Safe\cli_set_process_title' dl: 'Safe\dl' getlastmod: 'Safe\getlastmod' @@ -488,6 +487,7 @@ services: mb_parse_str: 'Safe\mb_parse_str' mb_regex_encoding: 'Safe\mb_regex_encoding' mb_send_mail: 'Safe\mb_send_mail' + mb_split: 'Safe\mb_split' define: 'Safe\define' highlight_file: 'Safe\highlight_file' highlight_string: 'Safe\highlight_string' @@ -1019,6 +1019,7 @@ services: md5_file: 'Safe\md5_file' metaphone: 'Safe\metaphone' sha1_file: 'Safe\sha1_file' + soundex: 'Safe\soundex' sprintf: 'Safe\sprintf' substr: 'Safe\substr' vsprintf: 'Safe\vsprintf'