Skip to content

Improve type error messages when an object is given #5625

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 3 commits into from

Conversation

kocsismate
Copy link
Member

@kocsismate kocsismate commented May 25, 2020

From now on, we always display the given object's type instead of just reporting object. As suggested by Nikita in #5620 (comment)

Additionally, I made the format of return type errors match the format of argument errors. I can revert this change easily if it's not desirable.

@kocsismate kocsismate marked this pull request as draft May 25, 2020 17:34
@kocsismate kocsismate marked this pull request as ready for review May 25, 2020 18:32
Zend/zend_API.c Outdated
@@ -140,6 +140,22 @@ ZEND_API const char *zend_zval_type_name(const zval *arg) /* {{{ */
}
/* }}} */

ZEND_API const char *zend_zval_type_error_name(const zval *arg) /* {{{ */
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't exactly sure that I can use zend_zval_type_name() for this purpose (although it seems likely for me) so I introduced this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that phpdbg_info.c remained the only client of zend_zval_type_name() about which I'm not sure if I could use the new semantics.

Copy link
Member

@nikic nikic May 26, 2020

Choose a reason for hiding this comment

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

I'm okay with reusing zend_zval_type_name for this and switching that phpdbg use to zend_get_type_by_const.

@kocsismate kocsismate force-pushed the type-error-object branch 3 times, most recently from 597899b to 97ff6ca Compare May 26, 2020 09:45
Additionally, make the format of return type errors match the format of argument errors.
@kocsismate kocsismate force-pushed the type-error-object branch from 97ff6ca to 6425fd0 Compare May 26, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants