File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16198: Usage of super in cloned trait method
3
+ --FILE--
4
+ <?php
5
+
6
+ trait T {
7
+ public function __destruct () {
8
+ parent ::__destruct ();
9
+ }
10
+ }
11
+
12
+ class P {
13
+ public function __destruct () {
14
+ var_dump (__METHOD__ );
15
+ }
16
+ }
17
+
18
+ class C extends P {
19
+ use T;
20
+ }
21
+
22
+ $ c = new C ();
23
+ unset($ c );
24
+
25
+ ?>
26
+ --EXPECT--
27
+ string(13) "P::__destruct"
Original file line number Diff line number Diff line change @@ -1112,7 +1112,10 @@ static inheritance_status do_inheritance_check_on_method(
1112
1112
1113
1113
#define SEPARATE_METHOD () do { \
1114
1114
if ((flags & ZEND_INHERITANCE_LAZY_CHILD_CLONE) \
1115
- && child_scope != ce && child->type == ZEND_USER_FUNCTION) { \
1115
+ && child_scope != ce \
1116
+ /* Trait scopes are fixed after inheritance. However, they are always duplicated. */ \
1117
+ && !(child_scope -> ce_flags & ZEND_ACC_TRAIT ) \
1118
+ && child -> type == ZEND_USER_FUNCTION ) { \
1116
1119
/* op_array wasn't duplicated yet */ \
1117
1120
zend_function * new_function = zend_arena_alloc (& CG (arena ), sizeof (zend_op_array )); \
1118
1121
memcpy (new_function , child , sizeof (zend_op_array )); \
You can’t perform that action at this time.
0 commit comments