3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function save($a = 1, $b = 2) { printf('Class name %s, A = %s, B = %s%s', get_class($this), $a, $b, PHP_EOL); } } class B extends A { public function test() { $closure = Closure::fromCallable('parent::save'); $closure->bindTo($this); $invoker = new Invoker(); $invoker->run($closure, func_get_args()); } } class Invoker { public function run(Closure $closure, array $params) { $closure(...$params); } } $o = new B; $o->test(); $o->test('fff'); $o->test(100, 500); $o->test('a', 'b', 'c');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TBRl6
function name:  (null)
number of ops:  18
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $1      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   31     3        INIT_METHOD_CALL                                         !0, 'test'
          4        DO_FCALL                                      0          
   32     5        INIT_METHOD_CALL                                         !0, 'test'
          6        SEND_VAL_EX                                              'fff'
          7        DO_FCALL                                      0          
   33     8        INIT_METHOD_CALL                                         !0, 'test'
          9        SEND_VAL_EX                                              100
         10        SEND_VAL_EX                                              500
         11        DO_FCALL                                      0          
   34    12        INIT_METHOD_CALL                                         !0, 'test'
         13        SEND_VAL_EX                                              'a'
         14        SEND_VAL_EX                                              'b'
         15        SEND_VAL_EX                                              'c'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Class A:
Function save:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TBRl6
function name:  save
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      1
          1        RECV_INIT                                        !1      2
    7     2        INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 'Class+name+%25s%2C+A+%3D+%25s%2C+B+%3D+%25s%25s'
          4        FETCH_THIS                                       ~2      
          5        GET_CLASS                                        ~3      ~2
          6        SEND_VAL                                                 ~3
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 '%0A'
         10        DO_ICALL                                                 
    8    11      > RETURN                                                   null

End of function save

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/TBRl6
function name:  test
number of ops:  17
compiled vars:  !0 = $closure, !1 = $invoker
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'Closure', 'fromCallable'
          1        SEND_VAL                                                 'parent%3A%3Asave'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   16     4        INIT_METHOD_CALL                                         !0, 'bindTo'
          5        FETCH_THIS                                       $4      
          6        SEND_VAR_EX                                              $4
          7        DO_FCALL                                      0          
   17     8        NEW                                              $6      'Invoker'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $6
   18    11        INIT_METHOD_CALL                                         !1, 'run'
         12        SEND_VAR_EX                                              !0
         13        FUNC_GET_ARGS                                    ~9      
         14        SEND_VAL_EX                                              ~9
         15        DO_FCALL                                      0          
   19    16      > RETURN                                                   null

End of function test

Function save:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TBRl6
function name:  save
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      1
          1        RECV_INIT                                        !1      2
    7     2        INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 'Class+name+%25s%2C+A+%3D+%25s%2C+B+%3D+%25s%25s'
          4        FETCH_THIS                                       ~2      
          5        GET_CLASS                                        ~3      ~2
          6        SEND_VAL                                                 ~3
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 '%0A'
         10        DO_ICALL                                                 
    8    11      > RETURN                                                   null

End of function save

End of class B.

Class Invoker:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TBRl6
function name:  run
number of ops:  7
compiled vars:  !0 = $closure, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        INIT_DYNAMIC_CALL                                        !0
          3        SEND_UNPACK                                              !1
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1          
   27     6      > RETURN                                                   null

End of function run

End of class Invoker.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.03 ms | 1400 KiB | 15 Q