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));

preferences:
45.92 ms | 402 KiB | 5 Q