3v4l.org

run code in 500+ PHP versions simultaneously
<?php function withAssignment(float $f): float { if ($f === 0.0) { $f = 0.0; // reported as assign.redundant } return $f; } function withoutAssignment(float $f): float { if ($f === 0.0) { } return $f; } function g(): float { $x = -0.0; $x = 0.0; // reported as assign.redundant return $x; } foreach (['withAssignment', 'withoutAssignment', 'g'] as $fn) { $v = $fn === 'g' ? g() : $fn(-0.0); printf( "%-18s (string): %-3s var_export: %-5s json_encode: %-3s fdiv(1, v): %s\n", $fn, (string) $v, var_export($v, true), json_encode($v), var_export(fdiv(1, $v), true), ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 38
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 38
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/NdkoE
function name:  (null)
number of ops:  40
compiled vars:  !0 = $fn, !1 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E > > FE_RESET_R                                           $2      <array>, ->38
          1    > > FE_FETCH_R                                                   $2, !0, ->38
   23     2    >   IS_IDENTICAL                                                 !0, 'g'
          3      > JMPZ                                                         ~3, ->8
          4    >   INIT_FCALL                                                   'g'
          5        DO_FCALL                                          0  $4      
          6        QM_ASSIGN                                            ~5      $4
          7      > JMP                                                          ->12
          8    >   INIT_DYNAMIC_CALL                                            !0
          9        SEND_VAL_EX                                                  -0
         10        DO_FCALL                                          0  $6      
         11        QM_ASSIGN                                            ~5      $6
         12    >   ASSIGN                                                       !1, ~5
   24    13        INIT_FCALL                                                   'printf'
   25    14        SEND_VAL                                                     '%25-18s+%28string%29%3A+%25-3s++var_export%3A+%25-5s++json_encode%3A+%25-3s++fdiv%281%2C+v%29%3A+%25s%0A'
   26    15        SEND_VAR                                                     !0
   27    16        CAST                                              6  ~8      !1
         17        SEND_VAL                                                     ~8
   28    18        INIT_FCALL                                                   'var_export'
         19        SEND_VAR                                                     !1
         20        SEND_VAL                                                     <true>
         21        DO_ICALL                                             $9      
         22        SEND_VAR                                                     $9
   29    23        INIT_FCALL                                                   'json_encode'
         24        SEND_VAR                                                     !1
         25        DO_ICALL                                             $10     
         26        SEND_VAR                                                     $10
   30    27        INIT_FCALL                                                   'var_export'
         28        INIT_FCALL                                                   'fdiv'
         29        SEND_VAL                                                     1
         30        SEND_VAR                                                     !1
         31        DO_ICALL                                             $11     
         32        SEND_VAR                                                     $11
         33        SEND_VAL                                                     <true>
         34        DO_ICALL                                             $12     
         35        SEND_VAR                                                     $12
   24    36        DO_ICALL                                                     
   22    37      > JMP                                                          ->1
         38    >   FE_FREE                                                      $2
   32    39      > RETURN                                                       1

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

End of function withassignment

Function withoutassignment:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 3
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
filename:       /in/NdkoE
function name:  withoutAssignment
number of ops:  7
compiled vars:  !0 = $f
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   11     1        IS_IDENTICAL                                                 !0, 0
          2      > JMPZ                                                         ~1, ->3
   13     3    >   VERIFY_RETURN_TYPE                                           !0
          4      > RETURN                                                       !0
   14     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of function withoutassignment

Function g:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NdkoE
function name:  g
number of ops:  6
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                       !0, -0
   18     1        ASSIGN                                                       !0, 0
   19     2        VERIFY_RETURN_TYPE                                           !0
          3      > RETURN                                                       !0
   20     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function g

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.33 ms | 488 KiB | 12 Q