3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add(float $a, float $b): float { return $a + $b; } var_dump(add("1", "1")); // float(2) var_dump(add("1", "1foo")); // PHP Notice: A non well formed numeric value encountered // float(2) var_dump((float) "foo"); // float(0) var_dump(floatval("foo")); // float(0) try { var_dump(add("1", "foo")); } catch (Throwable $e) { var_dump($e); } // PHP Fatal error: Uncaught TypeError: Argument 2 passed to add() must be of the type float, string given
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 30
Branch analysis from position: 30
2 jumps found. (Code = 107) Position 1 = 31, Position 2 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0m9je
function name:  (null)
number of ops:  35
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'add'
          2        SEND_VAL                                                 '1'
          3        SEND_VAL                                                 '1'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
    9     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'add'
          9        SEND_VAL                                                 '1'
         10        SEND_VAL                                                 '1foo'
         11        DO_FCALL                                      0  $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                                 
   12    14        INIT_FCALL                                               'var_dump'
         15        CAST                                          5  ~5      'foo'
         16        SEND_VAL                                                 ~5
         17        DO_ICALL                                                 
   14    18        INIT_FCALL                                               'var_dump'
         19        CAST                                          5  ~7      'foo'
         20        SEND_VAL                                                 ~7
         21        DO_ICALL                                                 
   17    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'add'
         24        SEND_VAL                                                 '1'
         25        SEND_VAL                                                 'foo'
         26        DO_FCALL                                      0  $9      
         27        SEND_VAR                                                 $9
         28        DO_ICALL                                                 
         29      > JMP                                                      ->34
   18    30  E > > CATCH                                       last         'Throwable'
   19    31    >   INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                                 
   21    34    > > RETURN                                                   1

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

End of function add

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.72 ms | 999 KiB | 17 Q