新版本的变更 / PHP 8.1

// *** before: ***
class Money {
    private int $cents;

    public function __construct(int $cents) {
        $this->cents = $cents;
    }
    // nothing stops another method of the class from changing $cents later
}

// *** in version 8.1: ***
class Money {
    public readonly int $cents;

    public function __construct(int $cents) {
        $this->cents = $cents;
    }
}

$price = new Money(500);
// $price->cents = 0; // Error: cannot modify readonly property