File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-14009: Traits inherit prototype
3
+ --FILE--
4
+ <?php
5
+
6
+ class P {
7
+ protected function common () {
8
+ throw new Exception ('Unreachable ' );
9
+ }
10
+ }
11
+
12
+ class A extends P {
13
+ public function test (P $ sibling ) {
14
+ $ sibling ->common ();
15
+ }
16
+ }
17
+
18
+ class B extends P {
19
+ protected function common () {
20
+ echo __METHOD__ , "\n" ;
21
+ }
22
+ }
23
+
24
+ trait T {
25
+ protected function common () {
26
+ echo __METHOD__ , "\n" ;
27
+ }
28
+ }
29
+
30
+ class C extends P {
31
+ use T;
32
+ }
33
+
34
+ $ a = new A ();
35
+ $ a ->test (new B ());
36
+ $ a ->test (new C ());
37
+
38
+ ?>
39
+ --EXPECT--
40
+ B::common
41
+ T::common
Original file line number Diff line number Diff line change @@ -1146,13 +1146,13 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
1146
1146
parent = proto ;
1147
1147
}
1148
1148
1149
- if (!check_only && child -> common .prototype != proto && child_zv ) {
1149
+ if (!check_only && child -> common .prototype != proto ) {
1150
1150
do {
1151
1151
if (child -> common .scope != ce && child -> type == ZEND_USER_FUNCTION ) {
1152
1152
if (ce -> ce_flags & ZEND_ACC_INTERFACE ) {
1153
1153
/* Few parent interfaces contain the same method */
1154
1154
break ;
1155
- } else {
1155
+ } else if ( child_zv ) {
1156
1156
/* op_array wasn't duplicated yet */
1157
1157
zend_function * new_function = zend_arena_alloc (& CG (arena ), sizeof (zend_op_array ));
1158
1158
memcpy (new_function , child , sizeof (zend_op_array ));
You can’t perform that action at this time.
0 commit comments