3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface LifeCycleListener { function before(); function after(); } class LifeCycler { private $listeners = []; public function run(callable $x) { foreach ($this->listeners as $l) $l->before(); $x(); foreach ($this->listeners as $l) $l->after(); } public function addListener(LifeCycleListener $listener) { $this->listeners[] = $listener; } } $lc = new LifeCycler(); $lc->addListener(new class implements LifeCycler { function before() { echo "before!\n"; } function after() { echo "after!\n"; } }); $lc->run(function() { echo "running!\n"; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FRZt3
function name:  (null)
number of ops:  14
compiled vars:  !0 = $lc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $1      'LifeCycler'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   23     3        INIT_METHOD_CALL                                         !0, 'addListener'
          4        DECLARE_ANON_CLASS                               <unknown> 
          5        NEW                                              $5      $4
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $5
          8        DO_FCALL                                      0          
   27     9        INIT_METHOD_CALL                                         !0, 'run'
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFRZt3%3A27%241'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FFRZt3%3A27%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FRZt3
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   ECHO                                                     'running%21%0A'
          1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFRZt3%3A27%241

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

End of function before

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

End of function after

End of class LifeCycleListener.

Class LifeCycler:
Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 7
filename:       /in/FRZt3
function name:  run
number of ops:  18
compiled vars:  !0 = $x, !1 = $l
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        FETCH_OBJ_R                                      ~2      'listeners'
          2      > FE_RESET_R                                       $3      ~2, ->7
          3    > > FE_FETCH_R                                               $3, !1, ->7
          4    >   INIT_METHOD_CALL                                         !1, 'before'
          5        DO_FCALL                                      0          
          6      > JMP                                                      ->3
          7    >   FE_FREE                                                  $3
   13     8        INIT_DYNAMIC_CALL                                        !0
          9        DO_FCALL                                      0          
   14    10        FETCH_OBJ_R                                      ~6      'listeners'
         11      > FE_RESET_R                                       $7      ~6, ->16
         12    > > FE_FETCH_R                                               $7, !1, ->16
         13    >   INIT_METHOD_CALL                                         !1, 'after'
         14        DO_FCALL                                      0          
         15      > JMP                                                      ->12
         16    >   FE_FREE                                                  $7
   15    17      > RETURN                                                   null

End of function run

Function addlistener:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FRZt3
function name:  addListener
number of ops:  5
compiled vars:  !0 = $listener
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        FETCH_OBJ_W                                      $1      'listeners'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   19     4      > RETURN                                                   null

End of function addlistener

End of class LifeCycler.

Class LifeCycler@anonymous:
Function before:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FRZt3
function name:  before
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ECHO                                                     'before%21%0A'
          1      > RETURN                                                   null

End of function before

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

End of function after

End of class LifeCycler@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.88 ms | 1399 KiB | 13 Q