3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Args { public $credsfile; public $max_query_size_bytes = (1 * 1024 * 1024) - 50; public $table; } function getArgs(): Args { global $argv; $ret = new Args(); $required = []; /** @var mixed $unused */ foreach ($ret as $key => $unused) { $required[] = $key . ":"; } $extracted_args = getopt("", $required); foreach ($ret as $key => &$val) { if (empty($extracted_args[$key])) { if (empty($val)) { fwrite(STDERR, "error: missing required argument: {$key}\n"); die(1); } } else { $ret->$key = $extracted_args[$key]; } } $argsCopy = $argv; unset($argsCopy[0]); foreach ($argsCopy as $arg) { // what the hell did i just write? if (! isset($ret->{ explode("=", substr($arg, strlen('--')), 2)[0]})) { fwrite(STDERR, "error: unrecognized argument: {$arg}\n"); die(1); } } return $ret; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Xs61G
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E > > RETURN                                                       1

Function getargs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
2 jumps found. (Code = 125) Position 1 = 19, Position 2 = 41
Branch analysis from position: 19
2 jumps found. (Code = 126) Position 1 = 20, Position 2 = 41
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 37
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 68
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 68
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 67
Branch analysis from position: 56
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Branch analysis from position: 41
Branch analysis from position: 12
filename:       /in/Xs61G
function name:  getArgs
number of ops:  73
compiled vars:  !0 = $argv, !1 = $ret, !2 = $required, !3 = $unused, !4 = $key, !5 = $extracted_args, !6 = $val, !7 = $argsCopy, !8 = $arg
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   BIND_GLOBAL                                                  !0, 'argv'
   16     1        NEW                                                  $9      'Args'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $9
   17     4        ASSIGN                                                       !2, <array>
   19     5      > FE_RESET_R                                           $13     !1, ->12
          6    > > FE_FETCH_R                                           ~14     $13, !3, ->12
          7    >   ASSIGN                                                       !4, ~14
   20     8        CONCAT                                               ~17     !4, '%3A'
          9        ASSIGN_DIM                                                   !2
         10        OP_DATA                                                      ~17
   19    11      > JMP                                                          ->6
         12    >   FE_FREE                                                      $13
   22    13        INIT_FCALL                                                   'getopt'
         14        SEND_VAL                                                     ''
         15        SEND_VAR                                                     !2
         16        DO_ICALL                                             $18     
         17        ASSIGN                                                       !5, $18
   24    18      > FE_RESET_RW                                          $20     !1, ->41
         19    > > FE_FETCH_RW                                          ~21     $20, !6, ->41
         20    >   ASSIGN                                                       !4, ~21
   25    21        ISSET_ISEMPTY_DIM_OBJ                             1          !5, !4
         22      > JMPZ                                                         ~23, ->37
   26    23    >   ISSET_ISEMPTY_CV                                             !6
         24      > JMPZ                                                         ~24, ->36
   27    25    >   INIT_FCALL                                                   'fwrite'
         26        FETCH_CONSTANT                                       ~25     'STDERR'
         27        SEND_VAL                                                     ~25
         28        ROPE_INIT                                         3  ~27     'error%3A+missing+required+argument%3A+'
         29        ROPE_ADD                                          1  ~27     ~27, !4
         30        ROPE_END                                          2  ~26     ~27, '%0A'
         31        SEND_VAL                                                     ~26
         32        DO_ICALL                                                     
   28    33      > INIT_FCALL                                                   'exit'
         34*       SEND_VAL                                                     1
         35*       DO_ICALL                                                     
   25    36    > > JMP                                                          ->40
   31    37    >   FETCH_DIM_R                                          ~32     !5, !4
         38        ASSIGN_OBJ                                                   !1, !4
         39        OP_DATA                                                      ~32
   24    40    > > JMP                                                          ->19
         41    >   FE_FREE                                                      $20
   34    42        ASSIGN                                                       !7, !0
   35    43        UNSET_DIM                                                    !7, 0
   36    44      > FE_RESET_R                                           $34     !7, ->68
         45    > > FE_FETCH_R                                                   $34, !8, ->68
   38    46    >   INIT_FCALL                                                   'explode'
         47        SEND_VAL                                                     '%3D'
         48        FRAMELESS_ICALL_2                substr              ~35     !8, 2
         49        SEND_VAL                                                     ~35
         50        SEND_VAL                                                     2
         51        DO_ICALL                                             $36     
         52        FETCH_DIM_R                                          ~37     $36, 0
         53        ISSET_ISEMPTY_PROP_OBJ                               ~38     !1, ~37
         54        BOOL_NOT                                             ~39     ~38
         55      > JMPZ                                                         ~39, ->67
   39    56    >   INIT_FCALL                                                   'fwrite'
         57        FETCH_CONSTANT                                       ~40     'STDERR'
         58        SEND_VAL                                                     ~40
         59        ROPE_INIT                                         3  ~42     'error%3A+unrecognized+argument%3A+'
         60        ROPE_ADD                                          1  ~42     ~42, !8
         61        ROPE_END                                          2  ~41     ~42, '%0A'
         62        SEND_VAL                                                     ~41
         63        DO_ICALL                                                     
   40    64      > INIT_FCALL                                                   'exit'
         65*       SEND_VAL                                                     1
         66*       DO_ICALL                                                     
   36    67    > > JMP                                                          ->45
         68    >   FE_FREE                                                      $34
   43    69        VERIFY_RETURN_TYPE                                           !1
         70      > RETURN                                                       !1
   44    71*       VERIFY_RETURN_TYPE                                           
         72*     > RETURN                                                       null

End of function getargs

Class Args: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
131.13 ms | 498 KiB | 13 Q