3v4l.org

run code in 300+ PHP versions simultaneously
<?php try { function hello_1(?string $whom): ?string { if ($whom !== null) { return "Hello $whom"; } } var_dump(hello_1(null)); } catch (\Error $e) { echo $e->getMessage() . PHP_EOL; } /*try { function hello_2(?string $whom): ?string { if ($whom !== null) { return "Hello $whom"; } return; } var_dump(hello_2(null)); } catch (\Error $e) { echo $e->getMessage() . PHP_EOL; } Fatal error: A function with return type must return a value (did you mean "return null;" instead of "return;"?) in /in/QRj2G on line 20 */ try { function hello_3(?string $whom): ?string { if ($whom !== null) { return "Hello $whom"; } return null; } var_dump(hello_3(null)); } catch (\Error $e) { echo $e->getMessage() . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 8
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Found catch point at position: 21
Branch analysis from position: 21
2 jumps found. (Code = 107) Position 1 = 22, Position 2 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h6IYF
function name:  (null)
number of ops:  27
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_FUNCTION                                         'hello_1'
   10     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL_BY_NAME                                       'hello_1'
          3        SEND_VAL_EX                                              null
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
          7      > JMP                                                      ->13
   11     8  E > > CATCH                                       last         'Error'
   12     9    >   INIT_METHOD_CALL                                         !0, 'getMessage'
         10        DO_FCALL                                      0  $3      
         11        CONCAT                                           ~4      $3, '%0A'
         12        ECHO                                                     ~4
   32    13    >   DECLARE_FUNCTION                                         'hello_3'
   39    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL_BY_NAME                                       'hello_3'
         16        SEND_VAL_EX                                              null
         17        DO_FCALL                                      0  $5      
         18        SEND_VAR                                                 $5
         19        DO_ICALL                                                 
         20      > JMP                                                      ->26
   40    21  E > > CATCH                                       last         'Error'
   41    22    >   INIT_METHOD_CALL                                         !0, 'getMessage'
         23        DO_FCALL                                      0  $7      
         24        CONCAT                                           ~8      $7, '%0A'
         25        ECHO                                                     ~8
   42    26    > > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h6IYF
function name:  hello_1
number of ops:  9
compiled vars:  !0 = $whom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        TYPE_CHECK                                  1020          !0
          2      > JMPZ                                                     ~1, ->7
    6     3    >   NOP                                                      
          4        FAST_CONCAT                                      ~2      'Hello+', !0
          5        VERIFY_RETURN_TYPE                                       ~2
          6      > RETURN                                                   ~2
    8     7    >   VERIFY_RETURN_TYPE                                       
          8      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h6IYF
function name:  hello_3
number of ops:  10
compiled vars:  !0 = $whom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        TYPE_CHECK                                  1020          !0
          2      > JMPZ                                                     ~1, ->7
   34     3    >   NOP                                                      
          4        FAST_CONCAT                                      ~2      'Hello+', !0
          5        VERIFY_RETURN_TYPE                                       ~2
          6      > RETURN                                                   ~2
   36     7    > > RETURN                                                   null
   37     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.3 ms | 1003 KiB | 14 Q