3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/New_York'); class Block { private $start; private $end; private $callback; public function __construct($start, $end, callable $callback) { $this->start = $start; $this->end = $end; $this->callback = $callback; } public function check($time) { return $time > strtotime($this->start) && $time > strtotime($this->end); } public function invoke() { call_user_func($this->callback); } } $blocks = [ new Block('16:00:00', '18:00:00', function () { echo 'Foo!'; }), new Block('18:00:00', '20:00:00', function () { echo 'Bar!'; }), new Block('20:00:00', '22:00:00', function () { echo 'Qux!'; }), ]; while (true) { foreach ($blocks as $block) { if ($block->check()) { $block->invoke(); } } sleep(1); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 26
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 33
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 26
Branch analysis from position: 39
Branch analysis from position: 26
Branch analysis from position: 34
filename:       /in/NYITM
function name:  (null)
number of ops:  40
compiled vars:  !0 = $blocks, !1 = $block
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'America%2FNew_York'
          2        DO_ICALL                                                 
   24     3        NEW                                              $3      'Block'
          4        SEND_VAL_EX                                              '16%3A00%3A00'
          5        SEND_VAL_EX                                              '18%3A00%3A00'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNYITM%3A24%240'
   26     7        SEND_VAL_EX                                              ~4
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~6      $3
   27    10        NEW                                              $7      'Block'
         11        SEND_VAL_EX                                              '18%3A00%3A00'
         12        SEND_VAL_EX                                              '20%3A00%3A00'
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNYITM%3A27%241'
   29    14        SEND_VAL_EX                                              ~8
         15        DO_FCALL                                      0          
         16        ADD_ARRAY_ELEMENT                                ~6      $7
   30    17        NEW                                              $10     'Block'
         18        SEND_VAL_EX                                              '20%3A00%3A00'
         19        SEND_VAL_EX                                              '22%3A00%3A00'
         20        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNYITM%3A30%242'
   32    21        SEND_VAL_EX                                              ~11
         22        DO_FCALL                                      0          
         23        ADD_ARRAY_ELEMENT                                ~6      $10
   23    24        ASSIGN                                                   !0, ~6
   35    25      > JMP                                                      ->38
   36    26    > > FE_RESET_R                                       $14     !0, ->34
         27    > > FE_FETCH_R                                               $14, !1, ->34
   37    28    >   INIT_METHOD_CALL                                         !1, 'check'
         29        DO_FCALL                                      0  $15     
         30      > JMPZ                                                     $15, ->33
   38    31    >   INIT_METHOD_CALL                                         !1, 'invoke'
         32        DO_FCALL                                      0          
   36    33    > > JMP                                                      ->27
         34    >   FE_FREE                                                  $14
   41    35        INIT_FCALL                                               'sleep'
         36        SEND_VAL                                                 1
         37        DO_ICALL                                                 
   35    38    > > JMPNZ                                                    <true>, ->26
   42    39    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FNYITM%3A24%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NYITM
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ECHO                                                     'Foo%21'
   26     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNYITM%3A24%240

Function %00%7Bclosure%7D%2Fin%2FNYITM%3A27%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NYITM
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ECHO                                                     'Bar%21'
   29     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNYITM%3A27%241

Function %00%7Bclosure%7D%2Fin%2FNYITM%3A30%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NYITM
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                     'Qux%21'
   32     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNYITM%3A30%242

Class Block:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NYITM
function name:  __construct
number of ops:  10
compiled vars:  !0 = $start, !1 = $end, !2 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3        ASSIGN_OBJ                                               'start'
          4        OP_DATA                                                  !0
   11     5        ASSIGN_OBJ                                               'end'
          6        OP_DATA                                                  !1
   12     7        ASSIGN_OBJ                                               'callback'
          8        OP_DATA                                                  !2
   13     9      > RETURN                                                   null

End of function __construct

Function check:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/NYITM
function name:  check
number of ops:  15
compiled vars:  !0 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'strtotime'
          2        FETCH_OBJ_R                                      ~1      'start'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        IS_SMALLER                                       ~3      $2, !0
          6      > JMPZ_EX                                          ~3      ~3, ->13
   16     7    >   INIT_FCALL                                               'strtotime'
          8        FETCH_OBJ_R                                      ~4      'end'
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        IS_SMALLER                                       ~6      $5, !0
         12        BOOL                                             ~3      ~6
         13    > > RETURN                                                   ~3
   17    14*     > RETURN                                                   null

End of function check

Function invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NYITM
function name:  invoke
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'callback'
          1        INIT_USER_CALL                                0          'call_user_func', ~0
          2        DO_FCALL                                      0          
   20     3      > RETURN                                                   null

End of function invoke

End of class Block.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.07 ms | 1404 KiB | 19 Q