3v4l.org

run code in 300+ PHP versions simultaneously
<?php $convertQ = function ($str) { if ('No' === $str || '0' == $str) { return 'no'; } if ('Yes' === $str || '1' == $str) { return 'yes'; } if ('Unsure' === $str) { return 'maybe'; } throw new \InvalidArgumentException('Unaccounted for value for questionnaire field: ' . $str); }; var_dump($convertQ(0)); // expect 'no', get 'no' var_dump($convertQ('No')); // expect 'no', get 'no' var_dump($convertQ(1)); // expect 'yes', get 'yes' var_dump($convertQ('Yes')); // expect 'yes', get 'yes' var_dump($convertQ('Unsure')); // expect 'maybe', get 'maybe' var_dump($convertQ('a')); // expect thrown error, get error thrown
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p6901
function name:  (null)
number of ops:  39
compiled vars:  !0 = $convertQ
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        ASSIGN                                                   !0, ~1
   19     2        INIT_FCALL                                               'var_dump'
          3        INIT_DYNAMIC_CALL                                        !0
          4        SEND_VAL_EX                                              0
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   20     8        INIT_FCALL                                               'var_dump'
          9        INIT_DYNAMIC_CALL                                        !0
         10        SEND_VAL_EX                                              'No'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   21    14        INIT_FCALL                                               'var_dump'
         15        INIT_DYNAMIC_CALL                                        !0
         16        SEND_VAL_EX                                              1
         17        DO_FCALL                                      0  $7      
         18        SEND_VAR                                                 $7
         19        DO_ICALL                                                 
   22    20        INIT_FCALL                                               'var_dump'
         21        INIT_DYNAMIC_CALL                                        !0
         22        SEND_VAL_EX                                              'Yes'
         23        DO_FCALL                                      0  $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
   23    26        INIT_FCALL                                               'var_dump'
         27        INIT_DYNAMIC_CALL                                        !0
         28        SEND_VAL_EX                                              'Unsure'
         29        DO_FCALL                                      0  $11     
         30        SEND_VAR                                                 $11
         31        DO_ICALL                                                 
   24    32        INIT_FCALL                                               'var_dump'
         33        INIT_DYNAMIC_CALL                                        !0
         34        SEND_VAL_EX                                              'a'
         35        DO_FCALL                                      0  $13     
         36        SEND_VAR                                                 $13
         37        DO_ICALL                                                 
         38      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 5
filename:       /in/p6901
function name:  {closure}
number of ops:  22
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        IS_IDENTICAL                                     ~1      !0, 'No'
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   IS_EQUAL                                         ~2      !0, '0'
          4        BOOL                                             ~1      ~2
          5    > > JMPZ                                                     ~1, ->7
    5     6    > > RETURN                                                   'no'
    8     7    >   IS_IDENTICAL                                     ~3      !0, 'Yes'
          8      > JMPNZ_EX                                         ~3      ~3, ->11
          9    >   IS_EQUAL                                         ~4      !0, '1'
         10        BOOL                                             ~3      ~4
         11    > > JMPZ                                                     ~3, ->13
    9    12    > > RETURN                                                   'yes'
   12    13    >   IS_IDENTICAL                                             !0, 'Unsure'
         14      > JMPZ                                                     ~5, ->16
   13    15    > > RETURN                                                   'maybe'
   16    16    >   NEW                                              $6      'InvalidArgumentException'
         17        CONCAT                                           ~7      'Unaccounted+for+value+for+questionnaire+field%3A+', !0
         18        SEND_VAL_EX                                              ~7
         19        DO_FCALL                                      0          
         20      > THROW                                         0          $6
   17    21*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.19 ms | 1448 KiB | 14 Q