3v4l.org

run code in 500+ PHP versions simultaneously
<?php function absint( $maybeint ): int { return abs( (int) $maybeint ); } function safe_absint( $maybeint ): int { $maybeint = (int) $maybeint; // Avoid PHP fatal error where we might return a float instead of an int if ( PHP_INT_MIN === $maybeint ) { return PHP_INT_MAX; } return abs( $maybeint ); } $stuff = '-99999999999999999999'; var_dump( safe_absint( $stuff ) ); var_dump( absint( $stuff ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6JIR0
function name:  (null)
number of ops:  14
compiled vars:  !0 = $stuff
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                       !0, '-99999999999999999999'
   20     1        INIT_FCALL                                                   'var_dump'
          2        INIT_FCALL                                                   'safe_absint'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $2      
          5        SEND_VAR                                                     $2
          6        DO_ICALL                                                     
   22     7        INIT_FCALL                                                   'var_dump'
          8        INIT_FCALL                                                   'absint'
          9        SEND_VAR                                                     !0
         10        DO_FCALL                                          0  $4      
         11        SEND_VAR                                                     $4
         12        DO_ICALL                                                     
         13      > RETURN                                                       1

Function absint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6JIR0
function name:  absint
number of ops:  9
compiled vars:  !0 = $maybeint
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'abs'
          2        CAST                                              4  ~1      !0
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5        VERIFY_RETURN_TYPE                                           $2
          6      > RETURN                                                       $2
    5     7*       VERIFY_RETURN_TYPE                                           
          8*     > RETURN                                                       null

End of function absint

Function safe_absint:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6JIR0
function name:  safe_absint
number of ops:  13
compiled vars:  !0 = $maybeint
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        CAST                                              4  ~1      !0
          2        ASSIGN                                                       !0, ~1
   11     3        IS_IDENTICAL                                                 !0, -9223372036854775808
          4      > JMPZ                                                         ~3, ->6
   12     5    > > RETURN                                                       9223372036854775807
   15     6    >   INIT_FCALL                                                   'abs'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $4      
          9        VERIFY_RETURN_TYPE                                           $4
         10      > RETURN                                                       $4
   16    11*       VERIFY_RETURN_TYPE                                           
         12*     > RETURN                                                       null

End of function safe_absint

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.57 ms | 801 KiB | 12 Q