3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected function foo1() { return 'foo1'; } } $foo = new Foo(); $works = function () { return call_user_func(array($this, 'foo1')); }; $broken = function () { return $this->foo1(); }; $works = $works->bindTo($foo, $foo); $broken = $broken->bindTo($foo, $foo); var_dump($works()); var_dump($broken());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OUqSF
function name:  (null)
number of ops:  28
compiled vars:  !0 = $foo, !1 = $works, !2 = $broken
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   11     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOUqSF%3A11%240'
          4        ASSIGN                                                   !1, ~6
   14     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOUqSF%3A14%241'
          6        ASSIGN                                                   !2, ~8
   17     7        INIT_METHOD_CALL                                         !1, 'bindTo'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $10     
         11        ASSIGN                                                   !1, $10
   18    12        INIT_METHOD_CALL                                         !2, 'bindTo'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !2, $12
   19    17        INIT_FCALL                                               'var_dump'
         18        INIT_DYNAMIC_CALL                                        !1
         19        DO_FCALL                                      0  $14     
         20        SEND_VAR                                                 $14
         21        DO_ICALL                                                 
   20    22        INIT_FCALL                                               'var_dump'
         23        INIT_DYNAMIC_CALL                                        !2
         24        DO_FCALL                                      0  $16     
         25        SEND_VAR                                                 $16
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FOUqSF%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OUqSF
function name:  {closure}
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                       ~0      
          1        INIT_ARRAY                                       ~1      ~0
          2        ADD_ARRAY_ELEMENT                                ~1      'foo1'
          3        INIT_USER_CALL                                0          'call_user_func', ~1
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
   13     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOUqSF%3A11%240

Function %00%7Bclosure%7D%2Fin%2FOUqSF%3A14%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OUqSF
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_THIS                                       $0      
          1        INIT_METHOD_CALL                                         $0, 'foo1'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   16     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOUqSF%3A14%241

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

End of function foo1

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.15 ms | 1392 KiB | 15 Q