internal_function->num_args--;
}
if (info->type_hint) {
- if (info->type_hint == IS_OBJECT) {
- ZEND_ASSERT(info->class_name);
+ 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;
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;