summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-05-25 19:28:15 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-05-26 19:06:19 +0200
commitfbe30592d6bec94463c68b27eabffca3a50c474e (patch)
tree5f7e2ca5bb754504eb0e4f7a49609088832172aa /Zend/zend_API.c
parent38c85efe83004d98b7cce89689b40de32f8b8add (diff)
downloadphp-git-fbe30592d6bec94463c68b27eabffca3a50c474e.tar.gz
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
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c10
1 files changed, 9 insertions, 1 deletions
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));
}
/* }}} */