-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Update mbstring parameter names #6207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,11 @@ function mb_substitute_character(string|int|null $substitute_character = null): | |
function mb_preferred_mime_name(string $encoding): string|false {} | ||
|
||
/** @param array $result */ | ||
function mb_parse_str(string $encoded_string, &$result): bool {} | ||
function mb_parse_str(string $string, &$result): bool {} | ||
|
||
function mb_output_handler(string $contents, int $status): string {} | ||
function mb_output_handler(string $string, int $status): string {} | ||
|
||
function mb_str_split(string $string, int $split_length = 1, ?string $encoding = null): array {} | ||
function mb_str_split(string $string, int $length = 1, ?string $encoding = null): array {} | ||
|
||
function mb_strlen(string $string, ?string $encoding = null): int {} | ||
|
||
|
@@ -33,13 +33,13 @@ function mb_stripos(string $haystack, string $needle, int $offset = 0, ?string $ | |
|
||
function mb_strripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false {} | ||
|
||
function mb_strstr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} | ||
function mb_strstr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false {} | ||
|
||
function mb_strrchr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} | ||
function mb_strrchr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false {} | ||
|
||
function mb_stristr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} | ||
function mb_stristr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false {} | ||
|
||
function mb_strrichr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} | ||
function mb_strrichr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false {} | ||
|
||
function mb_substr_count(string $haystack, string $needle, ?string $encoding = null): int {} | ||
|
||
|
@@ -51,76 +51,76 @@ function mb_strwidth(string $string, ?string $encoding = null): int {} | |
|
||
function mb_strimwidth(string $string, int $start, int $width, string $trim_marker = "", ?string $encoding = null): string {} | ||
|
||
function mb_convert_encoding(array|string $string, string $to, array|string|null $from = null): array|string|false {} | ||
function mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false {} | ||
|
||
function mb_convert_case(string $string, int $mode, ?string $encoding = null): string {} | ||
|
||
function mb_strtoupper(string $string, ?string $encoding = null): string {} | ||
|
||
function mb_strtolower(string $string, ?string $encoding = null): string {} | ||
|
||
function mb_detect_encoding(string $string, array|string|null $encoding_list = null, bool $strict = false): string|false {} | ||
function mb_detect_encoding(string $string, array|string|null $encodings = null, bool $strict = false): string|false {} | ||
|
||
function mb_list_encodings(): array {} | ||
|
||
function mb_encoding_aliases(string $encoding): array {} | ||
|
||
function mb_encode_mimeheader(string $string, ?string $charset = null, ?string $transfer = null, string $linefeed = "\r\n", int $indent = 0): string {} | ||
function mb_encode_mimeheader(string $string, ?string $charset = null, ?string $transfer_encoding = null, string $newline = "\r\n", int $indent = 0): string {} | ||
|
||
function mb_decode_mimeheader(string $string): string {} | ||
|
||
function mb_convert_kana(string $string, string $option = "KV", ?string $encoding = null): string {} | ||
function mb_convert_kana(string $string, string $mode = "KV", ?string $encoding = null): string {} | ||
|
||
function mb_convert_variables(string $to, array|string $from, mixed &$var, mixed &...$vars): string|false {} | ||
function mb_convert_variables(string $to_encoding, array|string $from_encoding, mixed &$var, mixed &...$vars): string|false {} | ||
|
||
function mb_encode_numericentity(string $string, array $convmap, ?string $encoding = null, bool $is_hex = false): string {} | ||
function mb_encode_numericentity(string $string, array $map, ?string $encoding = null, bool $hex = false): string {} | ||
|
||
function mb_decode_numericentity(string $string, array $convmap, ?string $encoding = null): string {} | ||
function mb_decode_numericentity(string $string, array $map, ?string $encoding = null): string {} | ||
|
||
function mb_send_mail(string $to, string $subject, string $message, array|string $additional_headers = [], ?string $additional_parameters = null): bool {} | ||
function mb_send_mail(string $to, string $subject, string $message, array|string $additional_headers = [], ?string $additional_params = null): bool {} | ||
|
||
function mb_get_info(string $type = "all"): array|string|int|false {} | ||
|
||
function mb_check_encoding(array|string|null $var = null, ?string $encoding = null): bool {} | ||
function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool {} | ||
|
||
function mb_scrub(string $string, ?string $encoding = null): string {} | ||
|
||
function mb_ord(string $string, ?string $encoding = null): int|false {} | ||
|
||
function mb_chr(int $cp, ?string $encoding = null): string|false {} | ||
function mb_chr(int $codepoint, ?string $encoding = null): string|false {} | ||
|
||
#ifdef HAVE_MBREGEX | ||
function mb_regex_encoding(?string $encoding = null): string|bool {} | ||
|
||
/** @param array $registers */ | ||
function mb_ereg(string $pattern, string $string, &$registers = null): int|false {} | ||
/** @param array $matches */ | ||
function mb_ereg(string $pattern, string $string, &$matches = null): int|false {} | ||
|
||
/** @param array $registers */ | ||
function mb_eregi(string $pattern, string $string, &$registers = null): int|false {} | ||
/** @param array $matches */ | ||
function mb_eregi(string $pattern, string $string, &$matches = null): int|false {} | ||
|
||
function mb_ereg_replace(string $pattern, string $replacement, string $string, ?string $option = null): string|false|null {} | ||
function mb_ereg_replace(string $pattern, string $replacement, string $string, ?string $options = null): string|false|null {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The similarity with the pcre extension was already mentioned. In that context I would probably rename However that would also mean the documentation text needs updating. Which... would not be a bad idea anyways. It speaks about "options" and then lists all possible "options" which also include "modes". So options can also contain a mode. Confusing. https://www.php.net/manual/en/function.mb-regex-set-options.php Maybe it should speak about "behavior modifiers" and "syntax modifiers" in stead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, modifiers is a possible alternative term. However, the referenced function is called mb_regex_set_options(), so that seems like the preferred term for mb_regex. (PCRE also never exposes "modifiers" in parameters, as they are part of the regex -- as such, there is no naming consistency to upkeep in that respect at least.) |
||
|
||
function mb_eregi_replace(string $pattern, string $replacement, string $string, ?string $option = null): string|false|null {} | ||
function mb_eregi_replace(string $pattern, string $replacement, string $string, ?string $options = null): string|false|null {} | ||
|
||
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, ?string $option = null): string|false|null {} | ||
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, ?string $options = null): string|false|null {} | ||
|
||
function mb_split(string $pattern, string $string, int $limit = -1): array|false {} | ||
|
||
function mb_ereg_match(string $pattern, string $string, ?string $option = null): bool {} | ||
function mb_ereg_match(string $pattern, string $string, ?string $options = null): bool {} | ||
|
||
function mb_ereg_search(?string $pattern = null, ?string $option = null): bool {} | ||
function mb_ereg_search(?string $pattern = null, ?string $options = null): bool {} | ||
|
||
function mb_ereg_search_pos(?string $pattern = null, ?string $option = null): array|false {} | ||
function mb_ereg_search_pos(?string $pattern = null, ?string $options = null): array|false {} | ||
|
||
function mb_ereg_search_regs(?string $pattern = null, ?string $option = null): array|false {} | ||
function mb_ereg_search_regs(?string $pattern = null, ?string $options = null): array|false {} | ||
|
||
function mb_ereg_search_init(string $string, ?string $pattern = null, ?string $option = null): bool {} | ||
function mb_ereg_search_init(string $string, ?string $pattern = null, ?string $options = null): bool {} | ||
|
||
function mb_ereg_search_getregs(): array|false {} | ||
|
||
function mb_ereg_search_getpos(): int {} | ||
|
||
function mb_ereg_search_setpos(int $position): bool {} | ||
function mb_ereg_search_setpos(int $offset): bool {} | ||
|
||
function mb_regex_set_options(?string $options = null): string {} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
$from
/$to
->$decode
/$encode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand the suggestion. Are you saying the parameter names should be
$encode
and$decode
or$encode_encoding
and$decode_encoding
? Both don't really make sense to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion was to name them
$encode
and$decode
. My idea was that$decode
says how to decode the string while$encode
says how to encode it again. It made me think of how it would be written in Python:my_string.decode('iso-8859-1').encode('utf8')
The names are short too. To me it does make sense, but that could just be me. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to leave these at just
$to
and$from
if the_encoding
suffix makes them too long.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. I like their current names ^^ But unfortunately I can only have a closer look a bit later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to mention a few other options:
UConverter::__construct()
uses$source_encoding
and$destination_encoding
($target_encoding
reads better for me though).