- var_dump: documentation ( source)
<?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));