3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Database {} $fns = [ function ($str) {}, function ($str ="hello") {}, function (string $str) {}, function (string $str = null) {}, function (?string $str) {}, function (?Database $db) {}, function (Database $db = new Database()) {}, function (string|null $str) {}, function (string $str = "hello") {}, function (?string $str = "hello") {}, function (string|int $str) {}, function (string|null $str = null) {}, function (string|null $str = "hello") {}, ]; echo "parameter\tallowsNull\tisOptional\tgetDefaultValue\tgetType\n"; foreach ($fns as $fn) { $param = (new ReflectionFunction($fn))->getParameters()[0]; echo substr($param->__toString(), 26, -2) . "\t" . json_encode($param->allowsNull()) . "\t" . json_encode($param->isOptional()) . "\t" . ($param->isDefaultValueAvailable() ? str_replace("\n", "", print_r($param->getDefaultValue(), true)) : "throws ReflectionException") . "\t" . ($param->getType() ? get_class($param->getType()) : "null") . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 85
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 85
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 69
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 80
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 80
Branch analysis from position: 75
Branch analysis from position: 80
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
filename:       /in/pnXfM
function name:  (null)
number of ops:  87
compiled vars:  !0 = $fns, !1 = $fn, !2 = $param
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          1        INIT_ARRAY                                           ~4      ~3
    7     2        DECLARE_LAMBDA_FUNCTION                              ~5      [1]
          3        ADD_ARRAY_ELEMENT                                    ~4      ~5
    8     4        DECLARE_LAMBDA_FUNCTION                              ~6      [2]
          5        ADD_ARRAY_ELEMENT                                    ~4      ~6
    9     6        DECLARE_LAMBDA_FUNCTION                              ~7      [3]
          7        ADD_ARRAY_ELEMENT                                    ~4      ~7
   10     8        DECLARE_LAMBDA_FUNCTION                              ~8      [4]
          9        ADD_ARRAY_ELEMENT                                    ~4      ~8
   11    10        DECLARE_LAMBDA_FUNCTION                              ~9      [5]
         11        ADD_ARRAY_ELEMENT                                    ~4      ~9
   12    12        DECLARE_LAMBDA_FUNCTION                              ~10     [6]
         13        ADD_ARRAY_ELEMENT                                    ~4      ~10
   13    14        DECLARE_LAMBDA_FUNCTION                              ~11     [7]
         15        ADD_ARRAY_ELEMENT                                    ~4      ~11
   14    16        DECLARE_LAMBDA_FUNCTION                              ~12     [8]
         17        ADD_ARRAY_ELEMENT                                    ~4      ~12
   15    18        DECLARE_LAMBDA_FUNCTION                              ~13     [9]
         19        ADD_ARRAY_ELEMENT                                    ~4      ~13
   16    20        DECLARE_LAMBDA_FUNCTION                              ~14     [10]
         21        ADD_ARRAY_ELEMENT                                    ~4      ~14
   17    22        DECLARE_LAMBDA_FUNCTION                              ~15     [11]
         23        ADD_ARRAY_ELEMENT                                    ~4      ~15
   18    24        DECLARE_LAMBDA_FUNCTION                              ~16     [12]
         25        ADD_ARRAY_ELEMENT                                    ~4      ~16
    5    26        ASSIGN                                                       !0, ~4
   21    27        ECHO                                                         'parameter%09allowsNull%09isOptional%09getDefaultValue%09getType%0A'
   23    28      > FE_RESET_R                                           $18     !0, ->85
         29    > > FE_FETCH_R                                                   $18, !1, ->85
   24    30    >   NEW                                                  $19     'ReflectionFunction'
         31        SEND_VAR_EX                                                  !1
         32        DO_FCALL                                          0          
         33        INIT_METHOD_CALL                                             $19, 'getParameters'
         34        DO_FCALL                                          0  $21     
         35        FETCH_DIM_R                                          ~22     $21, 0
         36        ASSIGN                                                       !2, ~22
   26    37        INIT_METHOD_CALL                                             !2, '__toString'
         38        DO_FCALL                                          0  $24     
         39        FRAMELESS_ICALL_3                substr              ~25     $24, 26
         40        OP_DATA                                                      -2
   27    41        CONCAT                                               ~26     ~25, '%09'
         42        INIT_FCALL                                                   'json_encode'
         43        INIT_METHOD_CALL                                             !2, 'allowsNull'
         44        DO_FCALL                                          0  $27     
         45        SEND_VAR                                                     $27
         46        DO_ICALL                                             $28     
         47        CONCAT                                               ~29     ~26, $28
   28    48        CONCAT                                               ~30     ~29, '%09'
         49        INIT_FCALL                                                   'json_encode'
         50        INIT_METHOD_CALL                                             !2, 'isOptional'
         51        DO_FCALL                                          0  $31     
         52        SEND_VAR                                                     $31
         53        DO_ICALL                                             $32     
         54        CONCAT                                               ~33     ~30, $32
   29    55        CONCAT                                               ~34     ~33, '%09'
         56        INIT_METHOD_CALL                                             !2, 'isDefaultValueAvailable'
         57        DO_FCALL                                          0  $35     
         58      > JMPZ                                                         $35, ->69
         59    >   INIT_FCALL                                                   'print_r'
         60        INIT_METHOD_CALL                                             !2, 'getDefaultValue'
         61        DO_FCALL                                          0  $36     
         62        SEND_VAR                                                     $36
         63        SEND_VAL                                                     <true>
         64        DO_ICALL                                             $37     
         65        FRAMELESS_ICALL_3                str_replace         ~38     '%0A', ''
         66        OP_DATA                                                      $37
         67        QM_ASSIGN                                            ~39     ~38
         68      > JMP                                                          ->70
         69    >   QM_ASSIGN                                            ~39     'throws+ReflectionException'
         70    >   CONCAT                                               ~40     ~34, ~39
   30    71        CONCAT                                               ~41     ~40, '%09'
         72        INIT_METHOD_CALL                                             !2, 'getType'
         73        DO_FCALL                                          0  $42     
         74      > JMPZ                                                         $42, ->80
         75    >   INIT_METHOD_CALL                                             !2, 'getType'
         76        DO_FCALL                                          0  $43     
         77        GET_CLASS                                            ~44     $43
         78        QM_ASSIGN                                            ~45     ~44
         79      > JMP                                                          ->81
         80    >   QM_ASSIGN                                            ~45     'null'
         81    >   CONCAT                                               ~46     ~41, ~45
   31    82        CONCAT                                               ~47     ~46, '%0A'
         83        ECHO                                                         ~47
   23    84      > JMP                                                          ->29
         85    >   FE_FREE                                                      $18
   32    86      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:6}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:7}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                            !0      'hello'
          1      > RETURN                                                       null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:8}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:9}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV_INIT                                            !0      null
          1      > RETURN                                                       null

End of Dynamic Function 3

Dynamic Function 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:10}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of Dynamic Function 4

Dynamic Function 5
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:11}
number of ops:  2
compiled vars:  !0 = $db
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of Dynamic Function 5

Dynamic Function 6
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:12}
number of ops:  2
compiled vars:  !0 = $db
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV_INIT                                            !0      <const ast>
          1      > RETURN                                                       null

End of Dynamic Function 6

Dynamic Function 7
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:13}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of Dynamic Function 7

Dynamic Function 8
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:14}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV_INIT                                            !0      'hello'
          1      > RETURN                                                       null

End of Dynamic Function 8

Dynamic Function 9
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:15}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                            !0      'hello'
          1      > RETURN                                                       null

End of Dynamic Function 9

Dynamic Function 10
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:16}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of Dynamic Function 10

Dynamic Function 11
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:17}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                            !0      null
          1      > RETURN                                                       null

End of Dynamic Function 11

Dynamic Function 12
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnXfM
function name:  {closure:/in/pnXfM:18}
number of ops:  2
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV_INIT                                            !0      'hello'
          1      > RETURN                                                       null

End of Dynamic Function 12

Class Database: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
187.44 ms | 916 KiB | 10 Q