3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $callBack; public function foo() { $self = $this; $calBack = $this->callBack; $calBack(); } } class B { public function hello() { echo "Nyan"; } public function bar(A $a) { $self = $this; $a->callBack = function() use ($self) { $self->hello(); }; $a->foo(); } } $b = new B(); $b->bar(new A());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D6uZ4
function name:  (null)
number of ops:  9
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $1      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   34     3        INIT_METHOD_CALL                                         !0, 'bar'
          4        NEW                                              $4      'A'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $4
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FD6uZ4%3A24%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D6uZ4
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   BIND_STATIC                                              !0
   25     1        INIT_METHOD_CALL                                         !0, 'hello'
          2        DO_FCALL                                      0          
   26     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FD6uZ4%3A24%240

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D6uZ4
function name:  foo
number of ops:  7
compiled vars:  !0 = $self, !1 = $calBack
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_THIS                                       ~2      
          1        ASSIGN                                                   !0, ~2
    9     2        FETCH_OBJ_R                                      ~4      'callBack'
          3        ASSIGN                                                   !1, ~4
   11     4        INIT_DYNAMIC_CALL                                        !1
          5        DO_FCALL                                      0          
   12     6      > RETURN                                                   null

End of function foo

End of class A.

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

End of function hello

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D6uZ4
function name:  bar
number of ops:  10
compiled vars:  !0 = $a, !1 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        FETCH_THIS                                       ~2      
          2        ASSIGN                                                   !1, ~2
   24     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FD6uZ4%3A24%240'
          4        BIND_LEXICAL                                             ~5, !1
          5        ASSIGN_OBJ                                               !0, 'callBack'
   26     6        OP_DATA                                                  ~5
   28     7        INIT_METHOD_CALL                                         !0, 'foo'
          8        DO_FCALL                                      0          
   29     9      > RETURN                                                   null

End of function bar

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.19 ms | 1399 KiB | 13 Q