php-src
php-src copied to clipboard
ReflectionEnumBackedCase can be used on a non-backed enum via a constructor trick
Description
The following code:
<?php
enum NotBacked { case A; };
class FU extends ReflectionEnumBackedCase {
public function __construct($class, $const) {
ReflectionClassConstant::__construct($class, $const);
}
}
$fu = new FU('NotBacked', 'A');
$fu->getBackingValue();
Resulted in this output:
*explosion*
But I expected this output instead:
exception
PHP Version
8.4+
Operating System
No response