-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Show enum cases in errors #14496
Conversation
if (smart_str_append_zval(&msg, value, EG(exception_string_param_max_len)) == SUCCESS) { | ||
/* Nothing to do. */ | ||
} else { |
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.
Maybe?
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) { |
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.
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.
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.
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) { |
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.
Can this branch still be reached?
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.
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)); | ||
} | ||
|
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.
Line should be reverted
No description provided.