3v4l.org

run code in 300+ PHP versions simultaneously
<?php $version="v1.2.124.0bcd4d"; $fullVersion = $version; $version = trim($version); if (null === $fullVersion) { $fullVersion = $version; } // ignore aliases and just assume the alias is required instead of the source if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) { $version = $match[1]; } // ignore build metadata if (preg_match('{^([^,\s+]+)\+[^\s]+$}', $version, $match)) { $version = $match[1]; } // match master-like branches if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { return '9999999-dev'; } if ('dev-' === strtolower(substr($version, 0, 4))) { return 'dev-'.substr($version, 4); } print_r($fullVersion); // match classical versioning if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?$}i', $version, $matches)) { $version = $matches[1] .(!empty($matches[2]) ? $matches[2] : '.0') .(!empty($matches[3]) ? $matches[3] : '.0') .(!empty($matches[4]) ? $matches[4] : '.0'); $index = 5; } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)$}i', $version, $matches)) { // match date-based versioning $version = preg_replace('{\D}', '-', $matches[1]); $index = 2; } elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?$}i', $version, $matches)) { $version = $matches[1] .(!empty($matches[2]) ? $matches[2] : '.0') .(!empty($matches[3]) ? $matches[3] : '.0') .(!empty($matches[4]) ? $matches[4] : '.0'); $index = 5; } // add version modifiers if a version was matched if (isset($index)) { if (!empty($matches[$index])) { if ('stable' === $matches[$index]) { return $version; } $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index+1]) ? $matches[$index+1] : ''); } if (!empty($matches[$index+2])) { $version .= '-dev'; } return $version; } // match dev branches if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) { try { return $this->normalizeBranch($match[1]); } catch (\Exception $e) { } } $extraMessage = ''; if (preg_match('{ +as +'.preg_quote($version).'$}', $fullVersion)) { $extraMessage = ' in "'.$fullVersion.'", the alias must be an exact version'; } elseif (preg_match('{^'.preg_quote($version).' +as +}', $fullVersion)) { $extraMessage = ' in "'.$fullVersion.'", the alias source must be an exact version, if it is a branch name you should prefix it with dev-'; } throw new \UnexpectedValueException('Invalid version string "'.$version.'"'.$extraMessage);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 47
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 84
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 63
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 71
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 79
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 80
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 165
Branch analysis from position: 134
2 jumps found. (Code = 43) Position 1 = 137, Position 2 = 159
Branch analysis from position: 137
2 jumps found. (Code = 43) Position 1 = 140, Position 2 = 141
Branch analysis from position: 140
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 141
2 jumps found. (Code = 43) Position 1 = 152, Position 2 = 156
Branch analysis from position: 152
1 jumps found. (Code = 42) Position 1 = 157
Branch analysis from position: 157
2 jumps found. (Code = 43) Position 1 = 163, Position 2 = 164
Branch analysis from position: 163
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 164
Branch analysis from position: 156
2 jumps found. (Code = 43) Position 1 = 163, Position 2 = 164
Branch analysis from position: 163
Branch analysis from position: 164
Branch analysis from position: 159
Branch analysis from position: 165
2 jumps found. (Code = 43) Position 1 = 171, Position 2 = 180
Branch analysis from position: 171
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 180
2 jumps found. (Code = 43) Position 1 = 191, Position 2 = 195
Branch analysis from position: 191
1 jumps found. (Code = 42) Position 1 = 208
Branch analysis from position: 208
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 195
2 jumps found. (Code = 43) Position 1 = 205, Position 2 = 208
Branch analysis from position: 205
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 208
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 79
Branch analysis from position: 76
Branch analysis from position: 79
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 71
Branch analysis from position: 68
Branch analysis from position: 71
Branch analysis from position: 84
2 jumps found. (Code = 43) Position 1 = 90, Position 2 = 99
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
Branch analysis from position: 99
2 jumps found. (Code = 43) Position 1 = 105, Position 2 = 132
Branch analysis from position: 105
2 jumps found. (Code = 43) Position 1 = 109, Position 2 = 112
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
2 jumps found. (Code = 43) Position 1 = 117, Position 2 = 120
Branch analysis from position: 117
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
2 jumps found. (Code = 43) Position 1 = 125, Position 2 = 128
Branch analysis from position: 125
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 165
Branch analysis from position: 134
Branch analysis from position: 165
Branch analysis from position: 128
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 165
Branch analysis from position: 134
Branch analysis from position: 165
Branch analysis from position: 120
2 jumps found. (Code = 43) Position 1 = 125, Position 2 = 128
Branch analysis from position: 125
Branch analysis from position: 128
Branch analysis from position: 112
2 jumps found. (Code = 43) Position 1 = 117, Position 2 = 120
Branch analysis from position: 117
Branch analysis from position: 120
Branch analysis from position: 132
Branch analysis from position: 25
Branch analysis from position: 17
Branch analysis from position: 9
Found catch point at position: 179
Branch analysis from position: 179
2 jumps found. (Code = 107) Position 1 = 180, Position 2 = -2
Branch analysis from position: 180
filename:       /in/dhVnE
function name:  (null)
number of ops:  216
compiled vars:  !0 = $version, !1 = $fullVersion, !2 = $match, !3 = $matches, !4 = $index, !5 = $e, !6 = $extraMessage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'v1.2.124.0bcd4d'
    4     1        ASSIGN                                                   !1, !0
    6     2        INIT_FCALL                                               'trim'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !0, $9
    7     6        TYPE_CHECK                                    2          !1
          7      > JMPZ                                                     ~11, ->9
    8     8    >   ASSIGN                                                   !1, !0
   11     9    >   INIT_FCALL                                               'preg_match'
         10        SEND_VAL                                                 '%7B%5E%28%5B%5E%2C%5Cs%5D%2B%29+%2Bas+%2B%28%5B%5E%2C%5Cs%5D%2B%29%24%7D'
         11        SEND_VAR                                                 !0
         12        SEND_REF                                                 !2
         13        DO_ICALL                                         $13     
         14      > JMPZ                                                     $13, ->17
   12    15    >   FETCH_DIM_R                                      ~14     !2, 1
         16        ASSIGN                                                   !0, ~14
   15    17    >   INIT_FCALL                                               'preg_match'
         18        SEND_VAL                                                 '%7B%5E%28%5B%5E%2C%5Cs%2B%5D%2B%29%5C%2B%5B%5E%5Cs%5D%2B%24%7D'
         19        SEND_VAR                                                 !0
         20        SEND_REF                                                 !2
         21        DO_ICALL                                         $16     
         22      > JMPZ                                                     $16, ->25
   16    23    >   FETCH_DIM_R                                      ~17     !2, 1
         24        ASSIGN                                                   !0, ~17
   19    25    >   INIT_FCALL                                               'preg_match'
         26        SEND_VAL                                                 '%7B%5E%28%3F%3Adev-%29%3F%28%3F%3Amaster%7Ctrunk%7Cdefault%29%24%7Di'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $19     
         29      > JMPZ                                                     $19, ->31
   20    30    > > RETURN                                                   '9999999-dev'
   22    31    >   INIT_FCALL                                               'strtolower'
         32        INIT_FCALL                                               'substr'
         33        SEND_VAR                                                 !0
         34        SEND_VAL                                                 0
         35        SEND_VAL                                                 4
         36        DO_ICALL                                         $20     
         37        SEND_VAR                                                 $20
         38        DO_ICALL                                         $21     
         39        IS_IDENTICAL                                             $21, 'dev-'
         40      > JMPZ                                                     ~22, ->47
   23    41    >   INIT_FCALL                                               'substr'
         42        SEND_VAR                                                 !0
         43        SEND_VAL                                                 4
         44        DO_ICALL                                         $23     
         45        CONCAT                                           ~24     'dev-', $23
         46      > RETURN                                                   ~24
   26    47    >   INIT_FCALL                                               'print_r'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                                 
   30    50        INIT_FCALL                                               'preg_match'
         51        SEND_VAL                                                 '%7B%5Ev%3F%28%5Cd%7B1%2C3%7D%29%28%5C.%5Cd%2B%29%3F%28%5C.%5Cd%2B%29%3F%28%5C.%5Cd%2B%29%3F%24%7Di'
         52        SEND_VAR                                                 !0
         53        SEND_REF                                                 !3
         54        DO_ICALL                                         $26     
         55      > JMPZ                                                     $26, ->84
   31    56    >   FETCH_DIM_R                                      ~27     !3, 1
   32    57        ISSET_ISEMPTY_DIM_OBJ                         1  ~28     !3, 2
         58        BOOL_NOT                                         ~29     ~28
         59      > JMPZ                                                     ~29, ->63
         60    >   FETCH_DIM_R                                      ~30     !3, 2
         61        QM_ASSIGN                                        ~31     ~30
         62      > JMP                                                      ->64
         63    >   QM_ASSIGN                                        ~31     '.0'
         64    >   CONCAT                                           ~32     ~27, ~31
   33    65        ISSET_ISEMPTY_DIM_OBJ                         1  ~33     !3, 3
         66        BOOL_NOT                                         ~34     ~33
         67      > JMPZ                                                     ~34, ->71
         68    >   FETCH_DIM_R                                      ~35     !3, 3
         69        QM_ASSIGN                                        ~36     ~35
         70      > JMP                                                      ->72
         71    >   QM_ASSIGN                                        ~36     '.0'
         72    >   CONCAT                                           ~37     ~32, ~36
   34    73        ISSET_ISEMPTY_DIM_OBJ                         1  ~38     !3, 4
         74        BOOL_NOT                                         ~39     ~38
         75      > JMPZ                                                     ~39, ->79
         76    >   FETCH_DIM_R                                      ~40     !3, 4
         77        QM_ASSIGN                                        ~41     ~40
         78      > JMP                                                      ->80
         79    >   QM_ASSIGN                                        ~41     '.0'
         80    >   CONCAT                                           ~42     ~37, ~41
   31    81        ASSIGN                                                   !0, ~42
   35    82        ASSIGN                                                   !4, 5
         83      > JMP                                                      ->132
   36    84    >   INIT_FCALL                                               'preg_match'
         85        SEND_VAL                                                 '%7B%5Ev%3F%28%5Cd%7B4%7D%28%3F%3A%5B.%3A-%5D%3F%5Cd%7B2%7D%29%7B1%2C6%7D%28%3F%3A%5B.%3A-%5D%3F%5Cd%7B1%2C3%7D%29%3F%29%24%7Di'
         86        SEND_VAR                                                 !0
         87        SEND_REF                                                 !3
         88        DO_ICALL                                         $45     
         89      > JMPZ                                                     $45, ->99
   37    90    >   INIT_FCALL                                               'preg_replace'
         91        SEND_VAL                                                 '%7B%5CD%7D'
         92        SEND_VAL                                                 '-'
         93        FETCH_DIM_R                                      ~46     !3, 1
         94        SEND_VAL                                                 ~46
         95        DO_ICALL                                         $47     
         96        ASSIGN                                                   !0, $47
   38    97        ASSIGN                                                   !4, 2
         98      > JMP                                                      ->132
   39    99    >   INIT_FCALL                                               'preg_match'
        100        SEND_VAL                                                 '%7B%5Ev%3F%28%5Cd%7B4%2C%7D%29%28%5C.%5Cd%2B%29%3F%28%5C.%5Cd%2B%29%3F%28%5C.%5Cd%2B%29%3F%24%7Di'
        101        SEND_VAR                                                 !0
        102        SEND_REF                                                 !3
        103        DO_ICALL                                         $50     
        104      > JMPZ                                                     $50, ->132
   40   105    >   FETCH_DIM_R                                      ~51     !3, 1
   41   106        ISSET_ISEMPTY_DIM_OBJ                         1  ~52     !3, 2
        107        BOOL_NOT                                         ~53     ~52
        108      > JMPZ                                                     ~53, ->112
        109    >   FETCH_DIM_R                                      ~54     !3, 2
        110        QM_ASSIGN                                        ~55     ~54
        111      > JMP                                                      ->113
        112    >   QM_ASSIGN                                        ~55     '.0'
        113    >   CONCAT                                           ~56     ~51, ~55
   42   114        ISSET_ISEMPTY_DIM_OBJ                         1  ~57     !3, 3
        115        BOOL_NOT                                         ~58     ~57
        116      > JMPZ                                                     ~58, ->120
        117    >   FETCH_DIM_R                                      ~59     !3, 3
        118        QM_ASSIGN                                        ~60     ~59
        119      > JMP                                                      ->121
        120    >   QM_ASSIGN                                        ~60     '.0'
        121    >   CONCAT                                           ~61     ~56, ~60
   43   122        ISSET_ISEMPTY_DIM_OBJ                         1  ~62     !3, 4
        123        BOOL_NOT                                         ~63     ~62
        124      > JMPZ                                                     ~63, ->128
        125    >   FETCH_DIM_R                                      ~64     !3, 4
        126        QM_ASSIGN                                        ~65     ~64
        127      > JMP                                                      ->129
        128    >   QM_ASSIGN                                        ~65     '.0'
        129    >   CONCAT                                           ~66     ~61, ~65
   40   130        ASSIGN                                                   !0, ~66
   44   131        ASSIGN                                                   !4, 5
   49   132    >   ISSET_ISEMPTY_CV                                         !4
        133      > JMPZ                                                     ~69, ->165
   50   134    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~70     !3, !4
        135        BOOL_NOT                                         ~71     ~70
        136      > JMPZ                                                     ~71, ->159
   51   137    >   FETCH_DIM_R                                      ~72     !3, !4
        138        IS_IDENTICAL                                             ~72, 'stable'
        139      > JMPZ                                                     ~73, ->141
   52   140    > > RETURN                                                   !0
   54   141    >   FETCH_THIS                                       $74     
        142        INIT_METHOD_CALL                                         $74, 'expandStability'
        143        CHECK_FUNC_ARG                                           
        144        FETCH_DIM_FUNC_ARG                               $75     !3, !4
        145        SEND_FUNC_ARG                                            $75
        146        DO_FCALL                                      0  $76     
        147        CONCAT                                           ~77     '-', $76
        148        ADD                                              ~78     !4, 1
        149        ISSET_ISEMPTY_DIM_OBJ                         1  ~79     !3, ~78
        150        BOOL_NOT                                         ~80     ~79
        151      > JMPZ                                                     ~80, ->156
        152    >   ADD                                              ~81     !4, 1
        153        FETCH_DIM_R                                      ~82     !3, ~81
        154        QM_ASSIGN                                        ~83     ~82
        155      > JMP                                                      ->157
        156    >   QM_ASSIGN                                        ~83     ''
        157    >   CONCAT                                           ~84     ~77, ~83
        158        ASSIGN_OP                                     8          !0, ~84
   56   159    >   ADD                                              ~86     !4, 2
        160        ISSET_ISEMPTY_DIM_OBJ                         1  ~87     !3, ~86
        161        BOOL_NOT                                         ~88     ~87
        162      > JMPZ                                                     ~88, ->164
   57   163    >   ASSIGN_OP                                     8          !0, '-dev'
   59   164    > > RETURN                                                   !0
   62   165    >   INIT_FCALL                                               'preg_match'
        166        SEND_VAL                                                 '%7B%28.%2A%3F%29%5B.-%5D%3Fdev%24%7Di'
        167        SEND_VAR                                                 !0
        168        SEND_REF                                                 !2
        169        DO_ICALL                                         $90     
        170      > JMPZ                                                     $90, ->180
   64   171    >   FETCH_THIS                                       $91     
        172        INIT_METHOD_CALL                                         $91, 'normalizeBranch'
        173        CHECK_FUNC_ARG                                           
        174        FETCH_DIM_FUNC_ARG                               $92     !2, 1
        175        SEND_FUNC_ARG                                            $92
        176        DO_FCALL                                      0  $93     
        177      > RETURN                                                   $93
        178*       JMP                                                      ->180
   65   179  E > > CATCH                                       last         'Exception'
   68   180    >   ASSIGN                                                   !6, ''
   69   181        INIT_FCALL                                               'preg_match'
        182        INIT_FCALL                                               'preg_quote'
        183        SEND_VAR                                                 !0
        184        DO_ICALL                                         $95     
        185        CONCAT                                           ~96     '%7B+%2Bas+%2B', $95
        186        CONCAT                                           ~97     ~96, '%24%7D'
        187        SEND_VAL                                                 ~97
        188        SEND_VAR                                                 !1
        189        DO_ICALL                                         $98     
        190      > JMPZ                                                     $98, ->195
   70   191    >   CONCAT                                           ~99     '+in+%22', !1
        192        CONCAT                                           ~100    ~99, '%22%2C+the+alias+must+be+an+exact+version'
        193        ASSIGN                                                   !6, ~100
        194      > JMP                                                      ->208
   71   195    >   INIT_FCALL                                               'preg_match'
        196        INIT_FCALL                                               'preg_quote'
        197        SEND_VAR                                                 !0
        198        DO_ICALL                                         $102    
        199        CONCAT                                           ~103    '%7B%5E', $102
        200        CONCAT                                           ~104    ~103, '+%2Bas+%2B%7D'
        201        SEND_VAL                                                 ~104
        202        SEND_VAR                                                 !1
        203        DO_ICALL                                         $105    
        204      > JMPZ                                                     $105, ->208
   72   205    >   CONCAT                                           ~106    '+in+%22', !1
        206        CONCAT                                           ~107    ~106, '%22%2C+the+alias+source+must+be+an+exact+version%2C+if+it+is+a+branch+name+you+should+prefix+it+with+dev-'
        207        ASSIGN                                                   !6, ~107
   75   208    >   NEW                                              $109    'UnexpectedValueException'
        209        CONCAT                                           ~110    'Invalid+version+string+%22', !0
        210        CONCAT                                           ~111    ~110, '%22'
        211        CONCAT                                           ~112    ~111, !6
        212        SEND_VAL_EX                                              ~112
        213        DO_FCALL                                      0          
        214      > THROW                                         0          $109
        215*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.68 ms | 1421 KiB | 27 Q