3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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/kWmBf
function name:  (null)
number of ops:  13
compiled vars:  !0 = $p, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'myparent', 'observer'
   26     1        NEW                                              $2      'MyParent'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   27     4        INIT_METHOD_CALL                                         !0, 'createChild'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   28     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   29    10        INIT_METHOD_CALL                                         !1, '__destroy'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FkWmBf%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kWmBf
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     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%2FkWmBf%3A8%240

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

End of function createchild

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/kWmBf
function name:  __constructor
number of ops:  4
compiled vars:  !0 = $gatewayFunction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ASSIGN_OBJ                                               'gatewayFunction'
          2        OP_DATA                                                  !0
   18     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/kWmBf
function name:  __destroy
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~0      'gatewayFunction'
          1        INIT_METHOD_CALL                                         ~0, '__invoke'
          2        DO_FCALL                                      0          
   23     3      > RETURN                                                   null

End of function __destroy

End of class MyChild.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.69 ms | 1400 KiB | 15 Q