@@ -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 );
@@ -1552,7 +1546,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
1552
1546
}
1553
1547
/* }}} */
1554
1548
1555
- static void zend_add_trait_method (zend_class_entry * ce , const char * name , zend_string * key , zend_function * fn , HashTable * * overridden ) /* {{{ */
1549
+ static void zend_add_trait_method (zend_class_entry * ce , const char * name , zend_string * key , zend_function * fn ) /* {{{ */
1556
1550
{
1557
1551
zend_function * existing_fn = NULL ;
1558
1552
zend_function * new_fn ;
@@ -1566,31 +1560,14 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
1566
1560
return ;
1567
1561
}
1568
1562
1563
+ /* Abstract method signatures from the trait must be satisfied. */
1564
+ if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1565
+ perform_delayable_implementation_check (ce , existing_fn , fn );
1566
+ return ;
1567
+ }
1568
+
1569
1569
if (existing_fn -> common .scope == ce ) {
1570
1570
/* members from the current class override trait methods */
1571
- /* use temporary *overridden HashTable to detect hidden conflict */
1572
- if (* overridden ) {
1573
- if ((existing_fn = zend_hash_find_ptr (* overridden , key )) != NULL ) {
1574
- if (existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1575
- /* Make sure the trait method is compatible with previosly declared abstract method */
1576
- perform_delayable_implementation_check (ce , fn , existing_fn );
1577
- }
1578
- if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1579
- /* Make sure the abstract declaration is compatible with previous declaration */
1580
- perform_delayable_implementation_check (ce , existing_fn , fn );
1581
- return ;
1582
- }
1583
- }
1584
- } else {
1585
- ALLOC_HASHTABLE (* overridden );
1586
- zend_hash_init_ex (* overridden , 8 , NULL , overridden_ptr_dtor , 0 , 0 );
1587
- }
1588
- zend_hash_update_mem (* overridden , key , fn , sizeof (zend_function ));
1589
- return ;
1590
- } else if ((fn -> common .fn_flags & ZEND_ACC_ABSTRACT )
1591
- && !(existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT )) {
1592
- /* Make sure the abstract declaration is compatible with previous declaration */
1593
- perform_delayable_implementation_check (ce , existing_fn , fn );
1594
1571
return ;
1595
1572
} else if (UNEXPECTED ((existing_fn -> common .scope -> ce_flags & ZEND_ACC_TRAIT )
1596
1573
&& !(existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT ))) {
@@ -1644,7 +1621,7 @@ static void zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce) /*
1644
1621
}
1645
1622
/* }}} */
1646
1623
1647
- 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 ) /* {{{ */
1624
+ static void zend_traits_copy_functions (zend_string * fnname , zend_function * fn , zend_class_entry * ce , HashTable * exclude_table , zend_class_entry * * aliases ) /* {{{ */
1648
1625
{
1649
1626
zend_trait_alias * alias , * * alias_ptr ;
1650
1627
zend_string * lcname ;
@@ -1670,7 +1647,7 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
1670
1647
}
1671
1648
1672
1649
lcname = zend_string_tolower (alias -> alias );
1673
- zend_add_trait_method (ce , ZSTR_VAL (alias -> alias ), lcname , & fn_copy , overridden );
1650
+ zend_add_trait_method (ce , ZSTR_VAL (alias -> alias ), lcname , & fn_copy );
1674
1651
zend_string_release_ex (lcname , 0 );
1675
1652
1676
1653
/* Record the trait from which this alias was resolved. */
@@ -1722,7 +1699,7 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
1722
1699
}
1723
1700
}
1724
1701
1725
- zend_add_trait_method (ce , ZSTR_VAL (fn -> common .function_name ), fnname , & fn_copy , overridden );
1702
+ zend_add_trait_method (ce , ZSTR_VAL (fn -> common .function_name ), fnname , & fn_copy );
1726
1703
}
1727
1704
}
1728
1705
/* }}} */
@@ -1860,7 +1837,6 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce, zend_class_e
1860
1837
static void zend_do_traits_method_binding (zend_class_entry * ce , zend_class_entry * * traits , HashTable * * exclude_tables , zend_class_entry * * aliases ) /* {{{ */
1861
1838
{
1862
1839
uint32_t i ;
1863
- HashTable * overridden = NULL ;
1864
1840
zend_string * key ;
1865
1841
zend_function * fn ;
1866
1842
@@ -1869,7 +1845,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
1869
1845
if (traits [i ]) {
1870
1846
/* copies functions, applies defined aliasing, and excludes unused trait methods */
1871
1847
ZEND_HASH_FOREACH_STR_KEY_PTR (& traits [i ]-> function_table , key , fn ) {
1872
- zend_traits_copy_functions (key , fn , ce , & overridden , exclude_tables [i ], aliases );
1848
+ zend_traits_copy_functions (key , fn , ce , exclude_tables [i ], aliases );
1873
1849
} ZEND_HASH_FOREACH_END ();
1874
1850
1875
1851
if (exclude_tables [i ]) {
@@ -1883,7 +1859,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
1883
1859
for (i = 0 ; i < ce -> num_traits ; i ++ ) {
1884
1860
if (traits [i ]) {
1885
1861
ZEND_HASH_FOREACH_STR_KEY_PTR (& traits [i ]-> function_table , key , fn ) {
1886
- zend_traits_copy_functions (key , fn , ce , & overridden , NULL , aliases );
1862
+ zend_traits_copy_functions (key , fn , ce , NULL , aliases );
1887
1863
} ZEND_HASH_FOREACH_END ();
1888
1864
}
1889
1865
}
@@ -1892,11 +1868,6 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
1892
1868
ZEND_HASH_FOREACH_PTR (& ce -> function_table , fn ) {
1893
1869
zend_fixup_trait_method (fn , ce );
1894
1870
} ZEND_HASH_FOREACH_END ();
1895
-
1896
- if (overridden ) {
1897
- zend_hash_destroy (overridden );
1898
- FREE_HASHTABLE (overridden );
1899
- }
1900
1871
}
1901
1872
/* }}} */
1902
1873
0 commit comments