3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Vagabond\Http; class Request{ private $url; private $method; private $sources = []; public function __construct($url, $method){ $this->url = $url; $this->method = $method; } public function setParameterProvider($name, callable $provider){ $this->sources[$name] = $provider; } public function setParameterSource($name, array $data){ $this->sources[$name] = $data; } public function get($source, $name, $default = null){ if (isset($this->sources[$source]) && !is_array($this->sources[$source])){ $this->sources[$source] = call_user_func($this->sources[$source]); } return (isset($this->sources[$source][$name]))?$this->sources[$source][$name]:$default; } public function getUrl(){ return $this->url; } public function getMethod(){ return $this->method; } public static function getPhpDefaultRequest(){ $request = new Request($_SERVER["REQUEST_URI"], $_SERVER["REQUEST_METHOD"]); $request->setParameterSource("get", $_GET); $request->setParameterSource("post", $_POST); $request->setParameterSource("files", $_FILES); $request->setParameterProvider("session", function(){ return $_SESSION; }); $request->setParameterSource("env", $_ENV); $request->setParameterSource("cookie", $_COOKIE); $request->setParameterSource("server", $_SERVER); } } $request = \Vagabond\Http\Request::getPhpDefaultRequest(); $request->setParameterProvider("post", function(){ if ($_SERVER["CONTENT_TYPE"] == "application/json"){ return json_decode(file_get_contents("php://input"), true); } else { return $_POST; } }); $action = $request->get("get", "action"); $username = $request->get("post", "username"); $password = $request->get("post", "password"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  (null)
number of ops:  24
compiled vars:  !0 = $request, !1 = $action, !2 = $username, !3 = $password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   INIT_STATIC_METHOD_CALL                                  'Vagabond%5CHttp%5CRequest', 'getPhpDefaultRequest'
          1        DO_FCALL                                      0  $4      
          2        ASSIGN                                                   !0, $4
   49     3        INIT_METHOD_CALL                                         !0, 'setParameterProvider'
          4        SEND_VAL_EX                                              'post'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00vagabond%5Chttp%5C%7Bclosure%7D%2Fin%2FjsVnM%3A49%241'
   55     6        SEND_VAL_EX                                              ~6
          7        DO_FCALL                                      0          
   56     8        INIT_METHOD_CALL                                         !0, 'get'
          9        SEND_VAL_EX                                              'get'
         10        SEND_VAL_EX                                              'action'
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !1, $8
   57    13        INIT_METHOD_CALL                                         !0, 'get'
         14        SEND_VAL_EX                                              'post'
         15        SEND_VAL_EX                                              'username'
         16        DO_FCALL                                      0  $10     
         17        ASSIGN                                                   !2, $10
   58    18        INIT_METHOD_CALL                                         !0, 'get'
         19        SEND_VAL_EX                                              'post'
         20        SEND_VAL_EX                                              'password'
         21        DO_FCALL                                      0  $12     
         22        ASSIGN                                                   !3, $12
   59    23      > RETURN                                                   1

Function %00vagabond%5Chttp%5C%7Bclosure%7D%2Fin%2FjsVnM%3A40%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  Vagabond\Http\{closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_R                      global              ~0      '_SESSION'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function %00vagabond%5Chttp%5C%7Bclosure%7D%2Fin%2FjsVnM%3A40%240

Function %00vagabond%5Chttp%5C%7Bclosure%7D%2Fin%2FjsVnM%3A49%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  Vagabond\Http\{closure}
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_R                      global              ~0      '_SERVER'
          1        FETCH_DIM_R                                      ~1      ~0, 'CONTENT_TYPE'
          2        IS_EQUAL                                                 ~1, 'application%2Fjson'
          3      > JMPZ                                                     ~2, ->13
   51     4    >   INIT_NS_FCALL_BY_NAME                                    'Vagabond%5CHttp%5Cjson_decode'
          5        INIT_NS_FCALL_BY_NAME                                    'Vagabond%5CHttp%5Cfile_get_contents'
          6        SEND_VAL_EX                                              'php%3A%2F%2Finput'
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR_NO_REF_EX                                       $3
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0  $4      
         11      > RETURN                                                   $4
         12*       JMP                                                      ->15
   53    13    >   FETCH_R                      global              ~5      '_POST'
         14      > RETURN                                                   ~5
   55    15*     > RETURN                                                   null

End of function %00vagabond%5Chttp%5C%7Bclosure%7D%2Fin%2FjsVnM%3A49%241

Class Vagabond\Http\Request:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  __construct
number of ops:  7
compiled vars:  !0 = $url, !1 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN_OBJ                                               'url'
          3        OP_DATA                                                  !0
   12     4        ASSIGN_OBJ                                               'method'
          5        OP_DATA                                                  !1
   13     6      > RETURN                                                   null

End of function __construct

Function setparameterprovider:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  setParameterProvider
number of ops:  6
compiled vars:  !0 = $name, !1 = $provider
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        FETCH_OBJ_W                                      $2      'sources'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   16     5      > RETURN                                                   null

End of function setparameterprovider

Function setparametersource:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  setParameterSource
number of ops:  6
compiled vars:  !0 = $name, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        FETCH_OBJ_W                                      $2      'sources'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   19     5      > RETURN                                                   null

End of function setparametersource

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 14
filename:       /in/jsVnM
function name:  get
number of ops:  36
compiled vars:  !0 = $source, !1 = $name, !2 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   21     3        FETCH_OBJ_IS                                     ~3      'sources'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      ~3, !0
          5      > JMPZ_EX                                          ~4      ~4, ->14
          6    >   INIT_NS_FCALL_BY_NAME                                    'Vagabond%5CHttp%5Cis_array'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_OBJ_FUNC_ARG                               $5      'sources'
          9        FETCH_DIM_FUNC_ARG                               $6      $5, !0
         10        SEND_FUNC_ARG                                            $6
         11        DO_FCALL                                      0  $7      
         12        BOOL_NOT                                         ~8      $7
         13        BOOL                                             ~4      ~8
         14    > > JMPZ                                                     ~4, ->24
   22    15    >   INIT_NS_FCALL_BY_NAME                                    'Vagabond%5CHttp%5Ccall_user_func'
         16        CHECK_FUNC_ARG                                           
         17        FETCH_OBJ_FUNC_ARG                               $11     'sources'
         18        FETCH_DIM_FUNC_ARG                               $12     $11, !0
         19        SEND_FUNC_ARG                                            $12
         20        DO_FCALL                                      0  $13     
         21        FETCH_OBJ_W                                      $9      'sources'
         22        ASSIGN_DIM                                               $9, !0
         23        OP_DATA                                                  $13
   24    24    >   FETCH_OBJ_IS                                     ~14     'sources'
         25        FETCH_DIM_IS                                     ~15     ~14, !0
         26        ISSET_ISEMPTY_DIM_OBJ                         0          ~15, !1
         27      > JMPZ                                                     ~16, ->33
         28    >   FETCH_OBJ_R                                      ~17     'sources'
         29        FETCH_DIM_R                                      ~18     ~17, !0
         30        FETCH_DIM_R                                      ~19     ~18, !1
         31        QM_ASSIGN                                        ~20     ~19
         32      > JMP                                                      ->34
         33    >   QM_ASSIGN                                        ~20     !2
         34    > > RETURN                                                   ~20
   25    35*     > RETURN                                                   null

End of function get

Function geturl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  getUrl
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'url'
          1      > RETURN                                                   ~0
   29     2*     > RETURN                                                   null

End of function geturl

Function getmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  getMethod
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   FETCH_OBJ_R                                      ~0      'method'
          1      > RETURN                                                   ~0
   33     2*     > RETURN                                                   null

End of function getmethod

Function getphpdefaultrequest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsVnM
function name:  getPhpDefaultRequest
number of ops:  53
compiled vars:  !0 = $request
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $1      'Vagabond%5CHttp%5CRequest'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_FUNC_ARG               global              $2      '_SERVER'
          3        FETCH_DIM_FUNC_ARG                               $3      $2, 'REQUEST_URI'
          4        SEND_FUNC_ARG                                            $3
          5        CHECK_FUNC_ARG                                           
          6        FETCH_FUNC_ARG               global              $4      '_SERVER'
          7        FETCH_DIM_FUNC_ARG                               $5      $4, 'REQUEST_METHOD'
          8        SEND_FUNC_ARG                                            $5
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $1
   37    11        INIT_METHOD_CALL                                         !0, 'setParameterSource'
         12        SEND_VAL_EX                                              'get'
         13        CHECK_FUNC_ARG                                           
         14        FETCH_FUNC_ARG               global              $8      '_GET'
         15        SEND_FUNC_ARG                                            $8
         16        DO_FCALL                                      0          
   38    17        INIT_METHOD_CALL                                         !0, 'setParameterSource'
         18        SEND_VAL_EX                                              'post'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_FUNC_ARG               global              $10     '_POST'
         21        SEND_FUNC_ARG                                            $10
         22        DO_FCALL                                      0          
   39    23        INIT_METHOD_CALL                                         !0, 'setParameterSource'
         24        SEND_VAL_EX                                              'files'
         25        CHECK_FUNC_ARG                                           
         26        FETCH_FUNC_ARG               global              $12     '_FILES'
         27        SEND_FUNC_ARG                                            $12
         28        DO_FCALL                                      0          
   40    29        INIT_METHOD_CALL                                         !0, 'setParameterProvider'
         30        SEND_VAL_EX                                              'session'
         31        DECLARE_LAMBDA_FUNCTION                                  '%00vagabond%5Chttp%5C%7Bclosure%7D%2Fin%2FjsVnM%3A40%240'
         32        SEND_VAL_EX                                              ~14
         33        DO_FCALL                                      0          
   41    34        INIT_METHOD_CALL                                         !0, 'setParameterSource'
         35        SEND_VAL_EX                                              'env'
         36        CHECK_FUNC_ARG                                           
         37        FETCH_FUNC_ARG               global              $16     '_ENV'
         38        SEND_FUNC_ARG                                            $16
         39        DO_FCALL                                      0          
   42    40        INIT_METHOD_CALL                                         !0, 'setParameterSource'
         41        SEND_VAL_EX                                              'cookie'
         42        CHECK_FUNC_ARG                                           
         43        FETCH_FUNC_ARG               global              $18     '_COOKIE'
         44        SEND_FUNC_ARG                                            $18
         45        DO_FCALL                                      0          
   43    46        INIT_METHOD_CALL                                         !0, 'setParameterSource'
         47        SEND_VAL_EX                                              'server'
         48        CHECK_FUNC_ARG                                           
         49        FETCH_FUNC_ARG               global              $20     '_SERVER'
         50        SEND_FUNC_ARG                                            $20
         51        DO_FCALL                                      0          
   44    52      > RETURN                                                   null

End of function getphpdefaultrequest

End of class Vagabond\Http\Request.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.79 ms | 1412 KiB | 21 Q