[php-src] Issue #11410: Support for readonly default value
| From: | boan-jfm | Date: | Fri, 09 Jun 2023 08:22:16 +0000 |
| Subject: | [php-src] Issue #11410: Support for readonly default value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244636@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11410
Author: boan-jfm
### Description
Allowed:
```
class ReadOnlyConstructorAssigned
{
public readonly string $foo;
public function __construct() {
$this->foo = 'bar';
}
}
```
Not allowed:
```
class ReadOnlyDefault
{
public readonly string $foo = 'bar';
}
```
Example: https://tehplayground.com/zyMbrP3OUJ720MQJ
There may be a technical explanation why this is so, but I think the latter would make sense to
support.