3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mockInputRead() { static $commands = [ 'open foo', 'close bar', 'dance with the devil in the pale moonlight', 'exit', ]; return array_unshift($commands); } function vprintfln($format, array $args = []) { vprintf($format . PHP_EOL, $args); } $handlers = [ 'open' => function ($target) { vprintfln('Opening "%s"', [$target]); return 0; }, 'close' => function ($target) { vprintfln('Closing "%s"', [$target]); return 0; }, 'exit' => function () { vprintfln('Exiting...'); return 1; }, ]; $invalidHandler = function ($command) { vprintfln('## Invalid command "%s"', [$command]); }; while (true) { list($command, $argument) = explode(' ', mockInputRead(), 1) + [null, null]; if (!empty($command)) { if (isset($handlers[$command])) { if ($handlers[$command]($argument) > 0) { break; } } else { $invalidHandler($command); } } } vprintfln('Bye!');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 10
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 10
Branch analysis from position: 40
Branch analysis from position: 10
Branch analysis from position: 39
filename:       /in/Z7alR
function name:  (null)
number of ops:  44
compiled vars:  !0 = $handlers, !1 = $invalidHandler, !2 = $command, !3 = $argument
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZ7alR%3A21%240'
   24     1        INIT_ARRAY                                       ~5      ~4, 'open'
   25     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZ7alR%3A25%241'
   28     3        ADD_ARRAY_ELEMENT                                ~5      ~6, 'close'
   29     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZ7alR%3A29%242'
   32     5        ADD_ARRAY_ELEMENT                                ~5      ~7, 'exit'
   20     6        ASSIGN                                                   !0, ~5
   34     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZ7alR%3A34%243'
          8        ASSIGN                                                   !1, ~9
   39     9      > JMP                                                      ->39
   41    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '+'
         12        INIT_FCALL                                               'mockinputread'
         13        DO_FCALL                                      0  $11     
         14        SEND_VAR                                                 $11
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $12     
         17        ADD                                              ~13     $12, <array>
         18        FETCH_LIST_R                                     $14     ~13, 0
         19        ASSIGN                                                   !2, $14
         20        FETCH_LIST_R                                     $16     ~13, 1
         21        ASSIGN                                                   !3, $16
         22        FREE                                                     ~13
   42    23        ISSET_ISEMPTY_CV                                 ~18     !2
         24        BOOL_NOT                                         ~19     ~18
         25      > JMPZ                                                     ~19, ->39
   44    26    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
         27      > JMPZ                                                     ~20, ->36
   46    28    >   FETCH_DIM_R                                      ~21     !0, !2
         29        INIT_DYNAMIC_CALL                                        ~21
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0  $22     
         32        IS_SMALLER                                               0, $22
         33      > JMPZ                                                     ~23, ->35
   48    34    > > JMP                                                      ->40
         35    > > JMP                                                      ->39
   53    36    >   INIT_DYNAMIC_CALL                                        !1
         37        SEND_VAR_EX                                              !2
         38        DO_FCALL                                      0          
   39    39    > > JMPNZ                                                    <true>, ->10
   57    40    >   INIT_FCALL                                               'vprintfln'
         41        SEND_VAL                                                 'Bye%21'
         42        DO_FCALL                                      0          
         43      > RETURN                                                   1

Function mockinputread:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7alR
function name:  mockInputRead
number of ops:  6
compiled vars:  !0 = $commands
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
   12     1        INIT_FCALL                                               'array_unshift'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   13     5*     > RETURN                                                   null

End of function mockinputread

Function vprintfln:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7alR
function name:  vprintfln
number of ops:  8
compiled vars:  !0 = $format, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   17     2        INIT_FCALL                                               'vprintf'
          3        CONCAT                                           ~2      !0, '%0A'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                                 
   18     7      > RETURN                                                   null

End of function vprintfln

Function %00%7Bclosure%7D%2Fin%2FZ7alR%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7alR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'vprintfln'
          2        SEND_VAL                                                 'Opening+%22%25s%22'
          3        INIT_ARRAY                                       ~1      !0
          4        SEND_VAL                                                 ~1
          5        DO_FCALL                                      0          
   23     6      > RETURN                                                   0
   24     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZ7alR%3A21%240

Function %00%7Bclosure%7D%2Fin%2FZ7alR%3A25%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7alR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'vprintfln'
          2        SEND_VAL                                                 'Closing+%22%25s%22'
          3        INIT_ARRAY                                       ~1      !0
          4        SEND_VAL                                                 ~1
          5        DO_FCALL                                      0          
   27     6      > RETURN                                                   0
   28     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZ7alR%3A25%241

Function %00%7Bclosure%7D%2Fin%2FZ7alR%3A29%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7alR
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'vprintfln'
          1        SEND_VAL                                                 'Exiting...'
          2        DO_FCALL                                      0          
   31     3      > RETURN                                                   1
   32     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZ7alR%3A29%242

Function %00%7Bclosure%7D%2Fin%2FZ7alR%3A34%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7alR
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $command
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   35     1        INIT_FCALL                                               'vprintfln'
          2        SEND_VAL                                                 '%23%23+Invalid+command+%22%25s%22'
          3        INIT_ARRAY                                       ~1      !0
          4        SEND_VAL                                                 ~1
          5        DO_FCALL                                      0          
   36     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZ7alR%3A34%243

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.62 ms | 1398 KiB | 25 Q