summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-02-05 11:01:07 +0300
committerDmitry Stogov <dmitry@zend.com>2015-02-05 11:01:07 +0300
commitf5a9cfc33ab86e343b5cbf0d0a39a62037c32975 (patch)
tree05433d4070b6396fdaa3d65117fa61c29d16d348 /Zend/zend_API.c
parent067902daee9b293eec5b319c466d3f12fa643a27 (diff)
parent601fcc31af502fcf7aa36b8de53dfd4004fda613 (diff)
downloadphp-git-f5a9cfc33ab86e343b5cbf0d0a39a62037c32975.tar.gz
Merge branch 'internal-function-return-types' of github.com:reeze/php-src into test
* 'internal-function-return-types' of github.com:reeze/php-src: Add load time return type checking to match user land logic Add test function arguments Implemented internal function return types
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 7abbf31cb2..69327778e3 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2002,6 +2002,13 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
internal_function->num_args--;
}
if (info->type_hint) {
+ if (info->class_name) {
+ 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");
+ }
+ }
+
internal_function->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE;
}
} else {
@@ -2206,6 +2213,18 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
zend_error(error_type, "Method %s::%s() cannot be static", scope->name->val, __debugInfo->common.function_name->val);
}
}
+
+ if (ctor && ctor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && ctor->common.fn_flags & ZEND_ACC_CTOR) {
+ zend_error(E_CORE_ERROR, "Constructor %s::%s() cannot declare a return type", scope->name->val, ctor->common.function_name->val);
+ }
+
+ if (dtor && dtor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) {
+ zend_error(E_CORE_ERROR, "Destructor %s::%s() cannot declare a return type", scope->name->val, dtor->common.function_name->val);
+ }
+
+ if (clone && clone->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) {
+ zend_error(E_CORE_ERROR, "%s::%s() cannot declare a return type", scope->name->val, clone->common.function_name->val);
+ }
efree((char*)lc_class_name);
}
return SUCCESS;