3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum TaskType { case DISTANCE; case TIME; case WORKLOAD; public function visit(TaskProgressCalculator $calculator) { match($this) { TaskType::DISTANCE => $calculator->calculateForDistance(), TaskType::TIME => $calculator->calculateForTime(), TaskType::WORKLOAD => $calculator->calculateForWorkload(), }; } } class TaskProgressCalculator { public function calculateProgressFor(TaskType $task): void { $task->visit($this); } public function calculateForDistance(): void { echo "Calculating distance progress\n"; } public function calculateForTime(): void { echo "Calculating time progress\n"; } public function calculateForWorkload(): void { echo "Calculating workload progress\n"; } } $calculator = new TaskProgressCalculator; $calculator->calculateProgressFor(TaskType::WORKLOAD); $calculator->calculateProgressFor(TaskType::TIME); $calculator->calculateProgressFor(TaskType::DISTANCE);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bTCRW
function name:  (null)
number of ops:  17
compiled vars:  !0 = $calculator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'tasktype'
   42     1        NEW                                              $1      'TaskProgressCalculator'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   44     4        INIT_METHOD_CALL                                         !0, 'calculateProgressFor'
          5        FETCH_CLASS_CONSTANT                             ~4      'TaskType', 'WORKLOAD'
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0          
   45     8        INIT_METHOD_CALL                                         !0, 'calculateProgressFor'
          9        FETCH_CLASS_CONSTANT                             ~6      'TaskType', 'TIME'
         10        SEND_VAL_EX                                              ~6
         11        DO_FCALL                                      0          
   46    12        INIT_METHOD_CALL                                         !0, 'calculateProgressFor'
         13        FETCH_CLASS_CONSTANT                             ~8      'TaskType', 'DISTANCE'
         14        SEND_VAL_EX                                              ~8
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

Class TaskType:
Function visit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 197) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
filename:       /in/bTCRW
function name:  visit
number of ops:  28
compiled vars:  !0 = $calculator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        FETCH_THIS                                       ~1      
   12     2        FETCH_CLASS_CONSTANT                             ~3      'TaskType', 'DISTANCE'
          3        CASE_STRICT                                              ~1, ~3
          4      > JMPNZ                                                    ~2, ->13
   13     5    >   FETCH_CLASS_CONSTANT                             ~4      'TaskType', 'TIME'
          6        CASE_STRICT                                              ~1, ~4
          7      > JMPNZ                                                    ~2, ->17
   14     8    >   FETCH_CLASS_CONSTANT                             ~5      'TaskType', 'WORKLOAD'
          9        CASE_STRICT                                              ~1, ~5
         10      > JMPNZ                                                    ~2, ->21
         11    > > JMP                                                      ->12
         12    > > MATCH_ERROR                                              ~1
   12    13    >   INIT_METHOD_CALL                                         !0, 'calculateForDistance'
         14        DO_FCALL                                      0  $6      
         15        QM_ASSIGN                                        ~7      $6
         16      > JMP                                                      ->25
   13    17    >   INIT_METHOD_CALL                                         !0, 'calculateForTime'
         18        DO_FCALL                                      0  $8      
         19        QM_ASSIGN                                        ~7      $8
         20      > JMP                                                      ->25
   14    21    >   INIT_METHOD_CALL                                         !0, 'calculateForWorkload'
         22        DO_FCALL                                      0  $9      
         23        QM_ASSIGN                                        ~7      $9
         24      > JMP                                                      ->25
         25    >   FREE                                                     ~1
         26        FREE                                                     ~7
   16    27      > RETURN                                                   null

End of function visit

End of class TaskType.

Class TaskProgressCalculator:
Function calculateprogressfor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bTCRW
function name:  calculateProgressFor
number of ops:  6
compiled vars:  !0 = $task
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        INIT_METHOD_CALL                                         !0, 'visit'
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0          
   24     5      > RETURN                                                   null

End of function calculateprogressfor

Function calculatefordistance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bTCRW
function name:  calculateForDistance
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ECHO                                                     'Calculating+distance+progress%0A'
   29     1      > RETURN                                                   null

End of function calculatefordistance

Function calculatefortime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bTCRW
function name:  calculateForTime
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ECHO                                                     'Calculating+time+progress%0A'
   34     1      > RETURN                                                   null

End of function calculatefortime

Function calculateforworkload:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bTCRW
function name:  calculateForWorkload
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ECHO                                                     'Calculating+workload+progress%0A'
   39     1      > RETURN                                                   null

End of function calculateforworkload

End of class TaskProgressCalculator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.21 ms | 1011 KiB | 13 Q