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++) { $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/3aJPB
function name:  (null)
number of ops:  18
compiled vars:  !0 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   NEW                                              $1      'Events'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   70     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          
   71     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          
   72    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/3aJPB
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/3aJPB
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/3aJPB
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/3aJPB
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/3aJPB
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/3aJPB
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 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 4
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 4
Branch analysis from position: 28
Branch analysis from position: 4
filename:       /in/3aJPB
function name:  notify
number of ops:  29
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                                                      ->25
   46     4    >   INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        FETCH_DIM_R                                      ~8      $7, !1
          8        ASSIGN                                                   !2, ~8
   48     9        FETCH_DIM_R                                      ~10     !0, !2
         10        ASSIGN                                                   !3, ~10
   49    11        INIT_METHOD_CALL                                         !3, 'setEvents'
         12        FETCH_THIS                                       $12     
         13        SEND_VAR_EX                                              $12
         14        DO_FCALL                                      0          
   50    15        INIT_METHOD_CALL                                         !3, 'dispatch'
         16        DO_FCALL                                      0          
   52    17        INIT_FCALL                                               'array_merge'
         18        SEND_VAR                                                 !0
         19        FETCH_OBJ_R                                      ~15     'eventList'
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                         $16     
         22        ASSIGN                                                   !0, $16
   54    23        ECHO                                                     !2
   45    24        PRE_INC                                                  !1
         25    >   COUNT                                            ~19     !0
         26        IS_SMALLER_OR_EQUAL                                      !1, ~19
         27      > JMPNZ                                                    ~20, ->4
   57    28    > > 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/3aJPB
function name:  addEvent
number of ops:  6
compiled vars:  !0 = $name, !1 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   61     2        FETCH_OBJ_W                                      $2      'eventList'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   62     5      > RETURN                                                   null

End of function addevent

End of class Events.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.33 ms | 1404 KiB | 17 Q