3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Task { function Task($id, $start, $end) { $this->id = $id; $this->start = $start; $this->end = $end; $this->pos = $this->start; } function execute() { if ($this->pos < $this->end) { return $this->pos++; } else return false; } } $range = range(1, 100); $ranges = array_chunk($range, 10); $tasks = array(); while (count($ranges)) { $range = array_shift($ranges); $tasks[] = new Task( count($tasks) + 1, array_shift($range), array_pop($range)); } while (count($tasks)) { foreach ($tasks as $id => $task) { if ($task->execute() === false) { printf("task %d complete\n", $task->id); unset($tasks[$id]); } else printf("task %d position %d\n", $task->id, $task->pos); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 12
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 34
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 56
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 56
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 48
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 34
Branch analysis from position: 59
Branch analysis from position: 34
Branch analysis from position: 56
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 12
Branch analysis from position: 33
Branch analysis from position: 12
filename:       /in/kPEGu
function name:  (null)
number of ops:  60
compiled vars:  !0 = $range, !1 = $ranges, !2 = $tasks, !3 = $task, !4 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 100
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
   18     5        INIT_FCALL                                               'array_chunk'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 10
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
   19    10        ASSIGN                                                   !2, <array>
   21    11      > JMP                                                      ->31
   22    12    >   INIT_FCALL                                               'array_shift'
         13        SEND_REF                                                 !1
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !0, $10
   24    16        NEW                                              $13     'Task'
   25    17        COUNT                                            ~14     !2
         18        ADD                                              ~15     ~14, 1
         19        SEND_VAL_EX                                              ~15
   26    20        INIT_FCALL                                               'array_shift'
         21        SEND_REF                                                 !0
         22        DO_ICALL                                         $16     
         23        SEND_VAR_NO_REF_EX                                       $16
   27    24        INIT_FCALL                                               'array_pop'
         25        SEND_REF                                                 !0
         26        DO_ICALL                                         $17     
         27        SEND_VAR_NO_REF_EX                                       $17
         28        DO_FCALL                                      0          
   24    29        ASSIGN_DIM                                               !2
   27    30        OP_DATA                                                  $13
   21    31    >   COUNT                                            ~19     !1
         32      > JMPNZ                                                    ~19, ->12
   30    33    > > JMP                                                      ->57
   31    34    > > FE_RESET_R                                       $20     !2, ->56
         35    > > FE_FETCH_R                                       ~21     $20, !3, ->56
         36    >   ASSIGN                                                   !4, ~21
   32    37        INIT_METHOD_CALL                                         !3, 'execute'
         38        DO_FCALL                                      0  $23     
         39        TYPE_CHECK                                    4          $23
         40      > JMPZ                                                     ~24, ->48
   33    41    >   INIT_FCALL                                               'printf'
         42        SEND_VAL                                                 'task+%25d+complete%0A'
         43        FETCH_OBJ_R                                      ~25     !3, 'id'
         44        SEND_VAL                                                 ~25
         45        DO_ICALL                                                 
   34    46        UNSET_DIM                                                !2, !4
         47      > JMP                                                      ->55
   35    48    >   INIT_FCALL                                               'printf'
         49        SEND_VAL                                                 'task+%25d+position+%25d%0A'
         50        FETCH_OBJ_R                                      ~27     !3, 'id'
         51        SEND_VAL                                                 ~27
         52        FETCH_OBJ_R                                      ~28     !3, 'pos'
         53        SEND_VAL                                                 ~28
         54        DO_ICALL                                                 
   31    55    > > JMP                                                      ->35
         56    >   FE_FREE                                                  $20
   30    57    >   COUNT                                            ~30     !2
         58      > JMPNZ                                                    ~30, ->34
   38    59    > > RETURN                                                   1

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

End of function task

Function execute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kPEGu
function name:  execute
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'pos'
          1        FETCH_OBJ_R                                      ~1      'end'
          2        IS_SMALLER                                               ~0, ~1
          3      > JMPZ                                                     ~2, ->7
   12     4    >   POST_INC_OBJ                                     ~3      'pos'
          5      > RETURN                                                   ~3
          6*       JMP                                                      ->8
   13     7    > > RETURN                                                   <false>
   14     8*     > RETURN                                                   null

End of function execute

End of class Task.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.26 ms | 1404 KiB | 23 Q