3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace CHH; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; /** * URL Map Middleware, which maps kernels to paths * * Maps kernels to path prefixes and is insertable into a stack. * * @author Christoph Hochstrasser <christoph.hochstrasser@gmail.com> */ class UrlMap implements HttpKernelInterface { protected $map = array(); protected $app; function __construct(HttpKernelInterface $app, array $map = array()) { $this->app = $app; if ($map) { $this->setMap($map); } } function setMap(array $map) { # Collect an array of all key lengths $lengths = array_map('strlen', array_keys($map)); # Sort paths by their length descending, so the most specific # paths go first. `array_multisort` sorts the lengths descending and # uses the order on the $map array_multisort($lengths, SORT_DESC, $map); $this->map = $map; } function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) { foreach ($this->map as $path => $app) { if (strpos(rawurldecode($request->getPathInfo()), $path) === 0) { $server = array( 'SCRIPT_NAME' => rtrim($path, '/') . '/' . $request->server->get('SCRIPT_NAME') ); $subRequest = $request->duplicate(null, null, null, null, null, $server); return $app->handle($subRequest, $type, $catch); } } return $this->app->handle($request, $type, $catch); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9SuWM
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'chh%5Curlmap'
   57     1      > RETURN                                                   1

Class CHH\UrlMap:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/9SuWM
function name:  __construct
number of ops:  9
compiled vars:  !0 = $app, !1 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   22     2        ASSIGN_OBJ                                               'app'
          3        OP_DATA                                                  !0
   24     4      > JMPZ                                                     !1, ->8
   25     5    >   INIT_METHOD_CALL                                         'setMap'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   27     8    > > RETURN                                                   null

End of function __construct

Function setmap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9SuWM
function name:  setMap
number of ops:  18
compiled vars:  !0 = $map, !1 = $lengths
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   32     1        INIT_NS_FCALL_BY_NAME                                    'CHH%5Carray_map'
          2        SEND_VAL_EX                                              'strlen'
          3        INIT_NS_FCALL_BY_NAME                                    'CHH%5Carray_keys'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR_NO_REF_EX                                       $2
          7        DO_FCALL                                      0  $3      
          8        ASSIGN                                                   !1, $3
   37     9        INIT_NS_FCALL_BY_NAME                                    'CHH%5Carray_multisort'
         10        SEND_VAR_EX                                              !1
         11        FETCH_CONSTANT                                   ~5      'CHH%5CSORT_DESC'
         12        SEND_VAL_EX                                              ~5
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   39    15        ASSIGN_OBJ                                               'map'
         16        OP_DATA                                                  !0
   40    17      > RETURN                                                   null

End of function setmap

Function handle:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 47
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 47
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 46
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/9SuWM
function name:  handle
number of ops:  56
compiled vars:  !0 = $request, !1 = $type, !2 = $catch, !3 = $app, !4 = $path, !5 = $server, !6 = $subRequest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
          2        RECV_INIT                                        !2      <true>
   44     3        FETCH_OBJ_R                                      ~7      'map'
          4      > FE_RESET_R                                       $8      ~7, ->47
          5    > > FE_FETCH_R                                       ~9      $8, !3, ->47
          6    >   ASSIGN                                                   !4, ~9
   45     7        INIT_NS_FCALL_BY_NAME                                    'CHH%5Cstrpos'
          8        INIT_NS_FCALL_BY_NAME                                    'CHH%5Crawurldecode'
          9        INIT_METHOD_CALL                                         !0, 'getPathInfo'
         10        DO_FCALL                                      0  $11     
         11        SEND_VAR_NO_REF_EX                                       $11
         12        DO_FCALL                                      0  $12     
         13        SEND_VAR_NO_REF_EX                                       $12
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0  $13     
         16        IS_IDENTICAL                                             $13, 0
         17      > JMPZ                                                     ~14, ->46
   47    18    >   INIT_NS_FCALL_BY_NAME                                    'CHH%5Crtrim'
         19        SEND_VAR_EX                                              !4
         20        SEND_VAL_EX                                              '%2F'
         21        DO_FCALL                                      0  $15     
         22        CONCAT                                           ~16     $15, '%2F'
         23        FETCH_OBJ_R                                      ~17     !0, 'server'
         24        INIT_METHOD_CALL                                         ~17, 'get'
         25        SEND_VAL_EX                                              'SCRIPT_NAME'
         26        DO_FCALL                                      0  $18     
         27        CONCAT                                           ~19     ~16, $18
         28        INIT_ARRAY                                       ~20     ~19, 'SCRIPT_NAME'
   46    29        ASSIGN                                                   !5, ~20
   50    30        INIT_METHOD_CALL                                         !0, 'duplicate'
         31        SEND_VAL_EX                                              null
         32        SEND_VAL_EX                                              null
         33        SEND_VAL_EX                                              null
         34        SEND_VAL_EX                                              null
         35        SEND_VAL_EX                                              null
         36        SEND_VAR_EX                                              !5
         37        DO_FCALL                                      0  $22     
         38        ASSIGN                                                   !6, $22
   51    39        INIT_METHOD_CALL                                         !3, 'handle'
         40        SEND_VAR_EX                                              !6
         41        SEND_VAR_EX                                              !1
         42        SEND_VAR_EX                                              !2
         43        DO_FCALL                                      0  $24     
         44        FE_FREE                                                  $8
         45      > RETURN                                                   $24
   44    46    > > JMP                                                      ->5
         47    >   FE_FREE                                                  $8
   55    48        FETCH_OBJ_R                                      ~25     'app'
         49        INIT_METHOD_CALL                                         ~25, 'handle'
         50        SEND_VAR_EX                                              !0
         51        SEND_VAR_EX                                              !1
         52        SEND_VAR_EX                                              !2
         53        DO_FCALL                                      0  $26     
         54      > RETURN                                                   $26
   56    55*     > RETURN                                                   null

End of function handle

End of class CHH\UrlMap.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.67 ms | 1404 KiB | 25 Q