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/fCQcN
function name:  (null)
number of ops:  16
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        INIT_FCALL                                               'sayhello'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR_NO_REF_EX                                       $4
          8        DO_FCALL                                      0          
   27     9        INIT_FCALL                                               'sleep'
         10        SEND_VAL                                                 15
         11        DO_ICALL                                                 
   28    12        INIT_METHOD_CALL                                         !0, 'trig'
         13        SEND_VAL_EX                                              'hello'
         14        DO_FCALL                                      0          
         15      > RETURN                                                   1

Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fCQcN
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/fCQcN
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/fCQcN
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/fCQcN
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:
168.35 ms | 1403 KiB | 16 Q