3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BoundedInteger { protected $value = 0; public function __construct(Int $value) { $this->value = $value % PHP_INT_MAX; } public function add(Int $value) :Int { return ($this->value + ($value % PHP_INT_MAX)) % PHP_INT_MAX; } public function sub(Int $value) :Int { return ($this->value - ($value % PHP_INT_MAX)) % PHP_INT_MAX; } public function get(): Int { return $this->value; } } $val = new BoundedInteger(PHP_INT_MAX - 1); var_dump($val->add(1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLST4
function name:  (null)
number of ops:  11
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'BoundedInteger'
          1        SEND_VAL_EX                                              9223372036854775806
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   28     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'add'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class BoundedInteger:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLST4
function name:  __construct
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        MOD                                              ~2      !0, 9223372036854775807
          2        ASSIGN_OBJ                                               'value'
          3        OP_DATA                                                  ~2
    9     4      > RETURN                                                   null

End of function __construct

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

End of function add

Function sub:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLST4
function name:  sub
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        FETCH_OBJ_R                                      ~1      'value'
          2        MOD                                              ~2      !0, 9223372036854775807
          3        SUB                                              ~3      ~1, ~2
          4        MOD                                              ~4      ~3, 9223372036854775807
          5        VERIFY_RETURN_TYPE                                       ~4
          6      > RETURN                                                   ~4
   19     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function sub

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLST4
function name:  get
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   24     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function get

End of class BoundedInteger.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.35 ms | 1405 KiB | 15 Q