com php-src: Promote "Cannot use parent" to fatal error: UPGRADING Zend/tests/class_name_as_scalar_error_002.php t
Zend/tests/type_declarations/variance/parent_in_class _failure1.phpt Zend/zend_compile.c
| From: | Nikita Popov | Date: | Tue, 15 Oct 2019 09:46:48 +0000 |
| Subject: | com php-src: Promote "Cannot use parent" to fatal error: UPGRADING Zend/tests/class_name_as_scalar_error_002.php t Zend/tests/type_declarations/variance/parent_in_class _failure1.phpt Zend/zend_compile.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108918@lists.php.net to get a copy of this message | ||
Commit: 5c24f8042d46f3dfbe8eb122a64792758fff5271
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 15 Oct 2019 11:46:48 +0200
Parents: 0d55456d7349f308a018672301fedab563ca2ccc
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5c24f8042d46f3dfbe8eb122a64792758fff5271
Log:
Promote "Cannot use parent" to fatal error
Changed paths:
M UPGRADING
M Zend/tests/class_name_as_scalar_error_002.phpt
M Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt
M Zend/zend_compile.c
Diff:
diff --git a/UPGRADING b/UPGRADING
index 7783f92f9b9..a0d31617c88 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -45,6 +45,8 @@ PHP 8.0 UPGRADE NOTES
.. The default error_reporting level is now E_ALL. Previously it excluded
E_NOTICE and E_DEPRECATED.
. display_startup_errors is now enabled by default.
+ . Using "parent" inside a class that has no parent will now result in a
+ fatal compile-time error.
. The @ operator will no longer silence fatal errors (E_ERROR, E_CORE_ERROR,
E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR, E_PARSE). Error handlers
that expect error_reporting to be 0 when @ is used, should be adjusted to
diff --git a/Zend/tests/class_name_as_scalar_error_002.phpt
b/Zend/tests/class_name_as_scalar_error_002.phpt
index cbea0c2dcca..ebb2dd4c271 100644
--- a/Zend/tests/class_name_as_scalar_error_002.phpt
+++ b/Zend/tests/class_name_as_scalar_error_002.phpt
@@ -11,9 +11,4 @@ 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}
- 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/tests/type_declarations/variance/parent_in_class_failure1.phpt
b/Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt
index 2261b3c0167..6bbf4881a89 100644
--- a/Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt
+++ b/Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt
@@ -13,6 +13,4 @@ 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
+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 64b9bc70325..4ac3eaa6708 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1408,7 +1408,7 @@ static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */
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,
+ zend_error_noreturn(E_COMPILE_ERROR,
"Cannot use \"parent\" when current class scope has no parent");
}
}