3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $callback; public function setCallback($callback) { $this->callback = $callback; } public function callCallback() { return call_user_func($this->callback); } } class Bar { protected $foo; public function __construct(Foo $foo) { $this->foo = $foo; $self =& $this; $callback = function() use ($self) { return $this->protectedCallback(); }; $this->foo->setCallback($callback); } protected function protectedCallback() { return "callback called"; } } $foo = new Foo; $bar = new Bar($foo); echo $foo->callCallback();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cbrkb
function name:  (null)
number of ops:  11
compiled vars:  !0 = $foo, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   40     3        NEW                                              $5      'Bar'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   41     7        INIT_METHOD_CALL                                         !0, 'callCallback'
          8        DO_FCALL                                      0  $8      
          9        ECHO                                                     $8
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FCbrkb%3A27%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cbrkb
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   BIND_STATIC                                              !0
   28     1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, 'protectedCallback'
          3        DO_FCALL                                      0  $2      
          4      > RETURN                                                   $2
   29     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCbrkb%3A27%240

Class Foo:
Function setcallback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cbrkb
function name:  setCallback
number of ops:  4
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'callback'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function setcallback

Function callcallback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cbrkb
function name:  callCallback
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      'callback'
          1        INIT_USER_CALL                                0          'call_user_func', ~0
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   15     4*     > RETURN                                                   null

End of function callcallback

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cbrkb
function name:  __construct
number of ops:  13
compiled vars:  !0 = $foo, !1 = $self, !2 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   26     3        FETCH_THIS                                       $4      
          4        ASSIGN_REF                                               !1, $4
   27     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCbrkb%3A27%240'
          6        BIND_LEXICAL                                             ~6, !1
          7        ASSIGN                                                   !2, ~6
   30     8        FETCH_OBJ_R                                      ~8      'foo'
          9        INIT_METHOD_CALL                                         ~8, 'setCallback'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0          
   31    12      > RETURN                                                   null

End of function __construct

Function protectedcallback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cbrkb
function name:  protectedCallback
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E > > RETURN                                                   'callback+called'
   36     1*     > RETURN                                                   null

End of function protectedcallback

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.68 ms | 1399 KiB | 13 Q