File tree Expand file tree Collapse file tree 4 files changed +16
-16
lines changed
Expand file tree Collapse file tree 4 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ PHP 7.4 UPGRADE NOTES
20201. Backward Incompatible Changes
2121========================================
2222
23+ - Core:
24+ . Referencing parent:: inside a class that does not have a parent will now
25+ generate a compile-time error. Previously the error was only emitted at
26+ run-time.
27+
2328- Curl:
2429 . Attempting to serialize a CURLFile class will now generate an exception.
2530 Previously the exception was only thrown on unserialization.
Original file line number Diff line number Diff line change @@ -6,10 +6,6 @@ Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
66class A
77{
88 var $ _stdObject ;
9- function initialize ($ properties = FALSE ) {
10- $ this ->_stdObject = $ properties ? (object ) $ properties : new stdClass ();
11- parent ::initialize ();
12- }
139 function &__get ($ property )
1410 {
1511 if (isset ($ this ->_stdObject ->{$ property })) {
@@ -31,10 +27,6 @@ class A
3127
3228class B extends A
3329{
34- function initialize ($ properties = array ())
35- {
36- parent ::initialize ($ properties );
37- }
3830 function &__get ($ property )
3931 {
4032 if (isset ($ this ->settings ) && isset ($ this ->settings [$ property ])) {
Original file line number Diff line number Diff line change @@ -11,7 +11,4 @@ namespace Foo\Bar {
1111}
1212?>
1313--EXPECTF--
14- Fatal error: Uncaught Error: Cannot use "parent" when current class scope has no parent in %s:%d
15- Stack trace:
16- #0 {main}
17- thrown in %s on line %d
14+ Fatal error: Cannot use "parent" when current class scope has no parent in %s on line %d
Original file line number Diff line number Diff line change @@ -1358,10 +1358,16 @@ static uint32_t zend_get_class_fetch_type_ast(zend_ast *name_ast) /* {{{ */
13581358
13591359static void zend_ensure_valid_class_fetch_type (uint32_t fetch_type ) /* {{{ */
13601360{
1361- if (fetch_type != ZEND_FETCH_CLASS_DEFAULT && !CG (active_class_entry ) && zend_is_scope_known ()) {
1362- zend_error_noreturn (E_COMPILE_ERROR , "Cannot use \"%s\" when no class scope is active" ,
1363- fetch_type == ZEND_FETCH_CLASS_SELF ? "self" :
1364- fetch_type == ZEND_FETCH_CLASS_PARENT ? "parent" : "static" );
1361+ if (fetch_type != ZEND_FETCH_CLASS_DEFAULT && zend_is_scope_known ()) {
1362+ zend_class_entry * ce = CG (active_class_entry );
1363+ if (!ce ) {
1364+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot use \"%s\" when no class scope is active" ,
1365+ fetch_type == ZEND_FETCH_CLASS_SELF ? "self" :
1366+ fetch_type == ZEND_FETCH_CLASS_PARENT ? "parent" : "static" );
1367+ } else if (fetch_type == ZEND_FETCH_CLASS_PARENT && !ce -> parent_name ) {
1368+ zend_error_noreturn (E_COMPILE_ERROR ,
1369+ "Cannot use \"parent\" when current class scope has no parent" );
1370+ }
13651371 }
13661372}
13671373/* }}} */
You can’t perform that action at this time.
0 commit comments