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
20
20
1. Backward Incompatible Changes
21
21
========================================
22
22
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
+
23
28
- Curl:
24
29
. Attempting to serialize a CURLFile class will now generate an exception.
25
30
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)
6
6
class A
7
7
{
8
8
var $ _stdObject ;
9
- function initialize ($ properties = FALSE ) {
10
- $ this ->_stdObject = $ properties ? (object ) $ properties : new stdClass ();
11
- parent ::initialize ();
12
- }
13
9
function &__get ($ property )
14
10
{
15
11
if (isset ($ this ->_stdObject ->{$ property })) {
@@ -31,10 +27,6 @@ class A
31
27
32
28
class B extends A
33
29
{
34
- function initialize ($ properties = array ())
35
- {
36
- parent ::initialize ($ properties );
37
- }
38
30
function &__get ($ property )
39
31
{
40
32
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 {
11
11
}
12
12
?>
13
13
--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) /* {{{ */
1358
1358
1359
1359
static void zend_ensure_valid_class_fetch_type (uint32_t fetch_type ) /* {{{ */
1360
1360
{
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
+ }
1365
1371
}
1366
1372
}
1367
1373
/* }}} */
You can’t perform that action at this time.
0 commit comments