3v4l.org

run code in 500+ PHP versions simultaneously
<?php function absint( $maybeint ): int { $abs = abs( (int) $maybeint ); /* * abs() can return a float when $maybeint is larger than PHP_INT_MAX. * When that happens, PHP 8.5+ emits a warning that the vale is not * representable as an int and a float value is returned. In this case, * the value is clamped to PHP_INT_MAX. */ if ( is_float( $abs ) ) { return PHP_INT_MAX; } return $abs; } $maybeints = array( 'zero' => 0, 'negative 1 int' => -1, 'positive 1 int' => 1, 'negative min int' => PHP_INT_MIN, 'negative min int minus 1' => PHP_INT_MIN - 1, 'negative min int times 2' => PHP_INT_MIN * 2, 'positive max int' => PHP_INT_MAX, 'positive max int plus 1' => PHP_INT_MAX + 1, 'positive max int times 2' => PHP_INT_MAX * 2, 'positive max int as string' => (string) PHP_INT_MAX, 'positive max int times 1000 as string' => (string) PHP_INT_MAX . '000', ); foreach ( $maybeints as $case => $maybeint ) { echo "# $case\n\n"; echo 'Input: '; var_dump( $maybeint ); echo 'Outut: '; var_dump( absint( $maybeint ) ); echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 21
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/LNMss
function name:  (null)
number of ops:  23
compiled vars:  !0 = $maybeints, !1 = $maybeint, !2 = $case
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                       !0, <array>
   32     1      > FE_RESET_R                                           $4      !0, ->21
          2    > > FE_FETCH_R                                           ~5      $4, !1, ->21
          3    >   ASSIGN                                                       !2, ~5
   33     4        ROPE_INIT                                         3  ~8      '%23+'
          5        ROPE_ADD                                          1  ~8      ~8, !2
          6        ROPE_END                                          2  ~7      ~8, '%0A%0A'
          7        ECHO                                                         ~7
   34     8        ECHO                                                         'Input%3A+'
   35     9        INIT_FCALL                                                   'var_dump'
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                                     
   36    12        ECHO                                                         'Outut%3A+'
   37    13        INIT_FCALL                                                   'var_dump'
         14        INIT_FCALL                                                   'absint'
         15        SEND_VAR                                                     !1
         16        DO_FCALL                                          0  $11     
         17        SEND_VAR                                                     $11
         18        DO_ICALL                                                     
   38    19        ECHO                                                         '%0A'
   32    20      > JMP                                                          ->2
         21    >   FE_FREE                                                      $4
   39    22      > RETURN                                                       1

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

End of function absint

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.71 ms | 1490 KiB | 16 Q