Skip to content

ext/intl IntlChar::enumCharNames changes the signature to void. #10904

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

Closed
wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

No description provided.

@@ -61,6 +61,14 @@ typedef struct _intl_data {
RETURN_NULL(); \
}

/* Check status by error code, if error return directly */
#define INTL_CHECK_STATUS_RETURN(err, msg) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this is copy-pasted but these backslashes are aligned very bad. I think you should use spaces instead of tabs if you don't mind.

@@ -3411,7 +3411,7 @@ public static function chr(int|string $codepoint): ?string {}
public static function digit(int|string $codepoint, int $base = 10): int|false|null {}

/** @tentative-return-type */
public static function enumCharNames(int|string $start, int|string $end, callable $callback, int $type = IntlChar::UNICODE_CHAR_NAME): ?bool {} // TODO return values just don't make sense
public static function enumCharNames(int|string $start, int|string $end, callable $callback, int $type = IntlChar::UNICODE_CHAR_NAME): void {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the void return type suggests that there is no error condition, or the function emits exceptions in case of errors, however, this function has at least 4 error conditions and exceptions are not necessarily thrown. Previously, in case of an error, either null or false was returned. In case of success, it returned null (OMG). So I think the sensible solution would be to return false on failure, and true on success. What do you think about it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. At least this wouldn't break an existing if (IntlChar::enumCharNames(...) === false) {} pattern.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same opinion here.

@devnexen devnexen force-pushed the intl_enumcharnames_changes branch from 655631f to fa7ce56 Compare March 28, 2023 12:26
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@devnexen devnexen closed this in 2da2997 Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants