From: Nikita Popov Date: Tue, 15 Oct 2019 09:46:48 +0000 (+0200) Subject: Promote "Cannot use parent" to fatal error X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c24f8042d46f3dfbe8eb122a64792758fff5271;p=php Promote "Cannot use parent" to fatal error --- diff --git a/UPGRADING b/UPGRADING index 7783f92f9b..a0d31617c8 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 cbea0c2dcc..ebb2dd4c27 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 2261b3c016..6bbf4881a8 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 64b9bc7032..4ac3eaa670 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"); } }