[php-src] Issue #12452: Allow modifying readonly promoted properties in constructor
| From: | rentalhost | Date: | Tue, 17 Oct 2023 00:13:49 +0000 |
| Subject: | [php-src] Issue #12452: Allow modifying readonly promoted properties in constructor | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245590@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12452
Author: rentalhost
### Description
Eg.
```php
class Example {
public function __construct(public readonly int|null $a = null) {
$this->a = $a ?? 123;
}
}
```
So we can use
null as the default value and replace it with the final value inside the
constructor (ref. https://github.com/hammer-tools/php-hammer/issues/33).