From fbe30592d6bec94463c68b27eabffca3a50c474e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 25 May 2020 19:28:15 +0200 Subject: Improve type error messages when an object is given From now on, we always display the given object's type instead of just reporting "object". Additionally, make the format of return type errors match the format of argument errors. Closes GH-5625 --- Zend/zend_API.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Zend/zend_API.c') diff --git a/Zend/zend_API.c b/Zend/zend_API.c index cb8446d2ea..ba5cb9c747 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -136,7 +136,15 @@ ZEND_API const char *zend_zval_type_name(const zval *arg) /* {{{ */ { ZVAL_DEREF(arg); - return Z_ISUNDEF_P(arg) ? "null" : zend_get_type_by_const(Z_TYPE_P(arg)); + if (Z_ISUNDEF_P(arg)) { + return "null"; + } + + if (Z_TYPE_P(arg) == IS_OBJECT) { + return ZSTR_VAL(Z_OBJCE_P(arg)->name); + } + + return zend_get_type_by_const(Z_TYPE_P(arg)); } /* }}} */ -- cgit v1.2.1