summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorReeze Xia <reeze@php.net>2015-02-07 14:19:56 +0800
committerReeze Xia <reeze@php.net>2015-02-07 14:19:56 +0800
commitd9c28c558172281f78b47846357e1f48154d6a32 (patch)
treeb0ff5eca2c99744e3815af2d070033d196f26d44 /Zend/zend_API.c
parente82e22e27bd81027ea3a92ab6a34f31727049b1e (diff)
downloadphp-git-d9c28c558172281f78b47846357e1f48154d6a32.tar.gz
Improve internal function return types checking for parent
Previously the checking was against 'self', 'parent' need to be checked as user land declearation as well. This also add two missing test cases.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 69327778e3..260b0628b3 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2003,9 +2003,17 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
}
if (info->type_hint) {
if (info->class_name) {
+ uint32_t fetch_type;
+ zend_string *class_name;
+ ALLOCA_FLAG(use_heap);
+
ZEND_ASSERT(info->type_hint == IS_OBJECT);
- if (!strcasecmp(info->class_name, "self") && !scope) {
- zend_error(E_CORE_ERROR, "Cannot declare a return type of self outside of a class scope");
+ STR_ALLOCA_INIT(class_name, info->class_name, strlen(info->class_name), use_heap);
+ fetch_type = zend_get_class_fetch_type(class_name);
+ STR_ALLOCA_FREE(class_name, use_heap);
+
+ if (fetch_type != ZEND_FETCH_CLASS_DEFAULT && !scope) {
+ zend_error(E_CORE_ERROR, "Cannot declare a return type of %s outside of a class scope", info->class_name);
}
}