3v4l.org

run code in 300+ PHP versions simultaneously
<?php function try_string_to_int($value): ?int { if (is_string($value) && $value === (string)(int) $value) { return (int) $value; } return null; } var_dump(try_string_to_int('foo')); var_dump(try_string_to_int('1e10')); var_dump(try_string_to_int('42')); var_dump(try_string_to_int('0')); var_dump(try_string_to_int('-500'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VqVh0
function name:  (null)
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'try_string_to_int'
          2        SEND_VAL                                                 'foo'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   13     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'try_string_to_int'
          8        SEND_VAL                                                 '1e10'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   14    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'try_string_to_int'
         14        SEND_VAL                                                 '42'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   15    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'try_string_to_int'
         20        SEND_VAL                                                 '0'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
   16    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'try_string_to_int'
         26        SEND_VAL                                                 '-500'
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

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

End of function try_string_to_int

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.18 ms | 1017 KiB | 19 Q