php / php-src

The PHP Interpreter
https://www.php.net
Other
37.95k stars 7.73k forks source link

ReflectionClass::isInstantiable() returns true for enums in PHP8.1 #8583

Closed CxDevLead closed 2 years ago

CxDevLead commented 2 years ago

Description

The following code:

enum Subdomain: int
{
    case Test = 0;
}

$subdomain = Subdomain::Test;
$reflectionClass = new ReflectionClass(Subdomain::class);
var_dump($subdomain, $reflectionClass->isInstantiable(), $reflectionClass->isEnum());

Resulted in this output:

enum(Subdomain::Test) bool(true) bool(true)

But I expected this output instead:

enum(Subdomain::Test) bool(false) bool(true)

PHP Version

PHP 8.1.1

Operating System

Mac 12.4

CxDevLead commented 2 years ago

Duplicate, my fault.