diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-04 12:18:33 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-04 12:24:02 +0100 |
commit | deb44d405eb27a6654ad9a57c1e5f641218b22a4 (patch) | |
tree | c27b474de234b8a3e990a7b29fd9e4000833ded0 /Zend | |
parent | a8c3e22d231a9993c253d446ce23425662ac1645 (diff) | |
download | php-git-deb44d405eb27a6654ad9a57c1e5f641218b22a4.tar.gz |
Revert "Detect invalid uses of parent:: during compilation"
This reverts commit a9e6667817c38f22f4645ec5b4e5c6b0e4b928fa.
Breakage found in the wild: Mockery uses a parent:: call in the
implementation regardless of whether the class has a parent or not:
https://github.com/mockery/mockery/blob/4324afeaf9d95b492507e6587abb3f024e2576de/library/Mockery/Mock.php#L600
This change is not worth the compat break in 7.4.
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_002.phpt | 5 | ||||
-rw-r--r-- | Zend/zend_compile.c | 14 |
2 files changed, 8 insertions, 11 deletions
diff --git a/Zend/tests/class_name_as_scalar_error_002.phpt b/Zend/tests/class_name_as_scalar_error_002.phpt index ebb2dd4c27..3abba7f7fe 100644 --- a/Zend/tests/class_name_as_scalar_error_002.phpt +++ b/Zend/tests/class_name_as_scalar_error_002.phpt @@ -11,4 +11,7 @@ namespace Foo\Bar { } ?> --EXPECTF-- -Fatal error: 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} + thrown in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 9bf70d89fe..bb27b6e63f 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1317,16 +1317,10 @@ 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 && 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_noreturn(E_COMPILE_ERROR, - "Cannot use \"parent\" when current class scope has no parent"); - } + 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"); } } /* }}} */ |