Merge branch 'PHP-7.4'

This commit is contained in:
Nikita Popov 2019-05-24 11:02:03 +02:00
commit 038db18496
3 changed files with 14 additions and 4 deletions

View File

@ -11,6 +11,8 @@ namespace Foo\Bar {
}
?>
--EXPECTF--
Deprecated: Cannot use "parent" when current class scope has no parent in %s on line %d
Fatal error: Uncaught Error: Cannot use "parent" when current class scope has no parent in %s:%d
Stack trace:
#0 {main}

View File

@ -13,4 +13,6 @@ class B extends A {
?>
--EXPECTF--
Deprecated: Cannot use "parent" when current class scope has no parent in %s on line %d
Fatal error: Could not check compatibility between B::method(A $x) and A::method(parent $x), because class parent is not available in %s on line %d

View File

@ -1296,10 +1296,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");
}
}
}
/* }}} */