File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Dynamic static call of non-static method
3
+ --FILE--
4
+ <?php
5
+ class Foo {
6
+ function test1 () {
7
+ $ method = ['Foo ' , 'bar ' ];
8
+ $ method ();
9
+ }
10
+ function test2 () {
11
+ $ method = 'Foo::bar ' ;
12
+ $ method ();
13
+ }
14
+ function __call ($ name , $ args ) {}
15
+ }
16
+ $ x = new Foo ;
17
+ try {
18
+ $ x ->test1 ();
19
+ } catch (Error $ e ) {
20
+ echo $ e ->getMessage (), "\n" ;
21
+ }
22
+ try {
23
+ $ x ->test2 ();
24
+ } catch (Error $ e ) {
25
+ echo $ e ->getMessage (), "\n" ;
26
+ }
27
+ ?>
28
+ --EXPECT--
29
+ Non-static method Foo::bar() cannot be called statically
30
+ Non-static method Foo::bar() cannot be called statically
Original file line number Diff line number Diff line change @@ -4021,6 +4021,10 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s
4021
4021
4022
4022
if (UNEXPECTED (!(fbc -> common .fn_flags & ZEND_ACC_STATIC ))) {
4023
4023
zend_non_static_method_call (fbc );
4024
+ if (fbc -> common .fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) {
4025
+ zend_string_release_ex (fbc -> common .function_name , 0 );
4026
+ zend_free_trampoline (fbc );
4027
+ }
4024
4028
return NULL ;
4025
4029
}
4026
4030
if (EXPECTED (fbc -> type == ZEND_USER_FUNCTION ) && UNEXPECTED (!RUN_TIME_CACHE (& fbc -> op_array ))) {
@@ -4145,6 +4149,10 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
4145
4149
}
4146
4150
if (!(fbc -> common .fn_flags & ZEND_ACC_STATIC )) {
4147
4151
zend_non_static_method_call (fbc );
4152
+ if (fbc -> common .fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) {
4153
+ zend_string_release_ex (fbc -> common .function_name , 0 );
4154
+ zend_free_trampoline (fbc );
4155
+ }
4148
4156
return NULL ;
4149
4157
}
4150
4158
object_or_called_scope = called_scope ;
You can’t perform that action at this time.
0 commit comments