3v4l.org

run code in 500+ PHP versions simultaneously
<?php enum ResponseType { case Informational; case Success; case Redirect; case ClientError; case ServerError; case Teapot; case Unknown; } function getErrorType(int $code) { return match (true) { $code === 418 => ResponseType::Teapot, $code >= 100 && $code < 200 => ResponseType::Informational, $code >= 200 && $code < 300 => ResponseType::Success, $code >= 300 && $code < 400 => ResponseType::Redirect, $code >= 400 && $code < 500 => ResponseType::ClientError, $code >= 500 && $code < 600 => ResponseType::ServerError, default => ResponseType::Unknown, }; } $test = [108, 200, 201, 307, 404, 418, 500, 615]; foreach ($test as $code) { var_dump($code, getErrorType($code)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/5mkYA
function name:  (null)
number of ops:  14
compiled vars:  !0 = $test, !1 = $code
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'responsetype'
   28     1        ASSIGN                                                       !0, <array>
   29     2      > FE_RESET_R                                           $3      !0, ->12
          3    > > FE_FETCH_R                                                   $3, !1, ->12
   30     4    >   INIT_FCALL                                                   'var_dump'
          5        SEND_VAR                                                     !1
          6        INIT_FCALL                                                   'geterrortype'
          7        SEND_VAR                                                     !1
          8        DO_FCALL                                          0  $4      
          9        SEND_VAR                                                     $4
         10        DO_ICALL                                                     
   29    11      > JMP                                                          ->3
         12    >   FE_FREE                                                      $3
   31    13      > RETURN                                                       1

Function geterrortype:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 38
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 41
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 44
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 47
Branch analysis from position: 28
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 50
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 32
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 26
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 20
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 14
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 8
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
filename:       /in/5mkYA
function name:  getErrorType
number of ops:  58
compiled vars:  !0 = $code
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   17     1        IS_IDENTICAL                                         ~2      !0, 418
          2        IS_IDENTICAL                                                 ~2, <true>
          3      > JMPNZ                                                        ~1, ->35
   18     4    >   IS_SMALLER_OR_EQUAL                                  ~3      100, !0
          5      > JMPZ_EX                                              ~3      ~3, ->8
          6    >   IS_SMALLER                                           ~4      !0, 200
          7        BOOL                                                 ~3      ~4
          8    >   IS_IDENTICAL                                                 ~3, <true>
          9      > JMPNZ                                                        ~1, ->38
   19    10    >   IS_SMALLER_OR_EQUAL                                  ~5      200, !0
         11      > JMPZ_EX                                              ~5      ~5, ->14
         12    >   IS_SMALLER                                           ~6      !0, 300
         13        BOOL                                                 ~5      ~6
         14    >   IS_IDENTICAL                                                 ~5, <true>
         15      > JMPNZ                                                        ~1, ->41
   20    16    >   IS_SMALLER_OR_EQUAL                                  ~7      300, !0
         17      > JMPZ_EX                                              ~7      ~7, ->20
         18    >   IS_SMALLER                                           ~8      !0, 400
         19        BOOL                                                 ~7      ~8
         20    >   IS_IDENTICAL                                                 ~7, <true>
         21      > JMPNZ                                                        ~1, ->44
   21    22    >   IS_SMALLER_OR_EQUAL                                  ~9      400, !0
         23      > JMPZ_EX                                              ~9      ~9, ->26
         24    >   IS_SMALLER                                           ~10     !0, 500
         25        BOOL                                                 ~9      ~10
         26    >   IS_IDENTICAL                                                 ~9, <true>
         27      > JMPNZ                                                        ~1, ->47
   22    28    >   IS_SMALLER_OR_EQUAL                                  ~11     500, !0
         29      > JMPZ_EX                                              ~11     ~11, ->32
         30    >   IS_SMALLER                                           ~12     !0, 600
         31        BOOL                                                 ~11     ~12
         32    >   IS_IDENTICAL                                                 ~11, <true>
         33      > JMPNZ                                                        ~1, ->50
         34    > > JMP                                                          ->53
   17    35    >   FETCH_CLASS_CONSTANT                                 ~13     'ResponseType', 'Teapot'
         36        QM_ASSIGN                                            ~14     ~13
         37      > JMP                                                          ->56
   18    38    >   FETCH_CLASS_CONSTANT                                 ~15     'ResponseType', 'Informational'
         39        QM_ASSIGN                                            ~14     ~15
         40      > JMP                                                          ->56
   19    41    >   FETCH_CLASS_CONSTANT                                 ~16     'ResponseType', 'Success'
         42        QM_ASSIGN                                            ~14     ~16
         43      > JMP                                                          ->56
   20    44    >   FETCH_CLASS_CONSTANT                                 ~17     'ResponseType', 'Redirect'
         45        QM_ASSIGN                                            ~14     ~17
         46      > JMP                                                          ->56
   21    47    >   FETCH_CLASS_CONSTANT                                 ~18     'ResponseType', 'ClientError'
         48        QM_ASSIGN                                            ~14     ~18
         49      > JMP                                                          ->56
   22    50    >   FETCH_CLASS_CONSTANT                                 ~19     'ResponseType', 'ServerError'
         51        QM_ASSIGN                                            ~14     ~19
         52      > JMP                                                          ->56
   23    53    >   FETCH_CLASS_CONSTANT                                 ~20     'ResponseType', 'Unknown'
         54        QM_ASSIGN                                            ~14     ~20
         55      > JMP                                                          ->56
         56    > > RETURN                                                       ~14
   25    57*     > RETURN                                                       null

End of function geterrortype

Class ResponseType: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
152.48 ms | 1648 KiB | 15 Q