Closed
Description
Description
Referenced RFC #13455
The following code:
<?php
final readonly class ReadonlyClassWithProperty
{
public const int DEFAULT_VALUE = 640;
public function __construct(
public int $value = self::DEFAULT_VALUE {
set(int $value) => $value;
},
) {}
}
// Need to create new object multiple times
$ctx = new ReadonlyClassWithProperty();
$ctx = new ReadonlyClassWithProperty();
Resulted in this output:
*nothing*
But I expected this output instead:
PHP Fatal error: Uncaught Error: Cannot modify readonly property ReadonlyClassWithProperty::$value in ...
Stack trace:
#0 ...: ReadonlyClassWithProperty->$value::set(640)
#1 ...: ReadonlyClassWithProperty->__construct()
#2 {main}
thrown in ...
@iluuu1994 I mention you again, this time it's a not known issue, right?)
PHP Version
PHP 8.4-beta1
Operating System
No response