Skip to content

Show enum cases in errors #14496

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

iluuu1994
Copy link
Member

No description provided.

Comment on lines +876 to 878
if (smart_str_append_zval(&msg, value, EG(exception_string_param_max_len)) == SUCCESS) {
/* Nothing to do. */
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe?

Suggested change
if (smart_str_append_zval(&msg, value, EG(exception_string_param_max_len)) == SUCCESS) {
/* Nothing to do. */
} else {
if (smart_str_append_zval(&msg, value, EG(exception_string_param_max_len)) == FAILURE) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, that looks correct. We only want to emit "of type ..." if smart_str_append_zval() can't handle the value. Note that it intentionally does not handle some values like arrays, because they seem to be handled differently depending on the context. It would be nice if it could be unified in the future, but my intention is not to break BC here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, sorry. I misread your suggestion. :) Yeah, I'll change it!

if (Z_TYPE_P(value) <= IS_STRING) {
smart_str_append_scalar(str, value, SIZE_MAX);
if (smart_str_append_zval(str, value, SIZE_MAX) == SUCCESS) {
/* Nothing to do. */
} else if (Z_TYPE_P(value) == IS_ARRAY) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this branch still be reached?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, smart_str_append_zval() does not handle arrays atm, amongst other things.

} else {
smart_str_appendl(&msg, "of type ", sizeof("of type ")-1);
smart_str_appends(&msg, zend_zval_type_name(value));
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Line should be reverted

@iluuu1994 iluuu1994 closed this in 998bce1 Jun 10, 2024
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.

2 participants