3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Signal { private $listeners; function add($callback) { $this->listeners[]=$callback; } function dispatch() { if (empty($this->listeners)) { return; } foreach ($this->listeners as $callback) { call_user_func_array($callback, func_get_args()); } } } function myListener() { print_r(func_get_args()); } $signal = new Signal(); $signal->add('myListener'); $signal->add('myListener'); $signal->add('myListener'); $signal->dispatch('a',456,array(123));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PdsVF
function name:  (null)
number of ops:  18
compiled vars:  !0 = $signal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $1      'Signal'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   24     3        INIT_METHOD_CALL                                         !0, 'add'
          4        SEND_VAL_EX                                              'myListener'
          5        DO_FCALL                                      0          
   25     6        INIT_METHOD_CALL                                         !0, 'add'
          7        SEND_VAL_EX                                              'myListener'
          8        DO_FCALL                                      0          
   26     9        INIT_METHOD_CALL                                         !0, 'add'
         10        SEND_VAL_EX                                              'myListener'
         11        DO_FCALL                                      0          
   27    12        INIT_METHOD_CALL                                         !0, 'dispatch'
         13        SEND_VAL_EX                                              'a'
         14        SEND_VAL_EX                                              456
         15        SEND_VAL_EX                                              <array>
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Function mylistener:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PdsVF
function name:  myListener
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'print_r'
          1        FUNC_GET_ARGS                                    ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   21     4      > RETURN                                                   null

End of function mylistener

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

End of function add

Function dispatch:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 3
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/PdsVF
function name:  dispatch
number of ops:  14
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ISSET_ISEMPTY_PROP_OBJ                                   'listeners'
          1      > JMPZ                                                     ~1, ->3
   10     2    > > RETURN                                                   null
   13     3    >   FETCH_OBJ_R                                      ~2      'listeners'
          4      > FE_RESET_R                                       $3      ~2, ->12
          5    > > FE_FETCH_R                                               $3, !0, ->12
   14     6    >   INIT_USER_CALL                                0          'call_user_func_array', !0
          7        FUNC_GET_ARGS                                    ~4      
          8        SEND_ARRAY                                               ~4
          9        CHECK_UNDEF_ARGS                                         
         10        DO_FCALL                                      0          
   13    11      > JMP                                                      ->5
         12    >   FE_FREE                                                  $3
   16    13      > RETURN                                                   null

End of function dispatch

End of class Signal.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.23 ms | 1400 KiB | 15 Q