3v4l.org

run code in 300+ PHP versions simultaneously
<?php $convertQ = function ($str) { if ('No' === $str || '0' == $str || false === $str) { return 'no'; } if ('Yes' === $str || '1' == $str || true === $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/s6u1c
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                                  '%00%7Bclosure%7D%2Fin%2Fs6u1c%3A3%240'
          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

Function %00%7Bclosure%7D%2Fin%2Fs6u1c%3A3%240:
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 = 47) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 47) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 14
Branch analysis from position: 8
Branch analysis from position: 5
filename:       /in/s6u1c
function name:  {closure}
number of ops:  28
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    > > JMPNZ_EX                                         ~1      ~1, ->8
          6    >   TYPE_CHECK                                    4  ~3      !0
          7        BOOL                                             ~1      ~3
          8    > > JMPZ                                                     ~1, ->10
    5     9    > > RETURN                                                   'no'
    8    10    >   IS_IDENTICAL                                     ~4      !0, 'Yes'
         11      > JMPNZ_EX                                         ~4      ~4, ->14
         12    >   IS_EQUAL                                         ~5      !0, '1'
         13        BOOL                                             ~4      ~5
         14    > > JMPNZ_EX                                         ~4      ~4, ->17
         15    >   TYPE_CHECK                                    8  ~6      !0
         16        BOOL                                             ~4      ~6
         17    > > JMPZ                                                     ~4, ->19
    9    18    > > RETURN                                                   'yes'
   12    19    >   IS_IDENTICAL                                             !0, 'Unsure'
         20      > JMPZ                                                     ~7, ->22
   13    21    > > RETURN                                                   'maybe'
   16    22    >   NEW                                              $8      'InvalidArgumentException'
         23        CONCAT                                           ~9      'Unaccounted+for+value+for+questionnaire+field%3A+', !0
         24        SEND_VAL_EX                                              ~9
         25        DO_FCALL                                      0          
         26      > THROW                                         0          $8
   17    27*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fs6u1c%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.78 ms | 1400 KiB | 15 Q