summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-05-24 09:49:44 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-05-24 10:58:46 +0200
commitd7f3844c87c11073b717d0e888ab0d5c4074f216 (patch)
treeee4e377e21d54f9c1279fc4d15a7270b5f9f9916 /Zend/zend_compile.c
parentd9747c23a2e16825e141c5b2573afb805d42f97f (diff)
downloadphp-git-d7f3844c87c11073b717d0e888ab0d5c4074f216.tar.gz
Deprecate use of parent where no parent exists
This deprecation is part of the covariance RFC.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 43301b1147..b66ac4dcba 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1319,10 +1319,16 @@ static uint32_t zend_get_class_fetch_type_ast(zend_ast *name_ast) /* {{{ */
static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */
{
- if (fetch_type != ZEND_FETCH_CLASS_DEFAULT && !CG(active_class_entry) && zend_is_scope_known()) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot use \"%s\" when no class scope is active",
- fetch_type == ZEND_FETCH_CLASS_SELF ? "self" :
- fetch_type == ZEND_FETCH_CLASS_PARENT ? "parent" : "static");
+ if (fetch_type != ZEND_FETCH_CLASS_DEFAULT && zend_is_scope_known()) {
+ zend_class_entry *ce = CG(active_class_entry);
+ if (!ce) {
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot use \"%s\" when no class scope is active",
+ fetch_type == ZEND_FETCH_CLASS_SELF ? "self" :
+ fetch_type == ZEND_FETCH_CLASS_PARENT ? "parent" : "static");
+ } else if (fetch_type == ZEND_FETCH_CLASS_PARENT && !ce->parent_name) {
+ zend_error(E_DEPRECATED,
+ "Cannot use \"parent\" when current class scope has no parent");
+ }
}
}
/* }}} */