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; } $args = func_get_args(); foreach ($this->listeners as $callback) { call_user_func_array($callback, $args); } } } function myListener() { $args = func_get_args(); print_r($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/cofr2
function name:  (null)
number of ops:  18
compiled vars:  !0 = $signal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Signal'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'add'
          4        SEND_VAL_EX                                              'myListener'
          5        DO_FCALL                                      0          
   28     6        INIT_METHOD_CALL                                         !0, 'add'
          7        SEND_VAL_EX                                              'myListener'
          8        DO_FCALL                                      0          
   29     9        INIT_METHOD_CALL                                         !0, 'add'
         10        SEND_VAL_EX                                              'myListener'
         11        DO_FCALL                                      0          
   30    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/cofr2
function name:  myListener
number of ops:  6
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
   23     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   24     5      > 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/cofr2
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 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/cofr2
function name:  dispatch
number of ops:  15
compiled vars:  !0 = $args, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ISSET_ISEMPTY_PROP_OBJ                                   'listeners'
          1      > JMPZ                                                     ~2, ->3
   10     2    > > RETURN                                                   null
   13     3    >   FUNC_GET_ARGS                                    ~3      
          4        ASSIGN                                                   !0, ~3
   15     5        FETCH_OBJ_R                                      ~5      'listeners'
          6      > FE_RESET_R                                       $6      ~5, ->13
          7    > > FE_FETCH_R                                               $6, !1, ->13
   16     8    >   INIT_USER_CALL                                0          'call_user_func_array', !1
          9        SEND_ARRAY                                               !0
         10        CHECK_UNDEF_ARGS                                         
         11        DO_FCALL                                      0          
   15    12      > JMP                                                      ->7
         13    >   FE_FREE                                                  $6
   18    14      > RETURN                                                   null

End of function dispatch

End of class Signal.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.88 ms | 1400 KiB | 15 Q