3v4l.org

run code in 500+ PHP versions simultaneously
<?php //declare(strict_types = 1); interface FooIface{} class FooClass{} function fooNullable(?string $a,?int $b, ?float $c, ?bool $d, ?FooIface $e, ?FooClass $g) : ?int {} function foo ( string $a, int $b, float $c, bool $d, FooIface $e, FooClass $g) : int {} function printTypes(string $fn) { $reflectionFunction = new \ReflectionFunction($fn); $functionParameters = $reflectionFunction->getParameters(); foreach ($functionParameters as $parameter) { var_dump($parameter->getType()->__toString()); } echo "return:"; var_dump($reflectionFunction->getReturnType()->__toString()); return; } echo " ---not nullable--- "; printTypes('foo'); echo " --nullable-- "; printTypes('fooNullable');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HLdjC
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                         '%0A---not+nullable---%0A'
   26     1        INIT_FCALL                                                   'printtypes'
          2        SEND_VAL                                                     'foo'
          3        DO_FCALL                                          0          
   28     4        ECHO                                                         '%0A--nullable--%0A'
   31     5        INIT_FCALL                                                   'printtypes'
          6        SEND_VAL                                                     'fooNullable'
          7        DO_FCALL                                          0          
          8      > RETURN                                                       1

Function foonullable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HLdjC
function name:  fooNullable
number of ops:  8
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d, !4 = $e, !5 = $g
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
          4        RECV                                                 !4      
          5        RECV                                                 !5      
          6        VERIFY_RETURN_TYPE                                           
          7      > RETURN                                                       null

End of function foonullable

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HLdjC
function name:  foo
number of ops:  8
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d, !4 = $e, !5 = $g
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
          4        RECV                                                 !4      
          5        RECV                                                 !5      
          6        VERIFY_RETURN_TYPE                                           
          7      > RETURN                                                       null

End of function foo

Function printtypes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/HLdjC
function name:  printTypes
number of ops:  29
compiled vars:  !0 = $fn, !1 = $reflectionFunction, !2 = $functionParameters, !3 = $parameter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        NEW                                                  $4      'ReflectionFunction'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !1, $4
   13     5        INIT_METHOD_CALL                                             !1, 'getParameters'
          6        DO_FCALL                                          0  $7      
          7        ASSIGN                                                       !2, $7
   15     8      > FE_RESET_R                                           $9      !2, ->18
          9    > > FE_FETCH_R                                                   $9, !3, ->18
   16    10    >   INIT_FCALL                                                   'var_dump'
         11        INIT_METHOD_CALL                                             !3, 'getType'
         12        DO_FCALL                                          0  $10     
         13        INIT_METHOD_CALL                                             $10, '__toString'
         14        DO_FCALL                                          0  $11     
         15        SEND_VAR                                                     $11
         16        DO_ICALL                                                     
   15    17      > JMP                                                          ->9
         18    >   FE_FREE                                                      $9
   18    19        ECHO                                                         'return%3A'
   19    20        INIT_FCALL                                                   'var_dump'
         21        INIT_METHOD_CALL                                             !1, 'getReturnType'
         22        DO_FCALL                                          0  $13     
         23        INIT_METHOD_CALL                                             $13, '__toString'
         24        DO_FCALL                                          0  $14     
         25        SEND_VAR                                                     $14
         26        DO_ICALL                                                     
   20    27      > RETURN                                                       null
   21    28*     > RETURN                                                       null

End of function printtypes

Class FooIface: [no user functions]
Class FooClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.36 ms | 2377 KiB | 16 Q