3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Event { protected $Events; public function dispatch() { echo "default Event \n"; } public function setEvents(Events $events) { $this->Events = $events; } } class customEvent extends Event { public function dispatch() { echo "should be in same notify loop"; } } class addedInIterationEvent extends Event { public function dispatch() { echo "addedInIterationEvent \n"; $this->Events->addEvent("customEvent",new customEvent()); } } class Events { protected $eventList = array(); public function notify() { $events = $this->eventList; for ($i = 0; $i <= sizeof($events); $i++) { if (isset(array_keys($events)[$i])) { $eventName = array_keys($events)[$i]; $event = $events[$eventName]; $event->setEvents($this); $event->dispatch(); $events = array_merge($events,$this->eventList); echo $eventName; } } } public function addEvent($name,$event) { $this->eventList[$name] = $event; } } $events = new Events(); $events->addEvent("basicEvent",new Event); $events->addEvent("addedInIterationEvent",new addedInIterationEvent); $events->notify();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  (null)
number of ops:  18
compiled vars:  !0 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   NEW                                              $1      'Events'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   72     3        INIT_METHOD_CALL                                         !0, 'addEvent'
          4        SEND_VAL_EX                                              'basicEvent'
          5        NEW                                              $4      'Event'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $4
          8        DO_FCALL                                      0          
   73     9        INIT_METHOD_CALL                                         !0, 'addEvent'
         10        SEND_VAL_EX                                              'addedInIterationEvent'
         11        NEW                                              $7      'addedInIterationEvent'
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $7
         14        DO_FCALL                                      0          
   74    15        INIT_METHOD_CALL                                         !0, 'notify'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

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

End of function dispatch

Function setevents:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  setEvents
number of ops:  4
compiled vars:  !0 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'Events'
          2        OP_DATA                                                  !0
   16     3      > RETURN                                                   null

End of function setevents

End of class Event.

Class customEvent:
Function dispatch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  dispatch
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                     'should+be+in+same+notify+loop'
   24     1      > RETURN                                                   null

End of function dispatch

Function setevents:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  setEvents
number of ops:  4
compiled vars:  !0 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'Events'
          2        OP_DATA                                                  !0
   16     3      > RETURN                                                   null

End of function setevents

End of class customEvent.

Class addedInIterationEvent:
Function dispatch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  dispatch
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                     'addedInIterationEvent+%0A'
   32     1        FETCH_OBJ_R                                      ~0      'Events'
          2        INIT_METHOD_CALL                                         ~0, 'addEvent'
          3        SEND_VAL_EX                                              'customEvent'
          4        NEW                                              $1      'customEvent'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0          
   33     8      > RETURN                                                   null

End of function dispatch

Function setevents:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  setEvents
number of ops:  4
compiled vars:  !0 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'Events'
          2        OP_DATA                                                  !0
   16     3      > RETURN                                                   null

End of function setevents

End of class addedInIterationEvent.

Class Events:
Function notify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 4
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 4
Branch analysis from position: 33
Branch analysis from position: 4
Branch analysis from position: 29
filename:       /in/tEZS6
function name:  notify
number of ops:  34
compiled vars:  !0 = $events, !1 = $i, !2 = $eventName, !3 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   FETCH_OBJ_R                                      ~4      'eventList'
          1        ASSIGN                                                   !0, ~4
   45     2        ASSIGN                                                   !1, 0
          3      > JMP                                                      ->30
   46     4    >   INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        ISSET_ISEMPTY_DIM_OBJ                         0          $7, !1
          8      > JMPZ                                                     ~8, ->29
   47     9    >   INIT_FCALL                                               'array_keys'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $9      
         12        FETCH_DIM_R                                      ~10     $9, !1
         13        ASSIGN                                                   !2, ~10
   49    14        FETCH_DIM_R                                      ~12     !0, !2
         15        ASSIGN                                                   !3, ~12
   50    16        INIT_METHOD_CALL                                         !3, 'setEvents'
         17        FETCH_THIS                                       $14     
         18        SEND_VAR_EX                                              $14
         19        DO_FCALL                                      0          
   51    20        INIT_METHOD_CALL                                         !3, 'dispatch'
         21        DO_FCALL                                      0          
   53    22        INIT_FCALL                                               'array_merge'
         23        SEND_VAR                                                 !0
         24        FETCH_OBJ_R                                      ~17     'eventList'
         25        SEND_VAL                                                 ~17
         26        DO_ICALL                                         $18     
         27        ASSIGN                                                   !0, $18
   55    28        ECHO                                                     !2
   45    29    >   PRE_INC                                                  !1
         30    >   COUNT                                            ~21     !0
         31        IS_SMALLER_OR_EQUAL                                      !1, ~21
         32      > JMPNZ                                                    ~22, ->4
   59    33    > > RETURN                                                   null

End of function notify

Function addevent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEZS6
function name:  addEvent
number of ops:  6
compiled vars:  !0 = $name, !1 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   63     2        FETCH_OBJ_W                                      $2      'eventList'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   64     5      > RETURN                                                   null

End of function addevent

End of class Events.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.58 ms | 1404 KiB | 17 Q