Cannot increment property %s::$%s of type int past its maximal value

Description

When a property is typed as an int, it cannot have a value higher than PHP_INT_MIN: beyond it, it would be turned into a float. There is a symetric error with the min value of an integer.

Example

<?php

class X {
    public int $p;
}

$x = new X;

$x->p = PHP_INT_MAX;
++$test->foo;

?>

Literal Examples

  • Cannot increment property X::$p of type int past its maximal value

Solutions

  • Check the value before incrementing.

  • Drop the type, but see the property get turned into a float.