summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UPGRADING5
-rw-r--r--Zend/tests/bug75573.phpt8
-rw-r--r--Zend/tests/class_name_as_scalar_error_002.phpt5
-rw-r--r--Zend/zend_compile.c14
4 files changed, 16 insertions, 16 deletions
diff --git a/UPGRADING b/UPGRADING
index df747d28ae..ce157fc702 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -20,6 +20,11 @@ PHP 7.4 UPGRADE NOTES
1. Backward Incompatible Changes
========================================
+- Core:
+ . Referencing parent:: inside a class that does not have a parent will now
+ generate a compile-time error. Previously the error was only emitted at
+ run-time.
+
- Curl:
. Attempting to serialize a CURLFile class will now generate an exception.
Previously the exception was only thrown on unserialization.
diff --git a/Zend/tests/bug75573.phpt b/Zend/tests/bug75573.phpt
index 476ff6e6cf..f5e87f8283 100644
--- a/Zend/tests/bug75573.phpt
+++ b/Zend/tests/bug75573.phpt
@@ -6,10 +6,6 @@ Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
class A
{
var $_stdObject;
- function initialize($properties = FALSE) {
- $this->_stdObject = $properties ? (object) $properties : new stdClass();
- parent::initialize();
- }
function &__get($property)
{
if (isset($this->_stdObject->{$property})) {
@@ -31,10 +27,6 @@ class A
class B extends A
{
- function initialize($properties = array())
- {
- parent::initialize($properties);
- }
function &__get($property)
{
if (isset($this->settings) && isset($this->settings[$property])) {
diff --git a/Zend/tests/class_name_as_scalar_error_002.phpt b/Zend/tests/class_name_as_scalar_error_002.phpt
index 3abba7f7fe..ebb2dd4c27 100644
--- a/Zend/tests/class_name_as_scalar_error_002.phpt
+++ b/Zend/tests/class_name_as_scalar_error_002.phpt
@@ -11,7 +11,4 @@ namespace Foo\Bar {
}
?>
--EXPECTF--
-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
+Fatal error: Cannot use "parent" when current class scope has no parent in %s on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 3dc19a30b1..08c9d97042 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1358,10 +1358,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_noreturn(E_COMPILE_ERROR,
+ "Cannot use \"parent\" when current class scope has no parent");
+ }
}
}
/* }}} */