3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Events { private $events = Array(); function __construct(){} function bind($eventName,Closure $callback) { if (!array_key_exists($eventName,$this->events)) { $this->events[$eventName] = $callback; } } function trig($eventName) { if(array_key_exists($eventName, $this->events)) { call_user_func($this->events[$eventName]); } } } function sayHello() { print("Hello world."); } $e = new Events; $e->bind('hello',sayHello); sleep(15); $e->trig('hello');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VtDEd
function name:  (null)
number of ops:  15
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Events'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     3        INIT_METHOD_CALL                                         !0, 'bind'
          4        SEND_VAL_EX                                              'hello'
          5        FETCH_CONSTANT                                   ~4      'sayHello'
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0          
   27     8        INIT_FCALL                                               'sleep'
          9        SEND_VAL                                                 15
         10        DO_ICALL                                                 
   28    11        INIT_METHOD_CALL                                         !0, 'trig'
         12        SEND_VAL_EX                                              'hello'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VtDEd
function name:  sayHello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ECHO                                                     'Hello+world.'
   22     1      > RETURN                                                   null

End of function sayhello

Class Events:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VtDEd
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   null

End of function __construct

Function bind:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/VtDEd
function name:  bind
number of ops:  10
compiled vars:  !0 = $eventName, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        FETCH_OBJ_R                                      ~2      'events'
          3        ARRAY_KEY_EXISTS                                 ~3      !0, ~2
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->9
    9     6    >   FETCH_OBJ_W                                      $5      'events'
          7        ASSIGN_DIM                                               $5, !0
          8        OP_DATA                                                  !1
   11     9    > > RETURN                                                   null

End of function bind

Function trig:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/VtDEd
function name:  trig
number of ops:  9
compiled vars:  !0 = $eventName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'events'
          2        ARRAY_KEY_EXISTS                                         !0, ~1
          3      > JMPZ                                                     ~2, ->8
   15     4    >   FETCH_OBJ_R                                      ~3      'events'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        INIT_USER_CALL                                0          'call_user_func', ~4
          7        DO_FCALL                                      0          
   17     8    > > RETURN                                                   null

End of function trig

End of class Events.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.4 ms | 1400 KiB | 15 Q