[php-src] Issue #7887: isCloneable() on ReflectionEnum errors
| From: | Crell | Date: | Wed, 05 Jan 2022 20:12:38 +0000 |
| Subject: | [php-src] Issue #7887: isCloneable() on ReflectionEnum errors | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238779@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7887
Author: Crell
### Description
The following code:
```php
<?php
enum A {
case B;
}
$e = new ReflectionEnum(A::class);
var_dump($e->isCloneable());
$c = new ReflectionClass(A::class);
var_dump($c->isCloneable());
```
Resulted in this output:
```
Fatal error: Uncaught Error: Cannot instantiate enum A in /in/IIhNF:8
Stack trace:
#0 /in/IIhNF(8): ReflectionClass->isCloneable()
#1 {main}
thrown in /in/IIhNF on line 8
```
But I expected this output instead:
```
false
false
```
Right now,
isCloneable() errors out on an Enum, regardless of whether it is called on
ReflectionEnum or ReflectionClass. (The former is a child of the latter,
so it's possible to reflect on an Enum with either Reflection class.) Since enums are not
cloneable, I would expect it to simply return false in both cases.
### PHP Version
8.1.1
### Operating System
_No response_