3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function test() { echo 'First'; } } class B extends A { public function test() { echo 'Second'; } } $instance = new B; $refClosure = (new ReflectionMethod(A::class, 'test')) ->getClosure($instance) ->bindTo($instance, A::class); $refClosure();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OdQJK
function name:  (null)
number of ops:  18
compiled vars:  !0 = $instance, !1 = $refClosure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   16     3        NEW                                              $5      'ReflectionMethod'
          4        SEND_VAL_EX                                              'A'
          5        SEND_VAL_EX                                              'test'
          6        DO_FCALL                                      0          
   17     7        INIT_METHOD_CALL                                         $5, 'getClosure'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $7      
   18    10        INIT_METHOD_CALL                                         $7, 'bindTo'
         11        SEND_VAR_EX                                              !0
         12        SEND_VAL_EX                                              'A'
         13        DO_FCALL                                      0  $8      
   16    14        ASSIGN                                                   !1, $8
   19    15        INIT_DYNAMIC_CALL                                        !1
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Class A:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OdQJK
function name:  test
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'First'
    6     1      > RETURN                                                   null

End of function test

End of class A.

Class B:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OdQJK
function name:  test
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                     'Second'
   12     1      > RETURN                                                   null

End of function test

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.44 ms | 1398 KiB | 13 Q