@@ -34,12 +34,6 @@ static void add_property_compatibility_obligation(
34
34
zend_class_entry * ce , const zend_property_info * child_prop ,
35
35
const zend_property_info * parent_prop );
36
36
37
- static void overridden_ptr_dtor (zval * zv ) /* {{{ */
38
- {
39
- efree_size (Z_PTR_P (zv ), sizeof (zend_function ));
40
- }
41
- /* }}} */
42
-
43
37
static void zend_type_copy_ctor (zend_type * type , zend_bool persistent ) {
44
38
if (ZEND_TYPE_HAS_LIST (* type )) {
45
39
zend_type_list * old_list = ZEND_TYPE_LIST (* type );
@@ -1571,7 +1565,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
1571
1565
}
1572
1566
/* }}} */
1573
1567
1574
- static void zend_add_trait_method (zend_class_entry * ce , const char * name , zend_string * key , zend_function * fn , HashTable * * overridden ) /* {{{ */
1568
+ static void zend_add_trait_method (zend_class_entry * ce , const char * name , zend_string * key , zend_function * fn ) /* {{{ */
1575
1569
{
1576
1570
zend_function * existing_fn = NULL ;
1577
1571
zend_function * new_fn ;
@@ -1585,31 +1579,14 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
1585
1579
return ;
1586
1580
}
1587
1581
1582
+ /* Abstract method signatures from the trait must be satisfied. */
1583
+ if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1584
+ perform_delayable_implementation_check (ce , existing_fn , fn );
1585
+ return ;
1586
+ }
1587
+
1588
1588
if (existing_fn -> common .scope == ce ) {
1589
1589
/* members from the current class override trait methods */
1590
- /* use temporary *overridden HashTable to detect hidden conflict */
1591
- if (* overridden ) {
1592
- if ((existing_fn = zend_hash_find_ptr (* overridden , key )) != NULL ) {
1593
- if (existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1594
- /* Make sure the trait method is compatible with previosly declared abstract method */
1595
- perform_delayable_implementation_check (ce , fn , existing_fn );
1596
- }
1597
- if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1598
- /* Make sure the abstract declaration is compatible with previous declaration */
1599
- perform_delayable_implementation_check (ce , existing_fn , fn );
1600
- return ;
1601
- }
1602
- }
1603
- } else {
1604
- ALLOC_HASHTABLE (* overridden );
1605
- zend_hash_init_ex (* overridden , 8 , NULL , overridden_ptr_dtor , 0 , 0 );
1606
- }
1607
- zend_hash_update_mem (* overridden , key , fn , sizeof (zend_function ));
1608
- return ;
1609
- } else if ((fn -> common .fn_flags & ZEND_ACC_ABSTRACT )
1610
- && !(existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT )) {
1611
- /* Make sure the abstract declaration is compatible with previous declaration */
1612
- perform_delayable_implementation_check (ce , existing_fn , fn );
1613
1590
return ;
1614
1591
} else if (UNEXPECTED ((existing_fn -> common .scope -> ce_flags & ZEND_ACC_TRAIT )
1615
1592
&& !(existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT ))) {
@@ -1663,7 +1640,7 @@ static void zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce) /*
1663
1640
}
1664
1641
/* }}} */
1665
1642
1666
- static void zend_traits_copy_functions (zend_string * fnname , zend_function * fn , zend_class_entry * ce , HashTable * * overridden , HashTable * exclude_table , zend_class_entry * * aliases ) /* {{{ */
1643
+ static void zend_traits_copy_functions (zend_string * fnname , zend_function * fn , zend_class_entry * ce , HashTable * exclude_table , zend_class_entry * * aliases ) /* {{{ */
1667
1644
{
1668
1645
zend_trait_alias * alias , * * alias_ptr ;
1669
1646
zend_string * lcname ;
@@ -1689,7 +1666,7 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
1689
1666
}
1690
1667
1691
1668
lcname = zend_string_tolower (alias -> alias );
1692
- zend_add_trait_method (ce , ZSTR_VAL (alias -> alias ), lcname , & fn_copy , overridden );
1669
+ zend_add_trait_method (ce , ZSTR_VAL (alias -> alias ), lcname , & fn_copy );
1693
1670
zend_string_release_ex (lcname , 0 );
1694
1671
1695
1672
/* Record the trait from which this alias was resolved. */
@@ -1741,7 +1718,7 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
1741
1718
}
1742
1719
}
1743
1720
1744
- zend_add_trait_method (ce , ZSTR_VAL (fn -> common .function_name ), fnname , & fn_copy , overridden );
1721
+ zend_add_trait_method (ce , ZSTR_VAL (fn -> common .function_name ), fnname , & fn_copy );
1745
1722
}
1746
1723
}
1747
1724
/* }}} */
@@ -1879,7 +1856,6 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce, zend_class_e
1879
1856
static void zend_do_traits_method_binding (zend_class_entry * ce , zend_class_entry * * traits , HashTable * * exclude_tables , zend_class_entry * * aliases ) /* {{{ */
1880
1857
{
1881
1858
uint32_t i ;
1882
- HashTable * overridden = NULL ;
1883
1859
zend_string * key ;
1884
1860
zend_function * fn ;
1885
1861
@@ -1888,7 +1864,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
1888
1864
if (traits [i ]) {
1889
1865
/* copies functions, applies defined aliasing, and excludes unused trait methods */
1890
1866
ZEND_HASH_FOREACH_STR_KEY_PTR (& traits [i ]-> function_table , key , fn ) {
1891
- zend_traits_copy_functions (key , fn , ce , & overridden , exclude_tables [i ], aliases );
1867
+ zend_traits_copy_functions (key , fn , ce , exclude_tables [i ], aliases );
1892
1868
} ZEND_HASH_FOREACH_END ();
1893
1869
1894
1870
if (exclude_tables [i ]) {
@@ -1902,7 +1878,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
1902
1878
for (i = 0 ; i < ce -> num_traits ; i ++ ) {
1903
1879
if (traits [i ]) {
1904
1880
ZEND_HASH_FOREACH_STR_KEY_PTR (& traits [i ]-> function_table , key , fn ) {
1905
- zend_traits_copy_functions (key , fn , ce , & overridden , NULL , aliases );
1881
+ zend_traits_copy_functions (key , fn , ce , NULL , aliases );
1906
1882
} ZEND_HASH_FOREACH_END ();
1907
1883
}
1908
1884
}
@@ -1911,11 +1887,6 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
1911
1887
ZEND_HASH_FOREACH_PTR (& ce -> function_table , fn ) {
1912
1888
zend_fixup_trait_method (fn , ce );
1913
1889
} ZEND_HASH_FOREACH_END ();
1914
-
1915
- if (overridden ) {
1916
- zend_hash_destroy (overridden );
1917
- FREE_HASHTABLE (overridden );
1918
- }
1919
1890
}
1920
1891
/* }}} */
1921
1892
0 commit comments