3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bob = function(Google $x, $y = 10, $z = 'sponge bob'){ return $x + $y; }; $functionReflection = new ReflectionFunction($bob); $parameters = $functionReflection->getParameters(); foreach($parameters as $param) { echo $param->name . ' '; echo var_export($param->isOptional(), true) . ' '; echo $param->isOptional() ? var_export($param->getDefaultValue(), true) : '-'; echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 37
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 37
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/U6RqX
function name:  (null)
number of ops:  39
compiled vars:  !0 = $bob, !1 = $functionReflection, !2 = $parameters, !3 = $param
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FU6RqX%3A3%240'
          1        ASSIGN                                                   !0, ~4
    7     2        NEW                                              $6      'ReflectionFunction'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
    8     6        INIT_METHOD_CALL                                         !1, 'getParameters'
          7        DO_FCALL                                      0  $9      
          8        ASSIGN                                                   !2, $9
   10     9      > FE_RESET_R                                       $11     !2, ->37
         10    > > FE_FETCH_R                                               $11, !3, ->37
   11    11    >   FETCH_OBJ_R                                      ~12     !3, 'name'
         12        CONCAT                                           ~13     ~12, '+'
         13        ECHO                                                     ~13
   12    14        INIT_FCALL                                               'var_export'
         15        INIT_METHOD_CALL                                         !3, 'isOptional'
         16        DO_FCALL                                      0  $14     
         17        SEND_VAR                                                 $14
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $15     
         20        CONCAT                                           ~16     $15, '+'
         21        ECHO                                                     ~16
   13    22        INIT_METHOD_CALL                                         !3, 'isOptional'
         23        DO_FCALL                                      0  $17     
         24      > JMPZ                                                     $17, ->33
         25    >   INIT_FCALL                                               'var_export'
         26        INIT_METHOD_CALL                                         !3, 'getDefaultValue'
         27        DO_FCALL                                      0  $18     
         28        SEND_VAR                                                 $18
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $19     
         31        QM_ASSIGN                                        ~20     $19
         32      > JMP                                                      ->34
         33    >   QM_ASSIGN                                        ~20     '-'
         34    >   ECHO                                                     ~20
   14    35        ECHO                                                     '%0A'
   10    36      > JMP                                                      ->10
         37    >   FE_FREE                                                  $11
   15    38      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FU6RqX%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U6RqX
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $x, !1 = $y, !2 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      10
          2        RECV_INIT                                        !2      'sponge+bob'
    4     3        ADD                                              ~3      !0, !1
          4      > RETURN                                                   ~3
    5     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FU6RqX%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.5 ms | 1400 KiB | 15 Q