[php-src] Issue #15731: AllowDynamicProperties validation should error on enums
| From: | DanielEScherzer | Date: | Tue, 03 Sep 2024 18:25:08 +0000 |
| Subject: | [php-src] Issue #15731: AllowDynamicProperties validation should error on enums | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247692@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15731
Author: DanielEScherzer
### Description
The following code:
```php
<?php
#[AllowDynamicProperties]
enum Example {
case MyCase;
}
$c = Example::MyCase;
$c->prop = 'foo';
```
Resulted in this output:
```
Fatal error: Uncaught Error: Cannot create dynamic property Example::$prop in /in/Aqipu:9
Stack trace:
#0 {main}
thrown in /in/Aqipu on line 9
Process exited with code 255.
```
But I expected this output instead:
```
Fatal error: Cannot apply #[AllowDynamicProperties] to enum in /in/Aqipu on line 4
Process exited with code 255.
```
### PHP Version
PHP 8.2
### Operating System
_No response_