3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Signal { protected $listeners; function add($callback) { $this->listeners[]=$callback; } function dispatch() { if (empty($this->listeners)) { return; } $args = func_get_args(); $numArgs = func_num_args(); foreach ($this->listeners as $callback) { switch ($numArgs) { case 0: call_user_func($callback); break; case 1: call_user_func($callback, $args[0]); break; case 2: call_user_func($callback, $args[0], $args[1]); break; default: 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->dispatch('a'); $signal->dispatch('a',456); $signal->dispatch('a',456,array(123));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hDZip
function name:  (null)
number of ops:  22
compiled vars:  !0 = $signal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $1      'Signal'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   43     3        INIT_METHOD_CALL                                         !0, 'add'
          4        SEND_VAL_EX                                              'myListener'
          5        DO_FCALL                                      0          
   44     6        INIT_METHOD_CALL                                         !0, 'add'
          7        SEND_VAL_EX                                              'myListener'
          8        DO_FCALL                                      0          
   45     9        INIT_METHOD_CALL                                         !0, 'dispatch'
         10        SEND_VAL_EX                                              'a'
         11        DO_FCALL                                      0          
   46    12        INIT_METHOD_CALL                                         !0, 'dispatch'
         13        SEND_VAL_EX                                              'a'
         14        SEND_VAL_EX                                              456
         15        DO_FCALL                                      0          
   47    16        INIT_METHOD_CALL                                         !0, 'dispatch'
         17        SEND_VAL_EX                                              'a'
         18        SEND_VAL_EX                                              456
         19        SEND_VAL_EX                                              <array>
         20        DO_FCALL                                      0          
         21      > RETURN                                                   1

Function mylistener:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hDZip
function name:  myListener
number of ops:  6
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
   39     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   40     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/hDZip
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 = 9, Position 2 = 37
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 37
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/hDZip
function name:  dispatch
number of ops:  39
compiled vars:  !0 = $args, !1 = $numArgs, !2 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ISSET_ISEMPTY_PROP_OBJ                                   'listeners'
          1      > JMPZ                                                     ~3, ->3
   10     2    > > RETURN                                                   null
   13     3    >   FUNC_GET_ARGS                                    ~4      
          4        ASSIGN                                                   !0, ~4
   14     5        FUNC_NUM_ARGS                                    ~6      
          6        ASSIGN                                                   !1, ~6
   16     7        FETCH_OBJ_R                                      ~8      'listeners'
          8      > FE_RESET_R                                       $9      ~8, ->37
          9    > > FE_FETCH_R                                               $9, !2, ->37
   18    10    >   IS_EQUAL                                                 !1, 0
         11      > JMPNZ                                                    ~10, ->17
   22    12    >   IS_EQUAL                                                 !1, 1
         13      > JMPNZ                                                    ~10, ->20
   26    14    >   IS_EQUAL                                                 !1, 2
         15      > JMPNZ                                                    ~10, ->25
         16    > > JMP                                                      ->32
   19    17    >   INIT_USER_CALL                                0          'call_user_func', !2
         18        DO_FCALL                                      0          
   20    19      > JMP                                                      ->36
   23    20    >   INIT_USER_CALL                                1          'call_user_func', !2
         21        FETCH_DIM_R                                      ~12     !0, 0
         22        SEND_USER                                                ~12
         23        DO_FCALL                                      0          
   24    24      > JMP                                                      ->36
   27    25    >   INIT_USER_CALL                                2          'call_user_func', !2
         26        FETCH_DIM_R                                      ~14     !0, 0
         27        SEND_USER                                                ~14
         28        FETCH_DIM_R                                      ~15     !0, 1
         29        SEND_USER                                                ~15
         30        DO_FCALL                                      0          
   28    31      > JMP                                                      ->36
   31    32    >   INIT_USER_CALL                                0          'call_user_func_array', !2
         33        SEND_ARRAY                                               !0
         34        CHECK_UNDEF_ARGS                                         
         35        DO_FCALL                                      0          
   16    36    > > JMP                                                      ->9
         37    >   FE_FREE                                                  $9
   34    38      > RETURN                                                   null

End of function dispatch

End of class Signal.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.24 ms | 1396 KiB | 15 Q