<?php
readonly class UserData {
    public string $name;
    public int $age;

    public function __construct(string $name, int $age) {
        $this->name = $name;
        $this->age = $age;
    }
}

$user = new UserData('Ala', 25);
$user->name = 'Ela'; // Błąd! Próba zmiany właściwości readonly