3v4l.org

run code in 300+ PHP versions simultaneously
<?php function extractRouteParameterComponents($routeParameter) { $regexPattern = "/^{(\w+)(?::(.+))?}(\?)?$/"; if (preg_match($regexPattern, $routeParameter, $matches)) { $name = $matches[1]; $type = $matches[2] ?? "[^/]"; $optional = isset($matches[3]); return [$name, $type, $optional]; } } $routeParameter = "{id:[0-9]+}"; $parameterComponents = extractRouteParameterComponents($routeParameter); var_dump($parameterComponents);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YmN6B
function name:  (null)
number of ops:  9
compiled vars:  !0 = $routeParameter, !1 = $parameterComponents
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, '%7Bid%3A%5B0-9%5D%2B%7D'
   16     1        INIT_FCALL                                               'extractrouteparametercomponents'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   18     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function extractrouteparametercomponents:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YmN6B
function name:  extractRouteParameterComponents
number of ops:  21
compiled vars:  !0 = $routeParameter, !1 = $regexPattern, !2 = $matches, !3 = $name, !4 = $type, !5 = $optional
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, '%2F%5E%7B%28%5Cw%2B%29%28%3F%3A%3A%28.%2B%29%29%3F%7D%28%5C%3F%29%3F%24%2F'
    6     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $7      
          7      > JMPZ                                                     $7, ->20
    7     8    >   FETCH_DIM_R                                      ~8      !2, 1
          9        ASSIGN                                                   !3, ~8
    8    10        FETCH_DIM_IS                                     ~10     !2, 2
         11        COALESCE                                         ~11     ~10
         12        QM_ASSIGN                                        ~11     '%5B%5E%2F%5D'
         13        ASSIGN                                                   !4, ~11
    9    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !2, 3
         15        ASSIGN                                                   !5, ~13
   11    16        INIT_ARRAY                                       ~15     !3
         17        ADD_ARRAY_ELEMENT                                ~15     !4
         18        ADD_ARRAY_ELEMENT                                ~15     !5
         19      > RETURN                                                   ~15
   13    20    > > RETURN                                                   null

End of function extractrouteparametercomponents

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.73 ms | 1390 KiB | 18 Q