@@ -1143,6 +1143,10 @@ ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /*
1143
1143
return FAILURE ;
1144
1144
}
1145
1145
1146
+ if (ce -> ce_flags & ZEND_ACC_LINKED ) {
1147
+ return SUCCESS ;
1148
+ }
1149
+
1146
1150
ce = zend_do_link_class (ce , lc_parent_name , Z_STR_P (lcname ));
1147
1151
if (!ce ) {
1148
1152
/* Reload bucket pointer, the hash table may have been reallocated */
@@ -7517,31 +7521,36 @@ void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel) /* {{{
7517
7521
ce -> ce_flags |= ZEND_ACC_TOP_LEVEL ;
7518
7522
}
7519
7523
7520
- if (toplevel
7521
- /* We currently don't early-bind classes that implement interfaces or use traits */
7522
- && !ce -> num_interfaces && !ce -> num_traits
7524
+ /* We currently don't early-bind classes that implement interfaces or use traits */
7525
+ if (!ce -> num_interfaces && !ce -> num_traits
7523
7526
&& !(CG (compiler_options ) & ZEND_COMPILE_WITHOUT_EXECUTION )) {
7524
- if (extends_ast ) {
7525
- zend_class_entry * parent_ce = zend_lookup_class_ex (
7526
- ce -> parent_name , NULL , ZEND_FETCH_CLASS_NO_AUTOLOAD );
7527
-
7528
- if (parent_ce
7529
- && ((parent_ce -> type != ZEND_INTERNAL_CLASS ) || !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES ))
7530
- && ((parent_ce -> type != ZEND_USER_CLASS ) || !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_OTHER_FILES ) || (parent_ce -> info .user .filename == ce -> info .user .filename ))) {
7531
-
7532
- CG (zend_lineno ) = decl -> end_lineno ;
7533
- if (zend_try_early_bind (ce , parent_ce , lcname , NULL )) {
7527
+ if (toplevel ) {
7528
+ if (extends_ast ) {
7529
+ zend_class_entry * parent_ce = zend_lookup_class_ex (
7530
+ ce -> parent_name , NULL , ZEND_FETCH_CLASS_NO_AUTOLOAD );
7531
+
7532
+ if (parent_ce
7533
+ && ((parent_ce -> type != ZEND_INTERNAL_CLASS ) || !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES ))
7534
+ && ((parent_ce -> type != ZEND_USER_CLASS ) || !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_OTHER_FILES ) || (parent_ce -> info .user .filename == ce -> info .user .filename ))) {
7535
+
7536
+ CG (zend_lineno ) = decl -> end_lineno ;
7537
+ if (zend_try_early_bind (ce , parent_ce , lcname , NULL )) {
7538
+ CG (zend_lineno ) = ast -> lineno ;
7539
+ zend_string_release (lcname );
7540
+ return ;
7541
+ }
7534
7542
CG (zend_lineno ) = ast -> lineno ;
7535
- zend_string_release (lcname );
7536
- return ;
7537
7543
}
7538
- CG (zend_lineno ) = ast -> lineno ;
7544
+ } else if (EXPECTED (zend_hash_add_ptr (CG (class_table ), lcname , ce ) != NULL )) {
7545
+ zend_string_release (lcname );
7546
+ zend_build_properties_info_table (ce );
7547
+ ce -> ce_flags |= ZEND_ACC_LINKED ;
7548
+ return ;
7539
7549
}
7540
- } else if (EXPECTED ( zend_hash_add_ptr ( CG ( class_table ), lcname , ce ) != NULL ) ) {
7541
- zend_string_release ( lcname );
7550
+ } else if (! extends_ast ) {
7551
+ /* Link unbound simple class */
7542
7552
zend_build_properties_info_table (ce );
7543
7553
ce -> ce_flags |= ZEND_ACC_LINKED ;
7544
- return ;
7545
7554
}
7546
7555
}
7547
7556
0 commit comments