3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Observer { protected function callme() { } } class MyParent extends Observer { function createChild() { $this->callme(); // this is OK return new MyChild (function() { $this->callme(); }); } } class MyChild { private $gatewayFunction; public function __constructor (Closure $gatewayFunction) { $this->gatewayFunction = $gatewayFunction; } public function __destroy() { $this->gatewayFunction->__invoke(); } } $p = new MyParent(); $c = $p->createChild(); var_dump($c); $c->__destroy();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPUsJ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $p, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $2      'MyParent'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   33     3        INIT_METHOD_CALL                                         !0, 'createChild'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   34     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   35     9        INIT_METHOD_CALL                                         !1, '__destroy'
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FLPUsJ%3A14%240

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

End of function callme

End of class Observer.

Class MyParent:
Function createchild:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPUsJ
function name:  createChild
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_METHOD_CALL                                         'callme'
          1        DO_FCALL                                      0          
   14     2        NEW                                              $1      'MyChild'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPUsJ%3A14%240'
          4        SEND_VAL_EX                                              ~2
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $1
   15     7*     > RETURN                                                   null

End of function createchild

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

End of function callme

End of class MyParent.

Class MyChild:
Function __constructor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPUsJ
function name:  __constructor
number of ops:  4
compiled vars:  !0 = $gatewayFunction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        ASSIGN_OBJ                                               'gatewayFunction'
          2        OP_DATA                                                  !0
   24     3      > RETURN                                                   null

End of function __constructor

Function __destroy:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPUsJ
function name:  __destroy
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'gatewayFunction'
          1        INIT_METHOD_CALL                                         ~0, '__invoke'
          2        DO_FCALL                                      0          
   29     3      > RETURN                                                   null

End of function __destroy

End of class MyChild.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.2 ms | 1400 KiB | 15 Q